fails to load because of "Ambiguous occurence" of map
(even (double 7))
does not work (maybe because "double" is undefined?)
not :: Bool -> Bool
should probably be a comment?
Then there is some stuff where I don't even have a clue what's wrong.
How to write functions is mentioned at the end instead of at the occurence of the first function.
The book linked at the bottom of the page seems to be good so far (and I should rather have read that instead of messing with this code).
absolutely no mention of lazy evaluation
absolutely no mention of purity
an if construct is not a control flow statement, but an expression, and indentation does not matter at all (except for the general layout rules and do blocks)
the fib function is horribly inefficient and a bad example
no mention of the fact that functions are always fully curried (i.e., a function never takes more than one argument; if you need more, you return another function)
no explanation of type inference and how it causes types and type constraints to "bubble up" in the call hierarchy
strings cannot be "added" in Haskell (unless you import Acme.PHP); they can be concatenated
strings cannot be "treated like lists of characters": they are lists of characters (which is also why you'd typically use Texts instead in most cases)
the reason Haskell doesn't have loops is not "because it uses recursion instead", but because it is pure, and for an imperative free-form loop, you need mutable state;
Haskell does have more specialized "looping" constructs, including map, repeat and replicate for pure constructs, their monadic counterparts mapM, replicateM, repeatM and their xxx_ brethren, and things like forever; implementing monadic for and while loops is pretty easy, e.g.:
while :: Monad m => m Bool -> m () -> m () while condition action = do v <- condition if v then (action >> while condition action) else return () -- using in, for example, IO: exitCond <- newIORef False while (readIORef exitCond) $ do ln <- getLine case ln of "" -> writeIORef exitCond True "foo" -> putStrLn "You said 'foo'!" "bar" -> putStrLn "So a foo walks into a bar..." x -> putStrLn ("Hmm, I don't think I know what '" ++ x ++ "' means...")
You can actually use it in any monad, but it makes the most sense in -- "stateful" monads like IO, ST, State, and the like.
From reddit (http://www.reddit.com/r/programming/comments/1h917l/learn_x_in_y_minutes/casl5so?context=1)
""" There seems to be one for haskell now http://learnxinyminutes.com/docs/haskell/ which I am reading.
gives 5 instead of 4
fails to load because of "Ambiguous occurence" of map
does not work (maybe because "double" is undefined?)
should probably be a comment?
Then there is some stuff where I don't even have a clue what's wrong.
How to write functions is mentioned at the end instead of at the occurence of the first function.
The book linked at the bottom of the page seems to be good so far (and I should rather have read that instead of messing with this code).
Haskell does have more specialized "looping" constructs, including map, repeat and replicate for pure constructs, their monadic counterparts mapM, replicateM, repeatM and their xxx_ brethren, and things like forever; implementing monadic for and while loops is pretty easy, e.g.:
You can actually use it in any monad, but it makes the most sense in -- "stateful" monads like IO, ST, State, and the like.