You can't. A datatype is closed. And it is a good thing otherwise, how can you predict how previsouly defined function will behave?
Several workarounds exist, here are some off the top of my head:
- Use a function as a constructor. e.g.
myExtendedType = MyType 42
; - Use your own type and a mapping function. e.g.
data MyExtendedType = MyExtendedType; toMyType MyExtendedType = MyType 42
; Wrap the existing datatype:
import MyModule as Old data MyExtendedType = FromOld (MyType Int) | MyExtendedType foo (FromOld m) = Old.foo m foo MyExtendedType = undefined