data-extend-generic-0.1.0.0: Extend Haskell data or newtype like in OOP languages

Safe HaskellSafe
LanguageHaskell2010

Data.Extend.Internal

Documentation

class GExtend a where Source #

Minimal complete definition

gExtend

Methods

gExtend :: a p -> a p -> a p Source #

Instances

GExtend U1 Source # 

Methods

gExtend :: U1 p -> U1 p -> U1 p Source #

Extend a => GExtend (K1 i a) Source # 

Methods

gExtend :: K1 i a p -> K1 i a p -> K1 i a p Source #

(GExtend a, GExtend b) => GExtend ((:+:) a b) Source # 

Methods

gExtend :: (a :+: b) p -> (a :+: b) p -> (a :+: b) p Source #

(GExtend (K1 i (m a)), Alternative m, GExtend b) => GExtend ((:*:) (K1 i (m a)) b) Source # 

Methods

gExtend :: (K1 i (m a) :*: b) p -> (K1 i (m a) :*: b) p -> (K1 i (m a) :*: b) p Source #

(GExtend a, GExtend b) => GExtend ((:*:) a b) Source # 

Methods

gExtend :: (a :*: b) p -> (a :*: b) p -> (a :*: b) p Source #

GExtend a => GExtend (M1 i c a) Source # 

Methods

gExtend :: M1 i c a p -> M1 i c a p -> M1 i c a p Source #

class Extend a where Source #

Methods

extend :: a -> a -> a Source #

By default

a `extend` b = a
Nothing `extend` Just a = Just a

To use the Extend class, simply make your data derive Generic.

If "a" is a user defined data type, then all Nothing fields of "a" are replaced by corresponding fields in "b",

ie, all Just fields in "a" will override corresponding fields in "b".

extend :: (Generic a, GExtend (Rep a)) => a -> a -> a Source #

By default

a `extend` b = a
Nothing `extend` Just a = Just a

To use the Extend class, simply make your data derive Generic.

If "a" is a user defined data type, then all Nothing fields of "a" are replaced by corresponding fields in "b",

ie, all Just fields in "a" will override corresponding fields in "b".

Instances

Extend a Source # 

Methods

extend :: a -> a -> a Source #

Extend a => Extend (Maybe a) Source # 

Methods

extend :: Maybe a -> Maybe a -> Maybe a Source #