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

Example code of decodeFile is not work #213

Open
matsubara0507 opened this issue Mar 8, 2023 · 1 comment
Open

Example code of decodeFile is not work #213

matsubara0507 opened this issue Mar 8, 2023 · 1 comment

Comments

@matsubara0507
Copy link

When use decodeFile, occur compile error.
ref. example code at https://hackage.haskell.org/package/yaml-0.11.11.0/docs/Data-Yaml-TH.html#v:decodeFile

yaml> /path/to/yaml/test/Data/Yaml/THSpec.hs:15:11: error:
yaml>     • Couldn't match expected type: Language.Haskell.TH.Syntax.Code
yaml>                                       Language.Haskell.TH.Syntax.Q Value
yaml>                   with actual type: Language.Haskell.TH.Syntax.Q
yaml>                                       (Language.Haskell.TH.Syntax.TExp a0)
yaml>     • In the expression: decodeFile "test/sample.yaml"
yaml>       In the Template Haskell splice $$(decodeFile "test/sample.yaml")
yaml>       In the first argument of ‘shouldBe’, namely
yaml>         ‘($$(decodeFile "test/sample.yaml") :: Value)’
yaml>    |  
yaml> 15 |       ($$(decodeFile "test/sample.yaml") :: Value) `shouldBe` object ["name" .=  String "John Doe", "age" .= Number 23]
yaml>    |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Typed TH splice $$(...) expect type Code Q a instead of Q (TExp a) from GHC 9.0.x.
ref. https://gitlab.haskell.org/ghc/ghc/-/wikis/migration/9.0#typed-th-quotes-and-splices-have-different-types

But, decodeFile have return type Q (TExp a).
So, example code of decodeFile is not work.

I think that should fix example code to $$(Code $ decodeFile "config.yaml") OR change decodeFile's return value to Code Q a (Is the latter not good idea for backward compatibility?).

@snoyberg
Copy link
Owner

snoyberg commented Mar 8, 2023

A PR fixing the example would be great, ideally with a comment explaining that GHC 9 changed semantics.

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