8 ms·
If you were to act like doubles are (optimized) thunks, would that ever trip you up? Haskell's strictness means that its abstractions don't leak as much. If I'm
by lmkg 15y ago
If you were to act like doubles are (optimized) thunks, would that ever trip you up? Haskell's strictness means that its abstractions don't leak as much. If I'm able to pretend that everything is a function, and doing so won't lead me astray, I don't see the point of caring that some things are really values (for some definition of real). That seems like the sort of detail that Haskell makes a point of protecting you from.
- loup-vaillant 15y agoDon't forget currying. Actually, in Haskell, function have exactly one argument. If you need more, just return a function. -- appears to have 2 arguments foo :: Int -> Int -> Int foo x y = x + (y * y) -- equivalent definition foo :: Int -> (Int -> Int) foo x = \y -> x + (y * y) -- or even more consistently foo :: Int -> (Int -> Int) foo = \x -> (\y -> x + (y * y)) Thinking this way is more useful in the long run: it makes partial application more natural. bar :: Int -> List Int -> List Int Bar = map (foo 42)