packages feed

keiro-dsl-0.2.0.0: test/conformance-skeletons/SkelAggregate/Generated/MyService/Thing/Domain.hs

{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -Wno-unused-top-binds #-}

-- @generated by keiro-dsl; do not edit. Regenerated from the .keiro spec.
module SkelAggregate.Generated.MyService.Thing.Domain where

import Data.Proxy (Proxy (..))
import Data.Text (Text)
import GHC.Generics (Generic)
import Keiki.Core (RegFile (..))
import Keiki.Generics.TH (deriveAggregateCtorsAll, deriveWireCtorsAll)

newtype ThingId = ThingId Text
    deriving stock (Generic, Eq, Ord, Show)

thingIdText :: ThingId -> Text
thingIdText (ThingId t) = t

data ThingVertex = ThingPending | ThingDone
    deriving stock (Generic, Eq, Ord, Show, Enum, Bounded)

data DoThingData = DoThingData
    { thingId :: !ThingId
    , attempt :: !Int
    }
    deriving stock (Generic, Eq, Show)

data ThingCommand = DoThing !DoThingData
    deriving stock (Generic, Eq, Show)

data ThingCompletedData = ThingCompletedData
    { thingId :: !ThingId
    , attempt :: !Int
    }
    deriving stock (Generic, Eq, Show)

data ThingEvent = ThingCompleted !ThingCompletedData
    deriving stock (Generic, Eq, Show)

type ThingRegs =
    '[ '("thingId", ThingId)
     , '("state", ThingVertex)
     ]

initialThingRegs :: RegFile ThingRegs
initialThingRegs =
    RCons (Proxy @"thingId") (ThingId "") $
        RCons (Proxy @"state") ThingPending RNil

$(deriveAggregateCtorsAll ''ThingCommand ''ThingRegs)

$(deriveWireCtorsAll ''ThingEvent)