GADT Type Checking GHC 6.10 versus older GHC

Simon Peyton-Jones simonpj at microsoft.com
Fri Nov 28 04:19:19 EST 2008


| > arbitrarySeq :: Sequence a -> Gen RepSeqVal
| > arbitrarySeq Nil =
| >    return (RepSeqVal Nil Empty)
| > arbitrarySeq (Cons (CTMandatory (NamedType n i t)) ts) =
| >    do u <- arbitraryType t
| >       us <- arbitrarySeq ts
| >       case u of
| >          RepTypeVal a v ->
| >             case us of
| >                RepSeqVal bs vs ->
| >                   return (RepSeqVal (Cons (CTMandatory (NamedType n i a)) bs) (v:*:vs))
|
|
| > QuickTest.lhs:240:13:
| >     GADT pattern match in non-rigid context for `Nil'
| >       Solution: add a type signature
| >     In the pattern: Nil
| >     In the definition of `arbitrarySeq':
| >         arbitrarySeq Nil = return (RepSeqVal Nil Empty)

That looks odd to me.  But it's hard to help without having the code. If you send it I'll try to help.

| > Did you try giving a type signature to the (entire) case expression,
| > as I suggested?  That should do it.
| >
|
| I'm not sure what this means or how to do it. Can you give an example or
| is it buried in some earlier email? I will go and have another look.

I mean replace
        (case blah of { ... })
by
        (case blah of { ... }) :: type-sig

That is, attach a type signature to the case expression itself.  Does that help at least explain what the sentence means? If so would you like to clarify the wiki advice?

Thanks

Simon


More information about the Glasgow-haskell-users mailing list