Skip to content

Modelling sum types #174

Discussion options

You must be logged in to vote

Here's an example of how you could embed that into a Rel8able, which is probably what you want to do:

{-# language DeriveAnyClass #-}
{-# language DeriveGeneric #-}
{-# language DisambiguateRecordFields #-}
{-# language OverloadedStrings #-}
{-# language TypeApplications #-}

-- base
import Data.Int ( Int64 )
import GHC.Generics ( Generic )

-- rel8
import Rel8

-- time
import Data.Time ( UTCTime )


data TaskTable f = TaskTable
  { id :: Column f Int64
  , task :: HADT f Task
  }
  deriving (Generic, Rel8able)


data Task f = Pending | Complete (CompletedTask f)
  deriving (Generic)


data CompletedTask f = CompletedTask
  { date :: Column f UTCTime
  }
  deriving (Generic, Rel8able)


main

Replies: 3 comments 7 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@chrisdone-artificial
Comment options

Comment options

You must be logged in to vote
6 replies
@chrisdone-artificial
Comment options

@chrisdone-artificial
Comment options

@shane-circuithub
Comment options

@chrisdone-artificial
Comment options

@chrisdone-artificial
Comment options

Answer selected by chrisdone-artificial
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants