Copyright | (c) Andrey Mulik 2020 |
---|---|
License | BSD-style |
Maintainer | work.a.mulik@gmail.com |
Safe Haskell | Safe |
Language | Haskell2010 |
Data.Property
provides property type Prop
for record-style operations.
Synopsis
- data Prop m field record where
- Incr :: (Monad m, SwitchProp field a) => field m record a -> Prop m field record
- Decr :: (Monad m, SwitchProp field a) => field m record a -> Prop m field record
- Switch :: (Monad m, SwitchProp field a) => field m record a -> Int -> Prop m field record
- (:=) :: (Monad m, SetProp field record) => field m record a -> a -> Prop m field record
- (::=) :: (Monad m, SetProp field record) => field m record a -> (record -> a) -> Prop m field record
- (:~) :: (Monad m, ModifyProp field record) => field m record a -> (a -> a) -> Prop m field record
- (::~) :: (Monad m, ModifyProp field record) => field m record a -> (record -> a -> a) -> Prop m field record
- (:=+) :: (Monad m, InsertProp field record many) => field m record (many a) -> a -> Prop m field record
- (:+=) :: (Monad m, InsertProp field record many) => a -> field m record (many a) -> Prop m field record
- (:~=) :: (Monad m, DeleteProp field record many, Eq a) => field m record (many a) -> a -> Prop m field record
- get :: (Monad m, GetProp field record) => field m record a -> record -> m a
- set :: Monad m => record -> [Prop m field record] -> m ()
- setProp :: Monad m => record -> [Prop m field record] -> m ()
- class GetProp field record where
- class SetProp field record where
- class ModifyProp field record where
- modifyRecord :: Monad m => field m record a -> record -> (a -> a) -> m a
- class InsertProp field record many where
- prependRecord :: Monad m => a -> field m record (many a) -> record -> m (many a)
- appendRecord :: Monad m => a -> field m record (many a) -> record -> m (many a)
- class DeleteProp field record many where
- deleteRecord :: (Monad m, Eq a) => a -> field m record (many a) -> record -> m (many a)
- class SwitchProp field a where
Property
data Prop m field record where Source #
Property representation
Incr :: (Monad m, SwitchProp field a) => field m record a -> Prop m field record | Increase property value (switch flag, increment, etc.). |
Decr :: (Monad m, SwitchProp field a) => field m record a -> Prop m field record | Decrease property value (switch flag, decrement, etc.). |
Switch :: (Monad m, SwitchProp field a) => field m record a -> Int -> Prop m field record | Increase/decrease value many times. |
(:=) :: (Monad m, SetProp field record) => field m record a -> a -> Prop m field record |
|
(::=) :: (Monad m, SetProp field record) => field m record a -> (record -> a) -> Prop m field record |
|
(:~) :: (Monad m, ModifyProp field record) => field m record a -> (a -> a) -> Prop m field record |
|
(::~) :: (Monad m, ModifyProp field record) => field m record a -> (record -> a -> a) -> Prop m field record |
|
(:=+) :: (Monad m, InsertProp field record many) => field m record (many a) -> a -> Prop m field record |
|
(:+=) :: (Monad m, InsertProp field record many) => a -> field m record (many a) -> Prop m field record |
|
(:~=) :: (Monad m, DeleteProp field record many, Eq a) => field m record (many a) -> a -> Prop m field record |
|
get :: (Monad m, GetProp field record) => field m record a -> record -> m a Source #
getRecord
shortcut.
setProp :: Monad m => record -> [Prop m field record] -> m () Source #
setRecord record props
changes record
value using props
properties.
Get
class GetProp field record where Source #
Property getter.
getRecord :: Monad m => field m record a -> record -> m a Source #
return getRecord
field recordrecord
's value using field
.
Set
class SetProp field record where Source #
Property setter.
setRecord :: Monad m => field m record a -> record -> a -> m () Source #
sets new setRecord
field record valuerecord
value
.
Modify
class ModifyProp field record where Source #
Property modifier.
Nothing
modifyRecord :: Monad m => field m record a -> record -> (a -> a) -> m a Source #
modifies modifyRecord
field record updrecord
field
using upd
.
Instances
ModifyProp Field record Source # | |
Defined in Data.Field modifyRecord :: Monad m => Field m record a -> record -> (a -> a) -> m a Source # | |
ModifyProp SField record Source # | |
Defined in Data.Field modifyRecord :: Monad m => SField m record a -> record -> (a -> a) -> m a Source # | |
ModifyProp field record => ModifyProp (Observe field) record Source # | |
Defined in Data.Field modifyRecord :: Monad m => Observe field m record a -> record -> (a -> a) -> m a Source # |
class InsertProp field record many where Source #
Prepend/append modifier.
prependRecord :: Monad m => a -> field m record (many a) -> record -> m (many a) Source #
Prepends new element to existing value.
appendRecord :: Monad m => a -> field m record (many a) -> record -> m (many a) Source #
Appends new element to existing value.
Instances
InsertProp Field record [] Source # | |
Defined in Data.Field prependRecord :: Monad m => a -> Field m record [a] -> record -> m [a] Source # appendRecord :: Monad m => a -> Field m record [a] -> record -> m [a] Source # | |
InsertProp Field record many => InsertProp SField record many Source # | |
Defined in Data.Field 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 # | |
InsertProp field record many => InsertProp (Observe field) record many Source # | |
Defined in Data.Field 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 # |
class DeleteProp field record many where Source #
Delete modifier.
deleteRecord :: (Monad m, Eq a) => a -> field m record (many a) -> record -> m (many a) Source #
Delete element from value (if any).
Instances
DeleteProp Field record [] Source # | |
Defined in Data.Field | |
DeleteProp Field record many => DeleteProp SField record many Source # | |
Defined in Data.Field | |
DeleteProp field record many => DeleteProp (Observe field) record many Source # | |
Defined in Data.Field |
class SwitchProp field a where Source #
Switch property modifier.
incRecord :: Monad m => field m record a -> record -> m () Source #
Generalized increment, same as switchRecord
.
decRecord :: Monad m => field m record a -> record -> m () Source #
Generalized decrement.
switchRecord :: Monad m => field m record a -> record -> Int -> m () Source #
Increment/decrement many times.
decRecord field record = switchRecord field record (-1) incRecord field record = switchRecord field record 1
Instances
SwitchProp Field Bool Source # | |
Integral switch => SwitchProp Field switch Source # | |
SwitchProp Field record => SwitchProp SField record Source # | |
SwitchProp field a => SwitchProp (Observe field) a Source # | |