Fixed Product comonad snippets

This commit is contained in:
Bartosz Milewski 2019-06-13 09:08:54 -07:00
parent 15c672cab1
commit 23f522ec08
5 changed files with 7 additions and 6 deletions

View File

@ -1 +1 @@
data Product e a = P e a deriving Functor
data Product e a = Prod e a deriving Functor

View File

@ -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

View File

@ -1 +1 @@
extract (P e a) = a
extract (Prod e a) = a

View File

@ -1 +1 @@
counit (Product (Reader f, s)) = f s
counit (Prod (Reader f) s)) = f s

View File

@ -1 +1,2 @@
unit a = Reader (\s -> Product (a, s))
unit :: a -> Reader s (Product a s)
unit a = Reader (\s -> Prod a s)