prairie-0.0.4.0: A first class record field library
Safe HaskellSafe-Inferred
LanguageHaskell2010

Prairie.Update

Description

This cl

Since: 0.0.1.0

Synopsis

Documentation

data Update rec where Source #

An operation representing an update against the rec in question.

This type is partially an example - you may want to have a more sophisticated update type than merely setting fields.

Since: 0.0.1.0

Constructors

SetField :: Field rec a -> a -> Update rec 

Instances

Instances details
(FieldDict FromJSON rec, FieldDict (Typeable :: Type -> Constraint) rec, FromJSON (SomeField rec)) => FromJSON (Update rec) Source #

Parses an Update with the following format:

{
    "field": field,
    "value": newValue
}

Since: 0.0.1.0

Instance details

Defined in Prairie.Update

(FieldDict ToJSON rec, forall a. ToJSON (Field rec a)) => ToJSON (Update rec) Source #

Renders an Update in the following format:

{
   "field": toJSON field,
   "value": toJSON newValue

}

Since: 0.0.1.0

Instance details

Defined in Prairie.Update

Methods

toJSON :: Update rec -> Value #

toEncoding :: Update rec -> Encoding #

toJSONList :: [Update rec] -> Value #

toEncodingList :: [Update rec] -> Encoding #

omitField :: Update rec -> Bool #

(forall a. Show (Field rec a), FieldDict Show rec) => Show (Update rec) Source #

Since: 0.0.1.0

Instance details

Defined in Prairie.Update

Methods

showsPrec :: Int -> Update rec -> ShowS #

show :: Update rec -> String #

showList :: [Update rec] -> ShowS #

(forall a. Eq (Field rec a), FieldDict (Typeable :: Type -> Constraint) rec, FieldDict Eq rec) => Eq (Update rec) Source #

Since: 0.0.1.0

Instance details

Defined in Prairie.Update

Methods

(==) :: Update rec -> Update rec -> Bool #

(/=) :: Update rec -> Update rec -> Bool #

updateSingleField :: Record rec => Update rec -> rec -> rec Source #

Run an Update against the record it is for.

>>> let user = User { name = "Bob", age = 30 }
>>> updateSingleField (SetField UserName Alice) user
User { name = "Alice", age = 30 }

Since: 0.0.1.0

updateRecord :: Record rec => [Update rec] -> rec -> rec Source #

Perform an list of updates against the Record.

Since: 0.0.1.0