Re: [Haskell-cafe] [Haskell] ANNOUNCE: notcpp-0.0.1
On 04/13/2012 10:49 PM, Ben Millwood wrote: I'm pleased to announce my first genuinely original Hackage package: notcpp-0.0.1! http://hackage.haskell.org/package/notcpp [...] Why is it scopeLookup :: String - Q Exp with n bound to x :: T = @scopeLookup n@ evaluates to an Exp containing @Just x@ , not scopeLookup :: String - Q (Maybe Exp) with n bound to x :: T = @scopeLookup n@ evaluates to Just (an Exp containing @x@) ? Shouldn't n's being in scope be a compile time decision? That would also make the openState: runtime name resolution has its drawbacks :/[1] a compile time error. -- Steffen [1] http://hackage.haskell.org/packages/archive/notcpp/0.0.1/doc/html/NotCPP-ScopeLookup.html ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [Haskell] ANNOUNCE: notcpp-0.0.1
On Sun, Apr 15, 2012 at 7:14 PM, Steffen Schuldenzucker sschuldenzuc...@uni-bonn.de wrote: On 04/13/2012 10:49 PM, Ben Millwood wrote: I'm pleased to announce my first genuinely original Hackage package: notcpp-0.0.1! http://hackage.haskell.org/package/notcpp [...] Why is it scopeLookup :: String - Q Exp with n bound to x :: T = @scopeLookup n@ evaluates to an Exp containing @Just x@ , not scopeLookup :: String - Q (Maybe Exp) with n bound to x :: T = @scopeLookup n@ evaluates to Just (an Exp containing @x@) ? Shouldn't n's being in scope be a compile time decision? That would also make the openState: runtime name resolution has its drawbacks :/[1] a compile time error. -- Steffen [1] http://hackage.haskell.org/packages/archive/notcpp/0.0.1/doc/html/NotCPP-ScopeLookup.html This way minimises the amount the user has to know about Template Haskell, because the user can just splice the expression immediately and then operate on it as an ordinary value. The design you suggest would require messing about in the Q monad to construct the expression you wanted based on whether you got a Nothing or a Just, which in my view is more awkward. I can see how your version would be useful too, though – in particular I can move the error call to a report call, which throws a compile-time error as you say. I'd be happy to expose both next version ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [Haskell] ANNOUNCE: notcpp-0.0.1
With the C pre processor you can write different code for windows and non windows? Can your package achieve the same? The name alone makes it sound like an alternative to using CPP. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [Haskell] ANNOUNCE: notcpp-0.0.1
Hi, scopeLookup :: String - Q Exp The example provided here [1] fails at runtime is no name can be found in scope. Would it make more sense to have scopeLookup :: [String] - Q Exp and have compilation fail if no name in the list is in scope? By the way, the library brings an interesting approach to conditional compilation. Facundo [1] http://hackage.haskell.org/packages/archive/notcpp/0.0.1/doc/html/NotCPP-ScopeLookup.html ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [Haskell] ANNOUNCE: notcpp-0.0.1
On Fri, 13 Apr 2012, Ben Millwood wrote: But I never liked using CPP: it completely defeats haskell-src-exts and hence things like SourceGraph, and anyway it's not designed for Haskell and doesn't at all understand its structure, or fit with its syntax. With a little thought, I wondered if creative use of template haskell might not achieve the same goal. It turned out it did, and emboldened with this knowledge I set out to write a new package making this technique available to others. I never liked CPP in Haskell, too. The problem is: I also do not like Template Haskell. :-) Whereever possible I use a Cabal flag and a conditional Hs-Source-Dirs. http://www.haskell.org/haskellwiki/Cabal/Developer-FAQ#Adapt_to_different_systems_without_CPP ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe