On Jan 21, 2020, at 7:21 PM, Yiyun Liu <liuyiyun@terpmail.umd.edu> wrote:_______________________________________________Hi ghc-devs,
I've been trying to implementing a function with the signature:
elaborateExpr :: GhcMonad m => String -> m CoreExpr
It should take a string of the form:
"\x y -> x <> y :: Semigroup a => a -> a -> a"
and give back a core expression with the dictionaries filled in:
\ ($dSem :: Semigroup a) (x :: a) (y :: a) -> (<>) $dSem x y
The goal is to use the function to add elaboration support for liquidhaskell.
I looked into the implementation of exprType and defined my own elaborateExpr similarly by calling desugarExpr on the expression (which has type LHsExpr GhcTcId) returned by tcInferSigma.
GhcTcId is a synonym of GhcTc so the program I wrote typechecks, but it's definitely not right. The elaborateExpr function I defined would return something even when the expression doesn't typecheck, or occasionally give a runtime exception:
ghc-elaboration-test: panic! (the 'impossible' happened)
(GHC version 8.6.5 for x86_64-unknown-linux):
dsEvBindsI must have broken some invariants somehow.
What is the correct way of defining such a function (takes a string and returns a CoreExpr)? It appears to me that I should convert LHsExpr GhcPs into LHsExpr GhcTc first before calling deSugarExpr, but I don't know how.
Thank you,
- Yiyun
ghc-devs mailing list
ghc-devs@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs