The Writer MonadYou can think of monoids as being accumulators. Given a running total, n, we can add in a new value a to get a new running total n' = n `mappend` a. Accumulating totals is a very common design pattern in real code so it's useful to abstract this idea. This is exactly what the Writer monad allows. We can write monadic code that accumulates values as a "side effect". The function to perform the accumulation is (somewhat confusingly) called tell. Here's an example where we're logging a trace of what we're doing.
The Theory of Concatenative Combinators - 1 views
A Neighborhood of Infinity: Haskell Monoids and their Uses - 0 views
-
-
This is an implementation of the factorial function that tells us what it did.
-
We use runWriter to extract the results back out. If we run> ex1 = runWriter (fact1 10)we get back both 10! and a list of what it took to compute this.
- ...6 more annotations...
Parsec - 2 views
Monads as containers - HaskellWiki - 0 views
-
A monad is a container type together with a few methods defined on it.
-
all the elements which a monadic container holds at any one time must be the same type (it is homogeneous).
-
map (fmap), return and join,
- ...15 more annotations...
What is (functional) reactive programming? - Stack Overflow - 0 views
-
Semantically, FRP's concurrency is fine-grained, determinate, and continuous.
-
Dynamic/evolving values (i.e., values "over time") are first class values in themselves. You can define them and combine them, pass them into & out of functions. I called these things "behaviors".
-
Each occurrence has an associated time and value.
- ...3 more annotations...
Pointfree - HaskellWiki - 0 views
1 - 7 of 7
Showing 20▼ items per page