On Thu, Dec 3, 2009 at 6:00 PM, Joachim Breitner <m...@joachim-breitner.de> wrote: > > But when I uncommented the definition of toFoo and fromfoo, I got: > > Demo.hs:11:9: > Couldn't match expected type `Foo' against inferred type `Int' > In the expression: id > In the definition of `toFoo': toFoo = id > In the second argument of `openNewtype', namely > `[d| nullFoo :: Foo > nullFoo = 0 > toFoo :: Int -> Foo > toFoo = id > .... |]' > > And just now, after writing half the code, I find out that $( fun > [d|...|] ) runs the type checker on the declarations before passing them > to fun, which of course kills my whole approach here, as only having the > declarations pass through openNewType will make them type check. > > Is there any way to pass declarations to a TH function so that their > names are resolved, but their type is not checked (or, alternatively, > type errors are ignored). > > If not, what would be a sane work-around? >
You could switch over to using a quasi-quoter. I think there's one on hackage for parsing haskell declarations you might be able to start with: http://hackage.haskell.org/package/haskell-src-meta More on GHC quasi-quotations: http://www.haskell.org/ghc/docs/latest/html/users_guide/template-haskell.html#th-quasiquotation Antoine _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe