Transform a data type into a new type


Identity: Newtype
Category: Data MultiModule
Classifiers: constructor definition
Internal cross references:
External cross references:
Language: Haskell


data Expr = Var Int
  

newtype Expr = Var Int  

  

General comment:

A newtype differs from a type synonym in that it creates a distinct type that must be explicitly coerced to or from the original type, this can improve the general efficiency of a large program with lot's of recursion over a particular simple data type.

Left to right comment:

A selected data type with a unary constructor is converted to a new type.

Right to left comment:

A selected newtype is converted to a data type with a unary constructor.

Left to right conditions:

The selected data type must have one unary constructor.


Right to left conditions:

None.

Analysis required: None.