File tree 2 files changed +10
-11
lines changed 2 files changed +10
-11
lines changed Original file line number Diff line number Diff line change @@ -5,10 +5,13 @@ import ITMOPrelude.Primitive
5
5
import ITMOPrelude.List
6
6
import ITMOPrelude.Tree
7
7
8
- -- class Category cat where
9
- -- id :: cat a a
10
- -- (.) :: cat b c -> cat a b -> cat a c
11
-
8
+ class Category cat where
9
+ id :: cat a a
10
+ (.) :: cat b c -> cat a b -> cat a c
11
+
12
+ instance Category (-> ) where
13
+ id = \ x -> x
14
+ f . g = \ x -> f (g x)
12
15
13
16
class Functor f where
14
17
fmap :: (a -> b ) -> f a -> f b
@@ -63,6 +66,4 @@ newtype State s a = State { runState :: s -> (s, a) }
63
66
instance Monad (State s ) where
64
67
return a = State $ \ s -> (s, a)
65
68
ma >>= f = State $ \ s -> let (s', a) = runState ma s
66
- in runState (f a) s'
67
-
68
-
69
+ in runState (f a) s'
Original file line number Diff line number Diff line change 1
1
{-# LANGUAGE NoImplicitPrelude #-}
2
2
module ITMOPrelude.IO where
3
3
4
- import ITMOPrelude.Primitive
4
+ import ITMOPrelude.Primitive hiding ( (.) )
5
5
import ITMOPrelude.List
6
6
import ITMOPrelude.Categories
7
7
@@ -14,12 +14,10 @@ type IO a = State RealWorld a
14
14
15
15
getNat :: IO Nat
16
16
getNat = State getNat'
17
- where getNat' world = (newWorld, value)
17
+ where getNat' world = (newWorld, value)
18
18
where newWorld = RealWorld (tail . stdIn $ world) (stdOut world) (exitCode world)
19
19
value = head . stdIn $ world
20
20
21
-
22
-
23
21
putNat :: Nat -> IO ()
24
22
putNat n = State putNat'
25
23
where putNat' world = (newWorld, () )
You can’t perform that action at this time.
0 commit comments