Spread Singleton among modules

Hi, I’m using the singletons and singletons-th libraries, and I want (if possible) to split a singleton definition between files. I tried creating a data family, but I’m getting a Declaration cannot be promoted error.

How could I split the singleton definition between two or more files?

1 Like

Here is some sample code:

data family Field
data family SField :: Field -> Type

singletons
  [d|

  data instance Field = Field1 | Field2
  |]

>>> Other file:
singletons
  [d|
  data instance Field = Field3
  |]
1 Like

These data instances are conflicting and are not valid even if they are not promoted. I also think singletons-th simply does not support promoting data families. I don’t know if it is even technically possible; what would the generated code look like?

Yeah, it’s impossible using data families.

But using open type families it could be possible