I’m trying to write a decoder which parses the whole remaining columns with the same decoder.
Something like remaining :: Decode e s a -> Decode e s [a].
and then use it like: remaining utf8 :: Decode e ByteString [Text].
Now there is a function row :: Decode e s (Vector s) which does basically that, but the return type is fixed to s.
So I’d expect to be able to bind a monadic function.
And indeed, there is two different bind functions:
(>>==) :: Decode e s a -> (a -> DecodeValidation e b) -> Decode e s b
bindDecode :: Decode e s a -> (a -> Decode e s b) -> Decode e s b
which both seem close, but none of them works.
row >>== ??? does not work, because >>== wants an a -> DecodeValidation e b, not a utf8 :: Decode e s a. Unfortunately, the DecodeValidation version of utf8 is not exported.
row bindDecode (\bs -> ???) doesn’t work, because it requires a function ByteString -> Decode e s a which I don’t know how to construct.
I think for now I’ll just copy & paste the inner DecodeValidation part of utf8, but the binding story is really not great right now, it doesn’t compose with any of the primitives the Decode module exposes.
I’m trying to write a decoder which parses the whole remaining columns with the same decoder.
Something like
remaining :: Decode e s a -> Decode e s [a].and then use it like:
remaining utf8 :: Decode e ByteString [Text].Now there is a function
row :: Decode e s (Vector s)which does basically that, but the return type is fixed tos.So I’d expect to be able to bind a monadic function.
And indeed, there is two different bind functions:
which both seem close, but none of them works.
row >>== ???does not work, because>>==wants ana -> DecodeValidation e b, not autf8 :: Decode e s a. Unfortunately, theDecodeValidationversion ofutf8is not exported.rowbindDecode(\bs -> ???)doesn’t work, because it requires a functionByteString -> Decode e s awhich I don’t know how to construct.I think for now I’ll just copy & paste the inner
DecodeValidationpart ofutf8, but the binding story is really not great right now, it doesn’t compose with any of the primitives theDecodemodule exposes.