[Haskell-cafe] Hoogle? [Stacking monads]

Ryan Ingram ryani.spam at gmail.com
Thu Oct 9 04:20:28 EDT 2008


2008/10/9 Reiner Pope <reiner.pope at gmail.com>:
> The syntax is for the implicit parameter extension[1]. I think you would
> write your example as
>
> foo (undefined :: Bar x) ?z :: Bar y
>
> Then querying the type of that whole expression with :t will list ?z's type
> in the expression's constraints. (Of course, you should turn off the
> monomorphism restriction so that ghc doesn't complain if constraints aren't
> resolved).

Oh yeah, I forgot about that.
ghci> :set -fno-monomorphism-restriction

Although I don't know if that affects the results of the :t command.

> [1]:
> http://www.haskell.org/ghc/docs/latest/html/users_guide/other-type-extensions.html#implicit-parameters
>
> Reiner

There's also a haskell98 way to do the same thing, it's just a bit
more wordy at the ghci prompt, and a bit more work to decode the
result:

ghci> :t \z -> (foo (undefined :: Bar x) z :: Bar y)

Now, the type of this expression is clearly

  type of z -> Bar y

So just read the value before the arrow to get your answer.

  -- ryan


More information about the Haskell-Cafe mailing list