Skip to content

Instantly share code, notes, and snippets.

@s9gf4ult
Created March 22, 2016 09:53
Show Gist options
  • Select an option

  • Save s9gf4ult/e1476544149dc7c8747f to your computer and use it in GitHub Desktop.

Select an option

Save s9gf4ult/e1476544149dc7c8747f to your computer and use it in GitHub Desktop.
data Table = Table Bool Symbol Symbol
-- | Term level table information carrier.
data TTable = TTable Bool String String
data instance Sing ('Table opt pre tbl) =
STable (Sing opt) (Sing pre) (Sing tbl)
instance ( SingI opt, SingI pre, SingI tbl )
=> SingI ('Table opt pre tbl) where
sing = STable sing sing sing
instance SingKind ('KProxy :: KProxy Table) where
type DemoteRep ('KProxy :: KProxy Table) = TTable
fromSing = \case
(STable opt pre tbl) ->
TTable (fromSing opt) (fromSing pre) (fromSing tbl)
toSing (TTable opt pre tbl) =
STable (toSing opt) (toSing pre) (toSing tbl)
-- Couldn't match type ‘a’ with ‘'Table a0 a1 a2’
-- ‘a’ is a rigid type variable bound by
-- the type signature for fromSing :: Sing a -> DemoteRep 'KProxy
-- at src/Database/PostgreSQL/Typed/Table.hs:46:3
-- Expected type: Sing a
-- Actual type: Sing ('Table a0 a1 a2)
-- Relevant bindings include
-- fromSing :: Sing a -> DemoteRep 'KProxy
-- (bound at src/Database/PostgreSQL/Typed/Table.hs:46:3)
-- In the pattern: STable opt pre tbl
-- In a case alternative:
-- (STable opt pre tbl)
-- -> TTable (fromSing opt) (fromSing pre) (fromSing tbl)
-- In the expression:
-- \case {
-- (STable opt pre tbl)
-- -> TTable (fromSing opt) (fromSing pre) (fromSing tbl) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment