Skip to content
  • Iavor S. Diatchki's avatar
    Add code to convert from representation types, to existentially quantified singletons. · 02b9a24a
    Iavor S. Diatchki authored
    The basic idea is like this:
    
    data SomeSing where SomeSing :: SingI n => Proxy n -> SomeSing
    
    toSing :: Integer -> Maybe SomeSing  -- Maybe, so that we rejetc -ve numbers
    
    The actual implementation is a bit more complicated because `SomeSing`
    is actually parameterized by a kind, so we really have something akin
    `SomeSing k`.  Also, `toSing` is a bit more general because, depending
    on the kind, the representation is different.  For example, we also
    support:
    
    toSing :: String -> Maybe (SomeSing (KindParam :: KindIs Symbol))
    
    
    This change relies on the primitive added to the compiler, which
    converts `Sing` values into `SingI` dictionaries.
    
    A nice benefit of this change is that, as far as I can see,
    we don't need  `unsafeSinNat` and friends, so I removed them.
    02b9a24a