Hi @brandonchinn178 it's me again. :)
I am trying to distinguish user input based on type annotation, for what would be either a text literal or a reference. I plan on using type annotations to label strings, and parse those as separate data types.
However using (naïvely I must confess) the (<|>) operator does not seem to give the expected results.
Here is a an excerpt from the reproducer, that you can run with cabal run Repro.hs:
myNodeDecoder :: DecodeArrow NodeList () (Either Var Text)
myNodeDecoder =
KDL.nodeWith "node" $
(Right <$> KDL.argWith' ["text"] KDL.text)
<|> (Left <$> KDL.argWith' ["var"] (Var <$> KDL.text))
Should I drop to a lower parsing level to make the distinction?
Repro.hs
Hi @brandonchinn178 it's me again. :)
I am trying to distinguish user input based on type annotation, for what would be either a text literal or a reference. I plan on using type annotations to label strings, and parse those as separate data types.
However using (naïvely I must confess) the
(<|>)operator does not seem to give the expected results.Here is a an excerpt from the reproducer, that you can run with
cabal run Repro.hs:Should I drop to a lower parsing level to make the distinction?
Repro.hs