2012/2/25 Andres Löh <andres.l...@googlemail.com>

> > Would you have an example of a type for which it would be useful to have
> > a DeepSeq instance, and that would require a V1 instance? I cannot think
> > of one now; I originaly thought it would be necessary to permit deriving
> > DeepSeq instances for types tagged with "void" types, but as José
> > explained, in that case, the V1 instance isn't needed because those void
> > types don't show up in the representation.
>
> While void datatypes are rare, it just doesn't make sense to exclude
> them. It's an arbitrary restriction. Here's a constructed example:
>
> data X a = C1 Int | C2 a
> data Z -- empty
>
> type Example = X Z
>
> We're using Z as a parameter to X in order to exclude the use of the
> C2 case. Without a V1 case, you cannot use deepSeq on values of type
> Example.
>

Yes, I agree. There should be a V1 instance, and it should return
`undefined`. This gives the expected behavior of `seq` on an empty
datatype, I think. If there is no V1 instance, you'll get a type-checking
error (no instance for V1), preventing generic deepseq on any datatype that
happens to use an empty datatype in its definition.


Cheers,
Pedro
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to