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