bmillwood / haskell-src-meta

Maintenance of Matt Morrow's package for parsing haskell source to a TH AST.
27 stars 51 forks source link

Q: Is it/could it be possible to type check expressions? #77

Closed Wizek closed 5 years ago

Wizek commented 6 years ago

If I do parseExp "1 :: Char" then I get Right $ SigE (LitE $ IntegerL 1) (ConT Char) Is that because haskell-src-meta only implements a parser and not a type checker?

And if so, could a type checker be implemented and ran on top of this? Or would that be a large undertaking? Or could ghc's own checker be reused/called upon somehow?

JonasDuregard commented 5 years ago

Yes, it is because it is only a parser - and yes, changing that would be a major undertaking. Specifically, it would be this project: http://hackage.haskell.org/package/haskell-type-exts Or possibly adding some kind of (safe) inverse to this function to TH: https://hackage.haskell.org/package/template-haskell-2.14.0.0/docs/Language-Haskell-TH-Syntax.html#v:unTypeQ

GHC's type checker checks the expression when it is spliced.