Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

decodeThrow expecting ‘Data.ByteString.Internal.ByteString’ #191

Open
JivanRoquet opened this issue Oct 18, 2020 · 3 comments
Open

decodeThrow expecting ‘Data.ByteString.Internal.ByteString’ #191

JivanRoquet opened this issue Oct 18, 2020 · 3 comments

Comments

@JivanRoquet
Copy link

The expected type for decodeThrow seems to be Data.ByteString.Internal.ByteString which seems to be inconsistent with what Data.Json.decode expects:

import qualified Data.ByteString.Lazy.Char8 as BL

import qualified Data.Yaml as Y
import qualified Data.Aeson as J

input = BL.pack "[1,2,3]" :: BL.ByteString

J.decode input :: Maybe [Int]
-- Just
--     [ 1
--     , 2
--     , 3
--     ]

Y.decodeThrow input :: Maybe [Int]
--     • Couldn't match expected type ‘Data.ByteString.Internal.ByteString’
--                   with actual type ‘BL.ByteString’

It also seems to contradict what the examples in the examples/ folder are showing, notably in Simple.hs.

Am I missing something, or should we adapt the documentation and examples to reflect this?

@snoyberg
Copy link
Owner

I think you're missing something. Data.Aeson and Data.Yaml have different APIs, no one claimed they would both work on the same data types.

@JivanRoquet
Copy link
Author

JivanRoquet commented Oct 19, 2020

Hey, thanks for the quick response

I agree that Data.Aeson and Data.Yaml are not supposed to work with same data types, however at least shouldn't the expected data types for Data.Yaml be consistent with what's shown in the examples/ section? (or more likely the reverse, shouldn't the examples reflect the actually expected data types)

When I try to run e.g. examples/Simple.hs it gives the error I mentioned above.

@snoyberg
Copy link
Owner

I can't see how the error message you mentioned can be generated from the code. Please provide exact code you're running, exactly library versions, and exact error messages. I'm fairly certain you're running a different bit of code than what is in the repo. For real reproducibility, you should include a Stack script (https://www.fpcomplete.com/haskell/tutorial/stack-script/).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants