Comments (2)
From what I learned in #14, I thought that it would be possible to also write the functions
mapProgramT :: (forall a. instr1 a -> instr2 a) -> ProgramT instr1 m b -> ProgramT instr2 m b
hoistProgramT :: (forall b. m b -> n b) -> ProgramT instr m a -> ProgramT instr n b
without pattern matching on ProgramT
. However, I still cannot find a way to write mapProgramT
with pattern matching, so I think that this PR is still relevant.
from operational.
The same ideas from #14 can be used to write mapProgramT
. Here is one way to do it:
mapProgramT :: Monad m => (forall a. instr1 a -> instr2 a)
-> ProgramT instr1 m b -> ProgramT instr2 m b
mapProgramT f p = do
v <- lift $ viewT p
case v of
Return a -> return a
i :>>= k -> singleton (f i) >>= mapProgramT f . k
If I were to export the constructors, then this would kind of the defeat the purpose of the library. (Though I'm willing to compromise for the sake of efficiency). Relying on viewT
only makes sure that the monad laws and the lifting laws are always satisfied. In contrast, having access to the internal constructors risks breaking these laws.
from operational.
Related Issues (17)
- MonadProgram typeclass for nicer transformer stacks HOT 2
- helper function interpretWithMonadT HOT 4
- Need ProgramT constructors to write other lifting instances HOT 9
- Pattern Synonyms for `Return` and `:>>=` HOT 7
- ProgramT and ProgramViewT are not really GADTs HOT 1
- Package documentation not as approachable as it maybe could be HOT 5
- Issues with `.cabal` file HOT 2
- Add interpretWithMonadT HOT 1
- Does not build with stackage nightly-2021-06-21 (ghc-9.0.1) HOT 1
- Hackage release with 9.0.1 support HOT 3
- PoorMansConcurrency Example doesn't compile HOT 2
- 0.2.4.0 fails to build with GHC-7.8 and older HOT 3
- Compatibility with mtl-2.3 HOT 2
- Add evalRandTIO HOT 3
- Broken links in documentation HOT 1
- MonadTransControl or MonadBaseControl instances HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from operational.