On 13 January 2011 13:03, z_axis <[hidden email]> wrote:
> data Layout a = forall l. (LayoutClass l a, Read (l a)) => Layout (l a)
> readsLayout :: Layout a -> String -> [(Layout a, String)]
> readsLayout (Layout l) s = [(Layout (asTypeOf x l), rs) | (x, rs) <- reads
> Why is the first parameter of readsLayout "(Layout l)" not "Layout (l a)" ?
Look at the data definition: if we replace the constraint with some
"L" type of kind * -> *, we have:
data Layout a = Layout (L a)
Note that the type of the value contained within the actual
constructor is the application of L (originally l) to a. For example,
if L == Maybe, then this could be a value of type "Layout Int" with
the value "Layout (Just 3)".
As such, there is only one actual internal value to pattern match against.