Tobias Dammers wrote: > IIRC you can use haskell-src-exts to parse a string into TH AST > structures. There might even be a quasi-quoter for that; I don't have a > real computer at hand right more, so you'll need to do some research of > your own.
Thanks Tobias, it led me to the right path. There is indeed a solution in Language.Haskell.Meta: $ ghci > :m Language.Haskell.Meta > parseDecs "s=s+1" Right [ValD (VarP s) (NormalB (UInfixE (VarE s) (VarE +) (LitE (IntegerL 1)))) []] > parseExp "x+1" Right (UInfixE (VarE x) (VarE +) (LitE (IntegerL 1))) > :i parseDecs parseDecs :: String -> Either String [Language.Haskell.TH.Syntax.Dec] -- Defined in `Language.Haskell.Meta.Parse' > :i parseExp parseExp :: String -> Either String Language.Haskell.TH.Syntax.Exp -- Defined in `Language.Haskell.Meta.Parse' Thanks, TP _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe