Skip to content

Commit f8ab7c5

Browse files
committed
Merge pull request #48 from parsonsmatt/master
Relax instance requirements for bind/monad
2 parents 0ed6dd0 + 09237cc commit f8ab7c5

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/Control/Comonad/Cofree.purs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ module Control.Comonad.Cofree
1010
import Prelude
1111

1212
import Control.Comonad (class Comonad)
13-
import Control.Alt ((<|>))
14-
import Control.MonadPlus (class MonadPlus)
13+
import Control.Alternative (class Alternative, (<|>), empty)
1514
import Control.Extend (class Extend)
1615
import Control.Monad.Trampoline (Trampoline, runTrampoline)
1716

@@ -82,12 +81,12 @@ instance applyCofree :: (Apply f) => Apply (Cofree f) where
8281
h = (head f) (head x)
8382
t = (<*>) <$> (tail f) <*> (tail x)
8483

85-
instance applicativeCofree :: (Applicative f) => Applicative (Cofree f) where
86-
pure a = mkCofree a (pure $ pure a)
84+
instance applicativeCofree :: (Alternative f) => Applicative (Cofree f) where
85+
pure a = mkCofree a empty
8786

88-
instance bindCofree :: (MonadPlus f) => Bind (Cofree f) where
87+
instance bindCofree :: (Alternative f) => Bind (Cofree f) where
8988
bind fa f = loop fa where
9089
loop fa = let fh = f (head fa)
9190
in mkCofree (head fh) ((tail fh) <|> (loop <$> tail fa))
9291

93-
instance monadCofree :: (MonadPlus f) => Monad (Cofree f)
92+
instance monadCofree :: (Alternative f) => Monad (Cofree f)

0 commit comments

Comments
 (0)