fmr-0.1: Fake monadic records library
Copyright(c) Andrey Mulik 2020
LicenseBSD-style
Maintainerwork.a.mulik@gmail.com
Safe HaskellSafe
LanguageHaskell2010

Data.Field

Description

Data.Field provides fake field type for record-style operations.

Synopsis

Simple field

data SField m record a Source #

Simple field, which contain only getter and setter.

Constructors

SField 

Fields

  • getSField :: !(record -> m a)

    Get field value

  • setSField :: !(record -> a -> m ())

    Set field value

Instances

Instances details
SwitchProp Field record => SwitchProp SField record Source # 
Instance details

Defined in Data.Field

Methods

incRecord :: Monad m => SField m record0 record -> record0 -> m () Source #

decRecord :: Monad m => SField m record0 record -> record0 -> m () Source #

switchRecord :: Monad m => SField m record0 record -> record0 -> Int -> m () Source #

ModifyProp SField record Source # 
Instance details

Defined in Data.Field

Methods

modifyRecord :: Monad m => SField m record a -> record -> (a -> a) -> m a Source #

SetProp SField record Source # 
Instance details

Defined in Data.Field

Methods

setRecord :: Monad m => SField m record a -> record -> a -> m () Source #

GetProp SField record Source # 
Instance details

Defined in Data.Field

Methods

getRecord :: Monad m => SField m record a -> record -> m a Source #

DeleteProp Field record many => DeleteProp SField record many Source # 
Instance details

Defined in Data.Field

Methods

deleteRecord :: (Monad m, Eq a) => a -> SField m record (many a) -> record -> m (many a) Source #

InsertProp Field record many => InsertProp SField record many Source # 
Instance details

Defined in Data.Field

Methods

prependRecord :: Monad m => a -> SField m record (many a) -> record -> m (many a) Source #

appendRecord :: Monad m => a -> SField m record (many a) -> record -> m (many a) Source #

sfield :: Monad m => (record -> m a) -> (record -> a -> m ()) -> Field m record a Source #

Create Field from getter and setter.

Field

data Field m record a Source #

Normal field, which contain getter, setter and modifier.

Constructors

Field 

Fields

  • getField :: !(record -> m a)

    Get field value

  • setField :: !(record -> a -> m ())

    Set field value

  • modifyField :: !(record -> (a -> a) -> m a)

    Modify field value

Instances

Instances details
SwitchProp Field Bool Source # 
Instance details

Defined in Data.Field

Methods

incRecord :: Monad m => Field m record Bool -> record -> m () Source #

decRecord :: Monad m => Field m record Bool -> record -> m () Source #

switchRecord :: Monad m => Field m record Bool -> record -> Int -> m () Source #

Integral switch => SwitchProp Field switch Source # 
Instance details

Defined in Data.Field

Methods

incRecord :: Monad m => Field m record switch -> record -> m () Source #

decRecord :: Monad m => Field m record switch -> record -> m () Source #

switchRecord :: Monad m => Field m record switch -> record -> Int -> m () Source #

ModifyProp Field record Source # 
Instance details

Defined in Data.Field

Methods

modifyRecord :: Monad m => Field m record a -> record -> (a -> a) -> m a Source #

SetProp Field record Source # 
Instance details

Defined in Data.Field

Methods

setRecord :: Monad m => Field m record a -> record -> a -> m () Source #

GetProp Field record Source # 
Instance details

Defined in Data.Field

Methods

getRecord :: Monad m => Field m record a -> record -> m a Source #

DeleteProp Field record [] Source # 
Instance details

Defined in Data.Field

Methods

deleteRecord :: (Monad m, Eq a) => a -> Field m record [a] -> record -> m [a] Source #

InsertProp Field record [] Source # 
Instance details

Defined in Data.Field

Methods

prependRecord :: Monad m => a -> Field m record [a] -> record -> m [a] Source #

appendRecord :: Monad m => a -> Field m record [a] -> record -> m [a] Source #

type OField = Observe Field Source #

Observable Field.

Observable field

data Observe field m record a Source #

Simple field observer, which can run some handlers after each action.

Constructors

Observe 

Fields

Instances

Instances details
SwitchProp field a => SwitchProp (Observe field) a Source # 
Instance details

Defined in Data.Field

Methods

incRecord :: Monad m => Observe field m record a -> record -> m () Source #

decRecord :: Monad m => Observe field m record a -> record -> m () Source #

switchRecord :: Monad m => Observe field m record a -> record -> Int -> m () Source #

ModifyProp field record => ModifyProp (Observe field) record Source # 
Instance details

Defined in Data.Field

Methods

modifyRecord :: Monad m => Observe field m record a -> record -> (a -> a) -> m a Source #

SetProp field record => SetProp (Observe field) record Source # 
Instance details

Defined in Data.Field

Methods

setRecord :: Monad m => Observe field m record a -> record -> a -> m () Source #

GetProp field record => GetProp (Observe field) record Source # 
Instance details

Defined in Data.Field

Methods

getRecord :: Monad m => Observe field m record a -> record -> m a Source #

DeleteProp field record many => DeleteProp (Observe field) record many Source # 
Instance details

Defined in Data.Field

Methods

deleteRecord :: (Monad m, Eq a) => a -> Observe field m record (many a) -> record -> m (many a) Source #

InsertProp field record many => InsertProp (Observe field) record many Source # 
Instance details

Defined in Data.Field

Methods

prependRecord :: Monad m => a -> Observe field m record (many a) -> record -> m (many a) Source #

appendRecord :: Monad m => a -> Observe field m record (many a) -> record -> m (many a) Source #

observe :: Monad m => field m record a -> Observe field m record a Source #

Create field with default observers.