I find that I can't use the functions from Data.Singletons.TH
to create singletons for any types involving Text
/Symbol
s in them.
Demote Symbol = Text
so this is clearly meant to be an intended use-case for singletons
, but regardless of which one I try to use, I get an error (below). When I replace Text
with Symbol
or String
the error message is the same but with Text
replaced with Symbol
or String
.
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
module Lib where
import Data.Singletons.TH
import Data.Text (Text)
$(singletons [d|
data MyType = MyType Text Text
|])
results in:
src/Lib.hs:14:3: error:
• Could not deduce: Demote Text ~ Text
from the context: a ~ 'MyType n n1
bound by a pattern with constructor:
SMyType :: forall (n1 :: Text) (n2 :: Text).
Sing n1 -> Sing n2 -> Sing ('MyType n1 n2),
in an equation for ‘fromSing’
at src/Lib.hs:(14,3)-(16,4)
• In the first argument of ‘MyType’, namely ‘(fromSing b_a7ip)’
In the expression: (MyType (fromSing b_a7ip)) (fromSing b_a7iq)
In an equation for ‘fromSing’:
fromSing (SMyType b_a7ip b_a7iq)
= (MyType (fromSing b_a7ip)) (fromSing b_a7iq)
|
14 | $(singletons [d|
| ^^^^^^^^^^^^^^...
src/Lib.hs:14:3: error:
• Couldn't match expected type ‘Text’
with actual type ‘Demote Text’
• When checking that the pattern signature: Demote Text
fits the type of its context: Text
In the pattern: b_a7is :: Demote Text
In the pattern:
MyType (b_a7is :: Demote Text) (b_a7it :: Demote Text)
|
14 | $(singletons [d|
| ^^^^^^^^^^^^^^...