git.iko.soy/rowtype-yoga/purescript-native
on 24fdff2 help sign in
rowtype-yoga/purescript-native/examples/passing/RowPolyInstanceContext.purs
22 lines 496 B history raw
1module Main where
3import Prelude
5class T s m where
6 state :: (s -> s) -> m Unit
8data S s a = S (s -> { new :: s, ret :: a })
10instance st :: T s (S s) where
11 state f = S $ \s -> { new: f s, ret: unit }
13test1 :: forall r . S { foo :: String | r } Unit
14test1 = state $ \o -> o { foo = o.foo ++ "!" }
16test2 :: forall m r . (T { foo :: String | r } m) => m Unit
17test2 = state $ \o -> o { foo = o.foo ++ "!" }
19main = do
20 let t1 = test1
21 let t2 = test2
22 Control.Monad.Eff.Console.log "Done"