
| My mistunderstanding stems from: | | (case undefined of Foo GadtValue -> ()) :: () -- is rigid | | (case undefined of Foo GadtValue -> () :: ()) -- not rigid
No, the former isn't rigid either. BOTH the scrutinee AND the return type must be rigid, and in the former case the scrutinee does not have a rigid type.
But the first compiles fine, so it seems that the scrutinee doesn't have to always be rigid?
| An example in the user manual would be good, but having the compiler | identify where the missing type signature is would be significantly | better (albeit significantly more work). The example that would have | helped me is: | | Given the case expression: | | case scrutinee of | GadtConstructor variable -> result | | The potential type signatures that may be required to ensure rigidity | are: | | (case scrutinee :: t of | GadtConstructor (variable :: t) -> result) :: t
OK. Can you give a sample program and the error message you'd like to see?
Given the program: g = case undefined of Foo GadtValue -> () I get the error message: Test.hs:13:12: GADT pattern match with non-rigid result type `t' Solution: add a type signature In a case alternative: Foo GadtValue -> () In the expression: case undefined of { Foo GadtValue -> () } In the definition of `g': g = case undefined of { Foo GadtValue -> () } Which last week I was reading as "add a type signature to Foo GadtValue -> ()". A better hint would be: Solution: add a type signature, probably at _TYPE_ (case undefined of { Foo GadtValue -> () }) :: _TYPE_
If you can suggest improvements to the manual I'm all ears. Notably, it says nothing about what "rigid" means or how it propagates.
I think the manual should give a conservative approximation of where type signatures should go -- i.e. if you put type signatures in all these places it will work. Details such as what rigid means or propagation rules are too unnecessary. My example in my previous mail would have helped me. Thanks Neil ============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html ==============================================================================