File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 1
1
module Control.Monad.Free
2
2
( Free
3
3
, suspendF
4
+ , wrap
4
5
, liftF
5
6
, hoistFree
6
7
, foldFree
@@ -121,16 +122,20 @@ liftF f = fromView (Bind (unsafeCoerceF f) (pure <<< unsafeCoerceVal))
121
122
unsafeCoerceVal :: forall a . Val -> a
122
123
unsafeCoerceVal = unsafeCoerce
123
124
124
- -- | Suspend a value given the applicative functor `f` into the free monad .
125
- suspendF :: forall f . Applicative f => Free f ~ > Free f
126
- suspendF f = fromView (Bind (unsafeCoerceF (pure f) ) unsafeCoerceVal)
125
+ -- | Add a layer .
126
+ wrap :: forall f a . f ( Free f a ) - > Free f a
127
+ wrap f = fromView (Bind (unsafeCoerceF f ) unsafeCoerceVal)
127
128
where
128
- unsafeCoerceF :: forall a . f (Free f a ) -> f Val
129
+ unsafeCoerceF :: forall b . f (Free f b ) -> f Val
129
130
unsafeCoerceF = unsafeCoerce
130
131
131
- unsafeCoerceVal :: forall a . Val -> Free f a
132
+ unsafeCoerceVal :: forall b . Val -> Free f b
132
133
unsafeCoerceVal = unsafeCoerce
133
134
135
+ -- | Suspend a value given the applicative functor `f` into the free monad.
136
+ suspendF :: forall f . Applicative f => Free f ~> Free f
137
+ suspendF f = wrap (pure f)
138
+
134
139
-- | Use a natural transformation to change the generating type constructor of a
135
140
-- | free monad.
136
141
hoistFree :: forall f g . (f ~> g ) -> Free f ~> Free g
You can’t perform that action at this time.
0 commit comments