Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Event o (s :: Nat)
- = EventDecrement Date o (UnsignedQuantity s)
- | EventIncrement Date o (UnsignedQuantity s)
- eventDate :: KnownNat s => Event o s -> Date
- eventObject :: KnownNat s => Event o s -> o
- negateEvent :: KnownNat s => Event o s -> Event o s
- mkEvent :: (MonadError String m, KnownNat s) => Date -> o -> Quantity s -> m (Event o s)
Documentation
data Event o (s :: Nat) Source #
Encoding of an increment/decrement event.
>>>
:set -XDataKinds
>>>
import Refined
>>>
let date = read "2021-01-01"
>>>
let oid = 1 :: Int
>>>
let qty = $$(refineTH 42) :: UnsignedQuantity 2
>>>
let event = EventDecrement date oid qty
>>>
let json = Aeson.encode event
>>>
json
"{\"qty\":42.0,\"obj\":1,\"date\":\"2021-01-01\",\"type\":\"DECREMENT\"}">>>
Aeson.decode json :: Maybe (Event Int 2)
Just (EventDecrement 2021-01-01 1 (Refined 42.00))>>>
Aeson.decode json == Just event
True
EventDecrement Date o (UnsignedQuantity s) | |
EventIncrement Date o (UnsignedQuantity s) |
Instances
eventObject :: KnownNat s => Event o s -> o Source #