Monad Big Stack Example

As the name says, I'm looking for a program that uses monad-transformers in combination with a large Monads stack.

Does anyone know an example of the real world?

+6
source share
2 answers

One of the good examples is Haskeline - its internal type InputCmdT is a monad transformer stack with a depth of 6 (see here ):

 type InputCmdT m = StateT Layout (UndoT (StateT HistLog (ReaderT (IORef KillRing) (ReaderT Prefs (ReaderT (Settings m) m))))) 

It can actually have interesting effects, for example, blowing out a signature of one type in System.Console.Haskeline.Emacs to more than 20,000 lines for at least one version of GHC ...

+8
source

I don’t know if this is considered the “real world”, but in my extension of the tutorial Write a diagram for yourself in 48 hours I have implemented an interpreter for a programming language that uses the following stack:

 type Eval a = ReaderT Environment (ErrorT LispError IO a) 

and I started adding extensions to the language, defining

 type EvalCont ra = ContT r (ReaderT Environment (ErrorT LispError IO a)) 

I have never finished implementing sequels, but you can see how much I got the check on Github .

+5
source

Source: https://habr.com/ru/post/927534/


All Articles