Skip to content

Latest commit

 

History

History
28 lines (19 loc) · 1.14 KB

README.md

File metadata and controls

28 lines (19 loc) · 1.14 KB

Newtype, Generic Interface Deriving

This package provides sorely-missed deriving for common interfaces like Num for newtypes and newtype-likes, iow single-constructor types. For instance:

import Generics.Newtype
%language ElabReflection

data Raf = MkRaf Double
%runElab derive "Raf"
  [Generic, Eq, Ord, Num, Neg, Abs, Fractional, FromDouble]

data Raff a b = MkRaff a b
%runElab derive "Raff"
  [Generic, Eq, Ord, Num, Neg, Abs, Fractional, FromDouble, Integral]

Your projects using this lib need to depend on sop and elab-util.

Code here is based on the pristine work done by Stefan Hoeck.

This package could be improved by scanning interfaces and generating the implementations programmaticlly but it does not do so currently and the deriving machinery is instead assembled by hand.

Version

This package follows Haskell PVP which is distinct from SEMVER in that when examining 1.2.3, 1.2 is the Major Version rather than 1.