The lecture videos are short, about 10mins each, and Professor Grossman explains the concepts carefully and succinctly, within a fixed teaching framework so you have a predictable learning experience with each concept. It's by far the best way to get into the mindset of typed FP.
I highly recommend spending a little time trying to understand the basics. You might find “Functors, Applicatives, and Monads in Pictures” helpful: http://adit.io/posts/2013-04-17-functors,_applicatives,_and_...
Type classes, functors, and monads are assumed knowledge in most documentation, as they are foundational concepts in Haskell. Just like math, you must know addition, subtraction, multiplication when learning algebra.
If those deal with composition and variable scoping in an intuitive way it's a monad. This "intuitive way" is equivalent to changing block scoping in imperative languages.
{
let x = foo()
let y = bar(x)
let z = baz(x,y)
...
}
should stay equivalent to {
let x = foo()
let z
{
let y = bar(x)
z = baz(x,y)
}
...
}
and you should be able to add empty scopes without changing anything so {
foo()
}
should still equal {
{}
foo()
{}
}
And that's the entire definition of monads. The abstract monad interface is useful to let users define new interpretations for the syntax sugar but not necessary when getting started with haskell - you will pick up intuitions while using it.Generalizations are notoriously hard to describe as they become more general. Better to understand where and when to use those patterns over being able to write a blog post about what a monad is.
spent hours figuring out how to debug-print a value from a pure function and still haven't gotten there
import Debug.Trace
myPureThing :: Bool -> Int
myPureThing b = if b
then traceShow "yay True" 42
else traceShow "oh noes False" 13
… λ> myPureThing True
"yay True"
42
λ> myPureThing False
"oh noes False"
13
I don't know if they're good for others, but I read Real World Haskell[1] and Learn You a Haskell[2]. There's also Graham Hutton's book which people like and which is free to read this month or something[3].[1] http://book.realworldhaskell.org/ – see also the in-progress updated version at https://github.com/tssm/up-to-date-real-world-haskell
[2] http://learnyouahaskell.com/
[3] https://www.cambridge.org/core/books/programming-in-haskell/...
while still having it return the original value
EDIT per comment below, I totally misread this! yes exactly, traceShow ftw
You saved me another N hours
What method did you try to figure it out?
If I google "haskell debug print pure function", the first three results I get are:
* https://hackage.haskell.org/package/base-4.12.0.0/docs/Debug...
* https://stackoverflow.com/questions/13265783/trace-output-in...
* https://en.wikibooks.org/wiki/Haskell/Debugging
and they all have easy, one-line, correct examples of how to do it, within the first 20 seconds of reading.
(This is not to criticise -- sometimes one misses the forest for the trees -- as a professional Haskell consultant who runs trainings I am genuinely interested into what problems people face and why.)
shrug
there's always an adjustment process when learning something new
A lot of the fancy abstractions don't make sense until you have a problem where you'll actually need them. Artificial problems, like some algorithmic assignments in books just don't click nearly as well to many of us.
Also, (Glasgow) Haskell has ghci, a rather nice REPL. You only need to learn to use :{ ... :} for multiline stuff. It's very good for quick experimentation with zero build time.
The EC2 instance was on continuously, and I would ssh+tmux in. You could probably replace this with a server plugged in under your desk, depending on how much you trade off operational costs and capital costs.
More often than not I wanted passing tests to send something for review. If I needed an artifact, I would publish a docket image on an internal registry.
the docs have a specific tone or pattern that's everywhere (and by docs I mean everything -- library readmes, examples, language intros, and stackoverflow posts)
they all read like 'well, you probably haven't been introduced to monads yet. I can't answer your question directly in a short post (these posts are all like 6 paragraphs, nothing short about them), but I'll tell you why you can't do what you're trying to do and I'll also explain why I can't tell you what a monad is'
also my laptop battery keeps dying because the builds are so expensive