bmillwood/haskell-src-meta

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

Closed this issue · 1 comments

Wizek commented

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?

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.