[Haskell-cafe] Hoogle? [Stacking monads]

Reiner Pope reiner.pope at gmail.com
Wed Oct 8 19:35:12 EDT 2008


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).

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

Reiner



On Thu, Oct 9, 2008 at 6:11 AM, Andrew Coppin
<andrewcoppin at btinternet.com>wrote:

> Ryan Ingram wrote:
>
>>
>>
>> There is such a tool, it's called ghci :)
>> It just takes a bit of massaging to do what you want:
>>
>> ghci> :set -fglasgow-exts
>> ghci> :t (?f some_func [?a .. ?b])
>>
>> Here's an example:
>> Prelude> :t ?f map [?a .. ?b]
>> ?f map [?a .. ?b] :: forall t a b t1.
>>                     (Enum t1,
>>                    ?b::t1,
>>                    ?a::t1,
>>                    ?f::((a -> b) -> [a] -> [b]) -> [t1] -> t)
>>         => t
>>
>> This tells you the types the variables have to have, and the type of
>> the expression.
>>
>> Judicious use of (undefined :: type_signature) can also help.
>>
>>
>
> Using undefined is already a standard technique for me. But what it doesn't
> let you do is
>
>  foo (undefined :: Bar x) (undefined) :: Bar y   -- What type is the second
> argument?
>
> I'm curios as to how the example you give actually works - I don't
> recognise that syntax at all...
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081009/8d84d050/attachment.htm


More information about the Haskell-Cafe mailing list