A History of Haskell - 0 views
A Neighborhood of Infinity: Haskell Monoids and their Uses - 0 views
-
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.
-
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...
Programacion Web con Haskell - 0 views
Learning Haskell Notes - 0 views
-
8. Functors
-
A "functor" is a structured collection (or container) type with a method (fmap) that accepts a method and applies that method to the members of the collection yielding an isomorphic collection of values of a (possibly) new type. Is this right?
-
Every monad is a functor, but not the other way around; a monad is a functor PLUS functions >>= and return satisfying some laws
- ...4 more annotations...
Haskell Platform Download (Beta) - 0 views
From Javascript To Haskell - 0 views
A Gentle Introduction to Haskell: Arrays - 0 views
Fatvat: Generating Text in Haskell - 0 views
Haskell-mode for Emacs - 0 views
The Haskell 98 Library Report: Arrays - 0 views
-
16.2 Incremental Array Updates The operator (//) takes an array and a list of pairs and returns an array identical to the left argument except that it has been updated by the associations in the right argument. (As with the array function, the indices in the association list must be unique for the updated elements to be defined.) For example, if m is a 1-origin, n by n matrix, then m//[((i,i), 0) | i <- [1..n]] is the same matrix, except with the diagonal zeroed.
-
-- A rectangular subarray subArray :: (Ix a) => (a,a) -> Array a b -> Array a b subArray bnds = ixmap bnds (\i->i) -- A row of a matrix row :: (Ix a, Ix b) => a -> Array (a,b) c -> Array b c row i x = ixmap (l',u') (\j->(i,j)) x where ((_,l'),(_,u')) = bounds x -- Diagonal of a matrix (assumed to be square) diag :: (Ix a) => Array (a,a) b -> Array a b diag x = ixmap (l,u) (\i->(i,i)) x where ((l,_),(u,_)) = bounds x -- Projection of first components of an array of pairs firstArray :: (Ix a) => Array a (b,c) -> Array a b firstArray = fmap (\(x,y)->x)
The Haskell 98 Language Report - 0 views
Haskell Hierarchical Libraries - 0 views
« First
‹ Previous
41 - 60 of 157
Next ›
Last »
Showing 20▼ items per page