Skip to content

Commit c8a14bd

Browse files
committed
1 parent 2786ca1 commit c8a14bd

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

examples/passing/RowSynonyms.purs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
module Main where
2+
3+
import Control.Monad.Eff
4+
import Control.Monad.ST
5+
6+
type State bindings =
7+
{
8+
bindings :: {addition :: Number | bindings},
9+
other :: String
10+
}
11+
12+
type MyBindings = (test :: Number)
13+
14+
data Shadow bindings = Shadow String
15+
16+
shadows :: Shadow (Object MyBindings)
17+
shadows = Shadow "uhh"
18+
19+
main :: Eff () Unit
20+
main = withIt
21+
shadows
22+
\ bindings -> do
23+
let state =
24+
{
25+
bindings : bindings,
26+
other : "Test"
27+
}
28+
runST do
29+
stRef <- newSTRef state
30+
handleKeyD stRef
31+
return unit
32+
33+
34+
withIt :: forall bindings eff a. Shadow (Object bindings) ->
35+
({addition :: Number | bindings} -> Eff eff a) -> Eff eff a
36+
withIt (Shadow str) success = do
37+
b <- withBindings
38+
success (b{addition = 1})
39+
40+
foreign import withBindings
41+
"""
42+
function withBindings() {}
43+
""" :: forall eff bindings. Eff eff bindings
44+
45+
handleKeyD :: forall h eff. STRef h (State MyBindings) -> Eff (st :: ST h | eff) Unit
46+
handleKeyD state = return unit

src/Language/PureScript/TypeChecker/Unify.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ unifyRows r1 r2 =
130130
rest <- fresh
131131
u1 =:= rowFromList (sd2, rest)
132132
u2 =:= rowFromList (sd1, rest)
133+
unifyRows' sd1 (SaturatedTypeSynonym name args) sd2 r2' = do
134+
r1' <- expandTypeSynonym name $ args
135+
unifyRows (rowFromList (sd1, r1')) (rowFromList (sd2, r2'))
136+
unifyRows' sd1 r1' sd2 r2'@(SaturatedTypeSynonym _ _) = unifyRows' sd2 r2' sd1 r1'
133137
unifyRows' [] REmpty [] REmpty = return ()
134138
unifyRows' [] (TypeVar v1) [] (TypeVar v2) | v1 == v2 = return ()
135139
unifyRows' [] (Skolem _ s1 _) [] (Skolem _ s2 _) | s1 == s2 = return ()

0 commit comments

Comments
 (0)