On Wed, Sep 29, 2010 at 9:16 PM, Simon Peyton-Jones
<[email protected]> wrote:
>
> |  Except I don't know how to write a type signature for this.
> |
> |  The value 's' passed in is bound by pattern matching on this guy's 
> constructor:
> |
> |  data Stream a = forall s. Stream (s -> Step s a) !s Int
> |
> |  in the top-level function, so I don't even know if it has a type I can 
> name.
>
> You can bind the type variable using a pattern type signature
>
>        case x of
>             Stream fun (state :: s) n -> ...
>
> This should bind the type variable 's'.
>

That's the part I'd been missing - I had always thought about
type-signatures in patterns as declarations, not about binding a type
to a symbol. But that's what the LHS of a match is for, after all.

I had been trying all kinds of crazy things.

Antoine
_______________________________________________
Glasgow-haskell-users mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Reply via email to