Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How am I supposed to use the package haskell-type-exts?

I am trying to typecheck a code snippet provided as a string.

I found the package haskell-type-exts (hackage link) which seems to provide what i need: With parseModule an AST gets constructed on which typecheckModule can be applied. But then I don't know what to do with the result. It is of type Tc VarEnv where Tc is a monad.

The package provides a test case where something like this is used:

ea <- runTc testEnv $ typecheckExp e

But runTc is in a hidden module so I cannot use it. Here is the code I have so far:

import Language.Haskell.Exts.Parser (parseModule, ParseResult(..))
import Language.Haskell.TypeCheck.TypeCheck
-- import Language.Haskell.TypeCheck.Monad  --hidden module

main = do
    let m = "myTest = map (+1) [1..10]"
    let r = parseModule m
    case r of
         ParseOk res -> printStuff res
         _ -> print "wtf"

printStuff r = do
    let Right tc = return $ typecheckModule r
--    print tc?

What am I missing here? Maybe the module is only hidden by mistake?

like image 575
somesoaccount Avatar asked Jul 07 '13 09:07

somesoaccount


1 Answers

I think this package is not yet ready for usage. Just look at the source of Language.Haskell.TypeCheck. For example typeCheck = undefined typechecks of course!

You could try to use the GHC-API (Haddock and Wiki Page).

like image 126
Shoe Avatar answered Sep 18 '22 19:09

Shoe