git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Fix #795
c8a14bdPhil Freeman
examples/passing/RowSynonyms.pursnew file+46
@@ -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+4
@@ -130,6 +130,10 @@ unifyRows r1 r2 =
130 rest <- fresh
130 rest <- fresh
131 u1 =:= rowFromList (sd2, rest)
131 u1 =:= rowFromList (sd2, rest)
132 u2 =:= rowFromList (sd1, rest)
132 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'
133 unifyRows' [] REmpty [] REmpty = return ()
137 unifyRows' [] REmpty [] REmpty = return ()
134 unifyRows' [] (TypeVar v1) [] (TypeVar v2) | v1 == v2 = return ()
138 unifyRows' [] (TypeVar v1) [] (TypeVar v2) | v1 == v2 = return ()
135 unifyRows' [] (Skolem _ s1 _) [] (Skolem _ s2 _) | s1 == s2 = return ()
139 unifyRows' [] (Skolem _ s1 _) [] (Skolem _ s2 _) | s1 == s2 = return ()