1
1
module Control.Monad.ListT
2
- ( ListT ()
2
+ ( ListT (..) -- FIXME: compiler bug: error in exports (wrong kind) unless constructor is exported
3
+ , Step (..) -- FIXME: have to export this for the preceding export
3
4
, nil
4
5
, cons'
5
6
, prepend'
@@ -64,8 +65,8 @@ module Control.Monad.ListT
64
65
65
66
concat :: forall f a. (Applicative f ) => ListT f a -> ListT f a -> ListT f a
66
67
concat x y = stepMap f x where
67
- f (Yield a s ) = Yield a (g <$> s ) where g s = s <> y
68
- f (Skip s ) = Skip (g <$> s ) where g s = s <> y
68
+ f (Yield a s ) = Yield a (flip (<>) y <$> s )
69
+ f (Skip s ) = Skip (flip (<>) y <$> s )
69
70
f Done = Skip (defer $ const y )
70
71
71
72
instance semigroupListT :: (Applicative f ) => Semigroup (ListT f a ) where
@@ -88,7 +89,7 @@ module Control.Monad.ListT
88
89
89
90
instance bindListT :: (Monad f ) => Bind (ListT f ) where
90
91
(>>=) fa f = stepMap g fa where
91
- g (Yield a s ) = Skip (h <$> s ) where h s = f a `concat` (s >>= f ) -- why overlapping instances?
92
+ g (Yield a s ) = Skip (h <$> s ) where h s = f a `concat` (s >>= f ) -- FIXME compiler bug with overlapping instances?
92
93
g (Skip s ) = Skip (h <$> s ) where h s = s >>= f
93
94
g Done = Done
94
95
@@ -124,7 +125,7 @@ module Control.Monad.ListT
124
125
125
126
takeWhile :: forall f a. (Applicative f ) => (a -> Boolean ) -> ListT f a -> ListT f a
126
127
takeWhile f = stepMap g where
127
- -- type inferencer bug with if/then/else !!!!!
128
+ -- FIXME: type inferencer bug with if/then/else
128
129
g (Yield a s ) = ifThenElse (f a ) (Yield a (takeWhile f <$> s)) Done where ifThenElse p a b = if p then a else b
129
130
g (Skip s ) = Skip $ takeWhile f <$> s
130
131
g Done = Done
0 commit comments