[Haskell-beginners] Doubts about functional programming paradigm
Henk-Jan van Tuyl
hjgtuyl at chello.nl
Sun Dec 13 23:51:11 UTC 2015
On Sat, 12 Dec 2015 01:56:48 +0100, Dimitri DeFigueiredo
<defigueiredo at ucdavis.edu> wrote:
:
> Couldn't match expected type ‘r’ with actual type ‘COParseResult’
> ‘r’ is a rigid type variable bound by
> the type signature for
> getParseResult :: ParseResult r => String -> IO r
> ...
>
> I have a PhD in computer science, but never really liked programming
> languages back then and somehow I never learned what a "rigid type
> variable" is.
See
[Haskell-cafe] What is a rigid type variable?
https://mail.haskell.org/pipermail/haskell-cafe/2008-June/044622.html
:
> But would anyone care to explain to a
> novice in a couple paragraphs why foldl (+) 0 [1..10^9] may take 10 Gigs
> of RAM to calculate?
The foldl builds up a very long expression and evaluates it after the last
element of the list is reached (the evaluation is non-strict, or lazy). If
you use foldl' (from Data.List) instead, the calculation is done per
element (the evaluation is strict).
For more details, see
Foldr Foldl Foldl'
https://wiki.haskell.org/Foldr_Foldl_Foldl'
Lazy vs. non-strict
https://wiki.haskell.org/Lazy_vs._non-strict
Regards,
Henk-Jan van Tuyl
--
Folding at home
What if you could share your unused computer power to help find a cure? In
just 5 minutes you can join the world's biggest networked computer and get
us closer sooner. Watch the video.
http://folding.stanford.edu/
http://Van.Tuyl.eu/
http://members.chello.nl/hjgtuyl/tourdemonad.html
Haskell programming
--
More information about the Beginners
mailing list