[Haskell-cafe] learning advanced haskell
Ivan Lazar Miljenovic
ivan.miljenovic at gmail.com
Mon Jun 14 09:56:54 EDT 2010
Martijn van Steenbergen <martijn at van.steenbergen.nl> writes:
>
> 1) What's a type of this function? I say *a* type because there are
> multiple correct answers.
>
>> debugWith f = do
>> putStrLn (f True)
>> putStrLn (f 'c')
>
> Don't ask the compiler to infer the type for you; it won't be able
> to. One of the characteristics of RankNTypes is that the compiler
> needs you, the programmer, to supply the type.
I randomly guess something like "(forall a. a -> String) -> IO ()" (but
haven't done anything myself with existentials so I'm quite possibly
wrong).
> 2) What would be a good argument to debugWith?
Does "show" suffice?
> 3) What's one reason the compiler can't infer the type for you?
foralls are tricksy little devils? :p
--
Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com
IvanMiljenovic.wordpress.com
More information about the Haskell-Cafe
mailing list