5 ms·
f(+’,1,2) = “cookie” For one. Now tell me: are types the best documentation?
by wellpast 7y ago
f(+’,1,2) = “cookie”
For one.
Now tell me: are types the best documentation?
- TheAsprngHacker 7y agoMaybe 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.
- wellpast 7y agoSounds like you could use some real documentation.
- deleted 7y ago[deleted]
- dllthomas 7y agoThe 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.
- nilkn 7y agoa, 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?