[Haskell-beginners] Unit numeric type pattern

Andres Loeh andres.loeh at googlemail.com
Tue Jun 21 18:38:09 CEST 2011


On Tue, Jun 21, 2011 at 10:38 AM, Christopher Howard
<christopher.howard at frigidcode.com> wrote:
> What is a "unit numeric type pattern", as in the error: "Only unit
> numeric type pattern is valid". I can cause this error by mixing numbers
> into type definitions. And, therefore, I know how to avoid this error.
> But the error indicates that there /is/ such a thing as "valid" "unit
> numeric type pattern", and consequently I am quite curious as to what a
> such a thing is and what it would look like in code.

It's a hack (and I believe one that can soon be deprecated). It allows
the number "1" to be used as a type, which is then interpreted as
being isomorphic to GHC.Generics.Unit. Any other number in a type will
produce the strange error you just mentioned. So this is syntactic
sugar that has been added to support a particular language extension
for generic deriving. I think the new generic deriving mechanism
currently being implemented by Pedro doesn't rely/benefit from nicer
syntax for the unit type. So this could be removed soon, and free up
the syntax for something like type-level naturals.


More information about the Beginners mailing list