Skip to content

TypeRep in data type does not work with genSingletons. #503

Description

@Sintrastes

With singletons-3.0 and singletons-th-3.0, if I try to generate a singled data type with TypeRep as one of the fields, with genSingletons, for instance:

data MvType s where
  MvHsT   :: TypeRep -> MvType s
  MvBaseT :: s -> MvType s
  MvFunT  :: MvType s -> MvType s -> MvType s
  MvPredT :: MvType s

$(genSingletons [''MvType])

I get the following exception in GHC:

src/Meriv/Types.hs:27:2: error:
    • Couldn't match type ‘Demote
                             base-4.15.0.0:Data.Typeable.Internal.SomeTypeRep’
                     with ‘base-4.15.0.0:Data.Typeable.Internal.SomeTypeRep’
      Expected: TypeRep
        Actual: Demote base-4.15.0.0:Data.Typeable.Internal.SomeTypeRep
    • When checking that the pattern signature:
          Demote base-4.15.0.0:Data.Typeable.Internal.SomeTypeRep
        fits the type of its context: TypeRep
      In the pattern:
        b_a7uB :: Demote base-4.15.0.0:Data.Typeable.Internal.SomeTypeRep
      In the pattern:
        MvHsT (b_a7uB :: Demote base-4.15.0.0:Data.Typeable.Internal.SomeTypeRep)
   |

I know that there are issues with TypeRep promotion, as documented here, however, I was not able to find any documentation explaining how to use Data.Singletons.Base.TypeRepTYPE to create a singled version of a data type containing TypeRep.

Note: a related issue looks like it had a workaround added in 3.0 so genSingletons works correctly with data types with Nats, so I am wondering if it is possible to add a workaround for TypeRep as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions