31 lines
528 B
Haskell
31 lines
528 B
Haskell
|
{-# LANGUAGE DeriveGeneric #-}
|
||
|
|
||
|
module Types.Purchase where
|
||
|
|
||
|
import Data.Text
|
||
|
|
||
|
import GHC.Generics
|
||
|
|
||
|
|
||
|
data PurchaseDetail = PurchaseDetail
|
||
|
{ pdBeverage :: Int
|
||
|
, pdAmount :: Int
|
||
|
}
|
||
|
|
||
|
instance ToJSON PurchaseDetail where
|
||
|
toEncoding = genericToEncoding defaultOptions
|
||
|
|
||
|
instance fromJSON PurchaseDetail
|
||
|
|
||
|
|
||
|
data PurchaseResult
|
||
|
= PurchaseOK
|
||
|
| PurchaseDebtful
|
||
|
| PayAmount Int
|
||
|
deriving (Generic, Show)
|
||
|
|
||
|
instance ToJSON PurchaseResult where
|
||
|
toEncoding = genericToEncoding defaultOptions
|
||
|
|
||
|
instance fromJSON PurchaseResult
|