ANNOUNCE: GHC 7.0.1 Release Candidate 1
Antoine Latter
aslatter at gmail.com
Wed Sep 29 22:19:45 EDT 2010
On Wed, Sep 29, 2010 at 9:16 PM, Simon Peyton-Jones
<simonpj at microsoft.com> 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
More information about the Glasgow-haskell-users
mailing list