pepeiborra / control-monad-free Goto Github PK
View Code? Open in Web Editor NEWFree monads and monad transformers
Free monads and monad transformers
I came across this sentence in a paper (IR for the Masses):
"Thus a reflection ρ : F I O → M I → M O is a natural transformation from the functor F I to the monad M I → M− and as such induces a monad morphism from the free monad on F I to this monad."
This suggests the following function:
induce :: (Functor f, Monad m) => (forall a. f a -> m a) -> Free f a -> m a
induce f = foldFree return (join . f)
(induce is probably not the best name for this function.)
mapFree can be written with induce:
mapFree eta = induce (Impure . fmap Pure . eta)
but that's slower than the current implementation, unless GHC can optimize the overhead away.
Control/Monad/Free/Zip.hs:24:27: error:
• Could not deduce (Control.Monad.Fail.MonadFail m)
arising from a do statement
with the failable pattern ‘(x : xx)’
from the context: (Traversable t1, Traversable t2, Monad m)
bound by the type signature for:
unsafeZipWithG :: forall (t1 :: * -> *) (t2 :: * -> *) (m :: *
-> *) a b c.
(Traversable t1, Traversable t2, Monad m) =>
(a -> b -> m c) -> t1 a -> t2 b -> m (t2 c)
at Control/Monad/Free/Zip.hs:22:1-106
Possible fix:
add (Control.Monad.Fail.MonadFail m) to the context of
the type signature for:
unsafeZipWithG :: forall (t1 :: * -> *) (t2 :: * -> *) (m :: *
-> *) a b c.
(Traversable t1, Traversable t2, Monad m) =>
(a -> b -> m c) -> t1 a -> t2 b -> m (t2 c)
• In a stmt of a 'do' block: (x : xx) <- get
In the expression:
do (x : xx) <- get
put xx
lift (f x y)
In an equation for ‘zipG'’:
zipG' y
= do (x : xx) <- get
put xx
lift (f x y)
|
24 | where zipG' y = do (x:xx) <- get
| ^^^^^^^^^^^^^
Hi, I'm trying to compile hledger
with the current GHC 7.10.1 release candidate, but I've run into trouble with control-monad-free
because of the issues indicated by the following GHC 7.8.4 warnings:
Control/Monad/Free.hs:58:10: Warning:
‘Free’ is an instance of Monad but not Applicative - this will become an error in GHC 7.10, under the Applicative-Monad Proposal.
Control/Monad/Free.hs:111:10: Warning:
‘FreeT’ is an instance of Monad but not Applicative - this will become an error in GHC 7.10, under the Applicative-Monad Proposal.
[2 of 3] Compiling Control.Monad.Free.Zip ( Control/Monad/Free/Zip.hs, dist/build/Control/Monad/Free/Zip.o )
[3 of 3] Compiling Control.Monad.Free.Improve ( Control/Monad/Free/Improve.hs, dist/build/Control/Monad/Free/Improve.o )
Control/Monad/Free/Improve.hs:36:10: Warning:
‘C’ is an instance of Monad but not Applicative - this will become an error in GHC 7.10, under the Applicative-Monad Proposal.
Control/Monad/Free/Improve.hs:44:10: Warning:
‘C’ is an instance of MonadPlus but not Alternative - this will become an error in GHC 7.10, under the Applicative-Monad Proposal.
Would it be possible to get an updated version of your package that remedies these issues?
The compiler complains:
Control/Monad/Free.hs:45:67:
Can't make a derived instance of `Typeable (Free f a)':
`Free' must only have arguments of kind `*'
In the data declaration for `Free'
A complete build log is at http://hydra.cryp.to/build/520220/nixlog/2/raw.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.