Welcome to the Functional Programming Zulip Chat Archive. You can join the chat here.
Is there an equivalent of symbolVal for Char like charVal :: forall n proxy. KnownChar n => Char? I am trying to realize the char kind in runtime.
symbolVal
charVal :: forall n proxy. KnownChar n => Char
don't think so, what are you trying to do?
There isn't support for type level chars yet - issue on GHC tracker exists, I just can't find it :big_smile:
https://gitlab.haskell.org/ghc/ghc/-/merge_requests/3598
I am trying to strip the prefix chars from a JSON string. I would like to specify which char to strip at the type level.
newtype StripPrefixes (c :: Char) a = StripPrefixes a instance FromJSON a => FromJSON (StripPrefixes c a) where parseJSON = ...
at least you can strip entire strings for now instead so it's not a blocker (?)
if you're interested, here's some hacky stuff with Symbols - https://kcsongor.github.io/symbol-parsing-haskell/
Symbol
I'd wager you can use these things to error out if the user uses a Symbol with more than one character :thinking:
Currently just doing
instance (KnownSymbol s, FromJson a) => FromJSON (StripPrefixes s a) where parseJSON = case prefix of "" -> parseJSON _ -> \case String x -> whileJust (T.stripPrefix prefix) >>> String >>> parseJSON _ -> fail "Expecting String" whileJust :: (a -> Maybe a) -> a -> a
Is there an equivalent of
symbolVal
for Char likecharVal :: forall n proxy. KnownChar n => Char
? I am trying to realize the char kind in runtime.don't think so, what are you trying to do?
There isn't support for type level chars yet - issue on GHC tracker exists, I just can't find it :big_smile:
https://gitlab.haskell.org/ghc/ghc/-/merge_requests/3598
I am trying to strip the prefix chars from a JSON string. I would like to specify which char to strip at the type level.
at least you can strip entire strings for now instead so it's not a blocker (?)
if you're interested, here's some hacky stuff with
Symbol
s - https://kcsongor.github.io/symbol-parsing-haskell/I'd wager you can use these things to error out if the user uses a
Symbol
with more than one character :thinking:Currently just doing