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.
Learning Clojure: Clojure is Fast - 0 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...
Arrays - HaskellWiki - 0 views
Smart constructors - HaskellWiki - 0 views
-
The most interesting are probably the static checks that can be done with Type arithmetic, that enforce the number of bands at compile time, rather than runtime, by lifting the band count into the type level.
-
typecheck perform the check statically, using phantom types and Peano numbers.
-
So encode a type-level version of the bounds check. Only resistors with bands >= 4 and <= 8 are valid:
- ...1 more annotation...
Fix Slow Running Computer Now - 0 views
My computer is running so slow so I contact Fix Slow Computers Online. They offer online computer support services to fix slow computers. They have the best computer tech specialists who know how t...
1 - 6 of 6
Showing 20▼ items per page