module Handler.Common.Types where import Import import Control.Lens data InventoryState = InventoryState { stock :: [WithType (Entity Item)] , invFormState :: Maybe (FormState ItemId) } data ReferenceState = ReferenceState { reference :: [WithType (Entity Reference)] , refFormState :: Maybe (FormState ReferenceId) } class HasFormState a where type family UpdateId a :: * formState :: a -> Maybe (FormState (UpdateId a)) instance HasFormState InventoryState where type UpdateId InventoryState = ItemId formState = invFormState instance HasFormState ReferenceState where type UpdateId ReferenceState = ReferenceId formState = refFormState data FormState id = InsertForm { fsInsertForm :: Widget , fsInsertEncoding :: Enctype } | UpdateForm { fsUpdateId :: id , fsUpdateForm :: Widget , fsUpdateEncoding :: Enctype } makeLensesWith abbreviatedFields ''FormState