[Haskell-fr] Fw: Éclaircissements sur les monades

Dan Popa popavdan at yahoo.com
Thu Mar 27 05:07:45 UTC 2014


Hi,

Sorry for writing in english, I am not from France.
Take a look here, please:
http://www.haskell.org/haskellwiki/Modular_Monadic_Compilers_for_Programming_Languages

The source  at  #3) on the above page is a code generator written using the State monad.
The state monad is necessary because here it provides a sort of context, like a set of the global variables
in imperative programming.
And that is why we are using The State Monad, to simulate the 

use of a set of global (or local) variables, used to store values. 


Especially in this example, the lenghts of the pieces of generated code are stored in order to compute the length of the biggers codes, when they are catenated, (glued together).

Other monads have specific use. Parser monad is used for glueing parsers, the list monad can simulate paralel computations and even backtracking (there is a backtracking monad too), the Maybe monad is used to make computations including Nothing in the set of values, etc.

Basically monadic capsules can be seen like Christmas Giftts containing compuations. And monadic operators have two kind of use:
- return is a package maker, it creates a capsule, a package, like wrapping a gift
- bind is something like:  how to combine a function with a package. Open the package, compose functions, take care to produce an other package (or capsule).


Hoping it helps,

Sincerely yours,
Dan Popa


----- Forwarded Message -----
From: Gautier DI FOLCO <gautier.difolco at gmail.com>
To: La liste Haskell Francophone <haskell-fr at haskell.org> 
Sent: Wednesday, March 26, 2014 12:10 PM
Subject: [Haskell-fr] Éclaircissements sur les monades
 


Bonjour,

Vaste sujet en perspective : les monades.
Je pense avoir compris le principe des monades (être en mesure d'effectuer des actions sur une valeur au sein d'un contexte), en revanche il y a deux choses que je ne comprends pas :
 * La notion de contexte (ou de cadre de calcul) est un peu floue
 * Pourquoi est-ce que les monades sont aptes à contenir les effets de bords (j'ai lu effectful computations) et pas d'autres typeclass (comme Applicative).

Merci par avance pour vos réponses.

_______________________________________________
Haskell-fr mailing list
Haskell-fr at haskell.org
http://www.haskell.org/mailman/listinfo/haskell-fr
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-fr/attachments/20140326/4ea2cab9/attachment-0001.html>


More information about the Haskell-fr mailing list