News for hackers. Stuff that matters.
Re:Implement with Types, Not Your Brain by wellpast on Tuesday June 25, 2019 @07:46PM (#20280460)
f(+’,1,2) = “cookie”

For one.

Now tell me: are types the best documentation?

Re:Implement with Types, Not Your Brain by TheAsprngHacker on Tuesday June 25, 2019 @08:01PM (#20280572)
Maybe I'm misunderstanding what you're saying, but how on Earth would a function

    f :: (a -> b -> c) -> b -> a -> c
result in

    f (+) 1 2
evaluating to

    "cookie"
? For one, the types (obviously, to me at least) don't work out.
Re:Implement with Types, Not Your Brain by wellpast on Tuesday June 25, 2019 @09:11PM (#20280993)
Sounds like you could use some real documentation.
Re:Implement with Types, Not Your Brain by dllthomas on Tuesday June 25, 2019 @10:25PM (#20281345)
The types tell me that that's not the function in question. Type variables in Haskell mean the caller of the function gets to pick the types. That means the implementation doesn't get to - and the compiler makes sure of it.

You're pattern matching on a number and returning a string. The function might be handed a function and expected to return a file handle for all you know from inside the function.

Re:Implement with Types, Not Your Brain by nilkn on Wednesday June 26, 2019 @12:44AM (#20282000)
a, b, and c are generic types. You need to supply an implementation of f that doesn't know anything about a, b, or c. How many such implementations are there? Can you supply at least two, both of which finish running in a finite amount of time and neither of which produces any error?