hello alex,
sorry slow reply, it's summer here...
> For example, say I have (++) and [1,2,3]. I then
> want to see if a value of type (Num a => [a]) can be
> applied to a function of type ([a] -> [a] -> [a]).
> I've been looking at Data.Typeable.funResultTy to do
> this, e.g.:
typeable won't work because it examines values, and
you're wanting to check the composition of type
signatures.
if you need ghc-as-a-library it may be better to start
there, however you can do what you want using
haskell-src-ext and HTE.
in the attached, mT infers a type for e3, and mT' rejects e5 saying:
Missing the instance declarations: IsIn "Num" [TCon "Char" Star],...
i'm curious to see how texture turns out!
best,
rohan
ps. HTE is at https://github.com/shayan-najd/HTE
pps. HTE does compile against base=4.6.0.0 if you edit HTE.cabal
import Language.Haskell.Exts {- haskell-src-exts -}
import qualified Language.Haskell.THIH.Typecheck.Load as T {- HTE -}
import qualified Language.Haskell.THIH.Typecheck.Types as T
mS :: String
mS = unlines ["e1 = (++)"
,"e2 = [1,2,3]"
,"e3 = e1 e2"]
mM :: Module
mM = fromParseResult (parseFileContents mS)
mT :: [T.Assump]
mT = T.tcHSEModuleWithPrelude mM
mS' :: String
mS' = unlines [mS
,"e4 = ['a','b','c']"
,"e5 = e3 e4"]
mM' :: Module
mM' = fromParseResult (parseFileContents mS')
mT' :: [T.Assump]
mT' = T.tcHSEModuleWithPrelude mM'
_______________________________________________
haskell-art mailing list
[email protected]
http://lists.lurk.org/mailman/listinfo/haskell-art