mirror of
https://github.com/hmemcpy/milewski-ctfp-pdf.git
synced 2024-11-26 03:11:47 +03:00
Fixed Product comonad snippets
This commit is contained in:
parent
15c672cab1
commit
23f522ec08
@ -1 +1 @@
|
||||
data Product e a = P e a deriving Functor
|
||||
data Product e a = Prod e a deriving Functor
|
@ -1,4 +1,4 @@
|
||||
(=>=) :: (Product e a -> b) -> (Product e b -> c) -> (Product e a -> c)
|
||||
f =>= g = \(P e a) -> let b = f (P e a)
|
||||
c = g (P e b)
|
||||
f =>= g = \(Prod e a) -> let b = f (Prod e a)
|
||||
c = g (Prod e b)
|
||||
in c
|
@ -1 +1 @@
|
||||
extract (P e a) = a
|
||||
extract (Prod e a) = a
|
@ -1 +1 @@
|
||||
counit (Product (Reader f, s)) = f s
|
||||
counit (Prod (Reader f) s)) = f s
|
@ -1 +1,2 @@
|
||||
unit a = Reader (\s -> Product (a, s))
|
||||
unit :: a -> Reader s (Product a s)
|
||||
unit a = Reader (\s -> Prod a s)
|
Loading…
Reference in New Issue
Block a user