3 ms·
Are you saying it's weird that a function has an explicit type in Haskell? ("First-class" functions) https://en.m.wikipedia.org/wiki/First-class_function http
by hgsgm 4y ago
Are you saying it's weird that a function has an explicit type in Haskell? ("First-class" functions)
https://en.m.wikipedia.org/wiki/First-class_function https://en.m.wikipedia.org/wiki/First-class_function
- mrkeen 4y agoYou can read those lower case letters as preceded by "for all", and it's up to the caller to choose which concrete type the letter should represent, as the function promises to return an implementation "for all" concrete types. So if wrote the function foo, foo :: Int -> b and you happened to need a BufferedReader, you could just get it by calling (foo 3). That's what the "thin air" comment is. Where could the implementation of BufferedReader possibly have come from?
- gowld 4y agoThat's impossible, but that's not what's happening here. There is no "-> b" at the end of the type signature upthread. The example in the thread is more like foo :: Either (b -> Int) b which is much easier: foo = Left (const 1) :: Either (b -> Int) b