Re: [Haskell-cafe] Template Haskell and Unit

2013-08-29 Thread Richard Eisenberg
I've always considered Unit to just be a nullary tuple. This intuition has never steered me wrong, and it seems that Template Haskell is making the same assumption. If there's some reason that this conflation of ideas is wrong, I would be eager to know -- th-desugar makes this assumption in seve

Re: [Haskell-cafe] Template Haskell and Unit

2013-08-29 Thread adam vogt
Hi Jose and Richard, haskell-src-meta has Language.Haskell.Meta.Utils.normalizeT which can help with making code "treat the two constructs equivalently", though I imagine using th-desugar instead will make that process harder to mess up. Adam On Thu, Aug 29, 2013 at 10:13 AM, Richard Eisenberg

Re: [Haskell-cafe] Template Haskell and Unit

2013-08-29 Thread Jose A. Lopes
> I can't answer about "expected behavior", but I can say that those > two constructions should be considered identical by the $(…) splice > construct. For better or worse, Template Haskell often offers > multiple ways of encoding the same source Haskell phrase, and any > code that processes Templa

Re: [Haskell-cafe] Template Haskell and Unit

2013-08-29 Thread Richard Eisenberg
I can't answer about "expected behavior", but I can say that those two constructions should be considered identical by the $(…) splice construct. For better or worse, Template Haskell often offers multiple ways of encoding the same source Haskell phrase, and any code that processes Template Hask

[Haskell-cafe] Template Haskell and Unit

2013-08-29 Thread Jose A. Lopes
Hi, I am positive about the following situation, but I can't find any concrete answer on the Web. Can anyone confirm this ? In template-haskell-2.7.0, the following quote [t| () |] appears as a (ConT name), where "name" is the name for unit. However, in template-haskell-2.8.0, the same quote

Re: [Haskell-cafe] Template Haskell: let statement in a splice put in the "main = do" part of a program?

2013-08-27 Thread TP
adam vogt wrote: > TH quotes limited as you've noticed. One way to generate similar code > is to note that: > > do > let x = y > z > > is the same as let x = y in do z. You can generate the latter with > something like the following file, but the `a' isn't in scope for the > second argument

Re: [Haskell-cafe] Template Haskell

2013-08-27 Thread Jose A. Lopes
Thanks, Jose -- Jose Antonio Lopes Ganeti Engineering Google Germany GmbH Dienerstr. 12, 80331, München Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Geschäftsführer: Graham Law, Christine Elizabeth Flores Steuernummer: 48/725/00206 Umsatzsteueridentifikationsnumm

Re: [Haskell-cafe] Template Haskell

2013-08-27 Thread Niklas Hambüchen
Hi Jose, Template Haskell doesn't parse code. haskell-src-exts and the GHC API can do that. Have a look at: * ghc-mod browse (using ghc api) * hscope (using haskell-src-exts) On 27/08/13 15:45, Jose A. Lopes wrote: > Hi, > > Is it possible to retrieve all definitions contained in a module usi

[Haskell-cafe] Template Haskell

2013-08-26 Thread Jose A. Lopes
Hi, Is it possible to retrieve all definitions contained in a module using Template Haskell ? Thanks, Jose -- Jose Antonio Lopes Ganeti Engineering Google Germany GmbH Dienerstr. 12, 80331, München Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Geschäftsführer:

Re: [Haskell-cafe] Template Haskell: let statement in a splice put in the "main = do" part of a program?

2013-08-25 Thread adam vogt
On Sat, Aug 24, 2013 at 11:00 AM, TP wrote: > that has type Stmt, in an ExpQ that seems to be the only thing that we can > put in a splice. I have found that it can only be done by doE (or DoE) and > compE (or CompE) according to > > http://www.haskell.org/ghc/docs/latest/html/libraries/template-h

Re: [Haskell-cafe] Template Haskell: let statement in a splice put in the "main = do" part of a program?

2013-08-24 Thread TP
Brandon Allbery wrote: >> main = do >> >> $(makeLetStatement "a") >> -- print a >> > > Is that the actual indentation you used? Because it's wrong if so, and the > error you would get is the one you're reporting. Indentation matters in > Haskell. Yes, it matters, but not after "main = do": all t

Re: [Haskell-cafe] Template Haskell: let statement in a splice put in the "main = do" part of a program?

2013-08-24 Thread Brandon Allbery
On Sat, Aug 24, 2013 at 11:00 AM, TP wrote: > main = do > > $(makeLetStatement "a") > -- print a > Is that the actual indentation you used? Because it's wrong if so, and the error you would get is the one you're reporting. Indentation matters in Haskell. In an equation for `main': main = do

[Haskell-cafe] Template Haskell: let statement in a splice put in the "main = do" part of a program?

2013-08-24 Thread TP
Hi, I continue to test Template Haskell, and I have some difficulties to use a splice $() in a "do" contained in the "main" part of a program. Here is an example. I want to make a splice that does `let a="a"` in my code. $ cat MakeLetStatement.hs {-# LANGUAGE Templ

Re: [Haskell-cafe] Template Haskell and Haddock

2013-07-31 Thread Simon Hengel
On Wed, Jul 31, 2013 at 08:29:18PM +0300, kudah wrote: > On Wed, 31 Jul 2013 15:18:32 +0200 "Jose A. Lopes" > wrote: > > > Is there a way to access docstrings through Template Haskell ? > > For example, access the docstring of a function declaration ? > > No, but I believe you can access comment

Re: [Haskell-cafe] Template Haskell and Haddock

2013-07-31 Thread kudah
On Wed, 31 Jul 2013 15:18:32 +0200 "Jose A. Lopes" wrote: > Is there a way to access docstrings through Template Haskell ? > For example, access the docstring of a function declaration ? No, but I believe you can access comments and annotations using a ghc plugin. See https://github.com/thoughtp

[Haskell-cafe] Template Haskell and Haddock

2013-07-31 Thread Jose A. Lopes
Hi, Is there a way to access docstrings through Template Haskell ? For example, access the docstring of a function declaration ? Best regards, Jose ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-c

Re: [Haskell-cafe] Template Haskell Splicing

2012-12-15 Thread adam vogt
On Sat, Dec 15, 2012 at 9:24 AM, satvik chauhan wrote: > Yeah, that is the problem. I have a function inside which I need to generate > some declarations using TH. I can not generate these at the top level as > these generations depend on the function's parameters which are local to the > function

Re: [Haskell-cafe] Template Haskell Splicing

2012-12-15 Thread satvik chauhan
On Sat, Dec 15, 2012 at 1:30 PM, Michael Sloan wrote: > I don't think that there is a particular reason for not supporting > quasi-quotes in where clauses.. It should be added! > > The reason for /splices/ to not be supported in here statements is that > they are run during type checking. That

Re: [Haskell-cafe] Template Haskell Splicing

2012-12-15 Thread Michael Sloan
I don't think that there is a particular reason for not supporting quasi-quotes in where clauses.. It should be added! The reason for /splices/ to not be supported in here statements is that they are run during type checking. That way calls to "reify" can access type information for things befor

[Haskell-cafe] Template Haskell Splicing

2012-12-14 Thread satvik chauhan
Is there any way to splice declarations inside where? If not, then what is the reason for not supporting this? -Satvik ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] Template-haskell loading packages

2012-06-28 Thread Christopher Done
'Ello, I'm using TH in a big project and whenever TH starts-up in the GHC (6.4.2) compilation process it loads a number of packages: [119 o 119] Compiling Main ( src/Main.hs, dist/build/eudl/eudl-tmp/Main.o ) Loading package ghc-prim ... linking ... done. Loading package integer-gmp .

Re: [Haskell-cafe] Template Haskell antiquotation in user-defined quasiquoters

2012-05-25 Thread Mike Ledger
(oops, sorry, didn't do reply to all) I use haskell-src-meta in QuasiText (on hackage) also. It would certainly be nice to have "native" anti-quotations, but for now haskell-src-meta does a very good job. Mike On Sat, May 26, 2012 at 8:31 AM, Geoffrey Mainland wrote: > On 05/25/2012 21:46, Antoi

Re: [Haskell-cafe] Template Haskell antiquotation in user-defined quasiquoters

2012-05-25 Thread Geoffrey Mainland
On 05/25/2012 21:46, Antoine Latter wrote: > On Fri, May 25, 2012 at 2:51 PM, Sam Lindley wrote: >> Template Haskell supports antiquotation for built-in quasiquotes, e.g.: >> >> [| \x -> x + $([|3 * 4|]) |] >> >> However, as far as I can tell, there is no way of supporting antiquotation >> in use

Re: [Haskell-cafe] Template Haskell antiquotation in user-defined quasiquoters

2012-05-25 Thread Antoine Latter
On Fri, May 25, 2012 at 2:51 PM, Sam Lindley wrote: > Template Haskell supports antiquotation for built-in quasiquotes, e.g.: > >  [| \x -> x + $([|3 * 4|]) |] > > However, as far as I can tell, there is no way of supporting antiquotation > in user-defined quasiquoters, because the only way to spe

[Haskell-cafe] Template Haskell antiquotation in user-defined quasiquoters

2012-05-25 Thread Sam Lindley
Template Haskell supports antiquotation for built-in quasiquotes, e.g.: [| \x -> x + $([|3 * 4|]) |] However, as far as I can tell, there is no way of supporting antiquotation in user-defined quasiquoters, because the only way to specify a new quasiquoter is through a quoteExp function of ty

Re: [Haskell-cafe] Template Haskell: Generate annotated function of a typeclass

2012-05-10 Thread Ismael Figueroa Palet
Hi Michael, I was able to do what I wanted using reify instead of reifyInstances, and also I used applyT instead of substT. Thanks 2012/4/13 Ismael Figueroa Palet > Thanks for your reply, in particular the reference to subsT! > I will work more on this next monday, and report my progress > > Ch

Re: [Haskell-cafe] Template Haskell vs Rewrite Rules?

2012-04-19 Thread Jake McArthur
I once experimented with something similar. This is a preprocessor. This was a long time ago, and I don't use it. https://patch-tag.com/r/jmcarthur/overloaded-whitespace/snapshot/current/content/pretty/Main.hs On Thu, Apr 19, 2012 at 8:40 AM, Ismael Figueroa Palet wrote: > Hi Michael! > > Thanks

Re: [Haskell-cafe] Template Haskell vs Rewrite Rules?

2012-04-19 Thread Ismael Figueroa Palet
Hi Michael! Thanks (again) for your answer. I'm not quite confident using TH yet, but it seems in your code you must define an 'app' function, and then use [overloadedApp|... |] as a quasiquoteator to inject the overloaded app, right? Thanks for the zeroth reference too, one question remains for

Re: [Haskell-cafe] Template Haskell vs Rewrite Rules?

2012-04-19 Thread Michael Sloan
You're in luck! This is something I've wanted to implement before in the past, and your email reminded me. While pretty awful, it could be used for doing some interesting value-interception instrumentation in Haskell. Recently I've been messing with TH a lot, so this initial implementation was r

[Haskell-cafe] Template Haskell vs Rewrite Rules?

2012-04-18 Thread Ismael Figueroa Palet
I'm working on getting annotated versions of all instances of a function of a typeclass, and was wondering what are the relation/differences between Template Haskell and the Rewrite Rules section. Of course this is specific to GHC. Another question, in Racket, primitive function application is den

Re: [Haskell-cafe] Template Haskell: Generate annotated function of a typeclass

2012-04-13 Thread Ismael Figueroa Palet
Thanks for your reply, in particular the reference to subsT! I will work more on this next monday, and report my progress Cheers! 2012/4/13 Michael Sloan > Hello! > > It seems like you would want to use "reifyInstances" in order to get > all of the instances associated with a class. Then, you

Re: [Haskell-cafe] Template Haskell: Generate annotated function of a typeclass

2012-04-13 Thread Michael Sloan
Hello! It seems like you would want to use "reifyInstances" in order to get all of the instances associated with a class. Then, you can match up the variables in each instance with the variables in the class declaration, and create a mapping from the class variables to the instance parameters. T

[Haskell-cafe] Template Haskell: Generate annotated function of a typeclass

2012-04-13 Thread Ismael Figueroa Palet
Hi all, I think this is the right place for the following questions and I thank beforehand for your answers :-) I'm experimenting with typeclasses and TH, and I want to define a 'macro' that works more or less like this: Given the name of a typeclass and a function, return the expressions corres

Re: [Haskell-cafe] Template Haskell sometimes sees hidden constructors

2011-05-30 Thread Nicolas Frisby
A quick follow-up: 1) I had a typo: it should say "N4 is like N1 with a phantom type variable". 2) In my larger code base, the constructor that is visible to TH when I think it shouldn't be is part of a type that is alpha-equivalent to N3. It's odd that N3 doesn't exhibit the leakiness here but a

[Haskell-cafe] Template Haskell sometimes sees hidden constructors

2011-05-27 Thread Nicolas Frisby
Whith the three modules at the end of this email, I get some interesting results. Note that none of the constructors are exported, yet Template Haskell can see (and splice in variable occurrences of!) T, C2, W1, and W4. If you load Dump into GHCi, you get to see the Info that TH provides when you

Re: [Haskell-cafe] Template Haskell reified type.

2011-05-10 Thread Serguey Zefirov
to > produce TupleT and ListT! > > Simon > > | -Original Message- > | From: haskell-cafe-boun...@haskell.org > [mailto:haskell-cafe-boun...@haskell.org] On > | Behalf Of Serguey Zefirov > | Sent: 09 May 2011 14:43 > | To: haskell > | Subject: [Haskell

Re: [Haskell-cafe] Template Haskell reified type.

2011-05-10 Thread Simon Peyton-Jones
| Subject: [Haskell-cafe] Template Haskell reified type. | | Language.Haskell.TH.Type contains, among others, two constructors: | TupleT Int and ListT. | | I can safely construct types using them, but reification returns ConT | "GHC.Tuple.(,)" and ConT "GHC.Types.[]" respective

[Haskell-cafe] Template Haskell reified type.

2011-05-09 Thread Serguey Zefirov
Language.Haskell.TH.Type contains, among others, two constructors: TupleT Int and ListT. I can safely construct types using them, but reification returns ConT "GHC.Tuple.(,)" and ConT "GHC.Types.[]" respectively. This is not fair asymmetry, I think. Also, it took purity from one of my functions

[Haskell-cafe] Template Haskell support for GADTs

2011-04-30 Thread Boris Lykah
Hi all! I am writing a library which allows to refer to the separate fields of a datatype. The fields are described as GADT with one constructor for each field. The constructors return GADT with the field type. The auxiliary data structures for this should be generated automatically via Template H

Re: [Haskell-cafe] Template Haskell question

2011-04-17 Thread Daniel Schüssler
Hello, assuming you mean avoiding the import of Data.Map in the module *using* x, you can use name quotations: A.hs: > {-# LANGUAGE TemplateHaskell #-} > > module A where > > import Data.Map > import Language.Haskell.TH > > x = varE 'empty > B.hs: > {-# LANGUAGE TemplateHaskell #-} > m

[Haskell-cafe] Template Haskell question

2011-04-17 Thread Alexey Karakulov
I'm interested if it's possible to use functions from some module without explicitly importing it. In ghci it's done on the fly, like this: Prelude> Data.Map.empty Loading package array-0.3.0.2 ... linking ... done. Loading package containers-0.4.0.0 ... linking ... done. fromList [] But without

Re: [Haskell-cafe] Template Haskell tutorials?

2011-04-14 Thread Zoe Clifford
On Wed, Apr 13, 2011 at 10:43 PM, Kenneth Hoste wrote: > Hi, > The links to the supposedly brilliant Template Haskell tutorials by Bulat are > broken. > > http://www.haskell.org/bz/thdoc.htm > http://www.haskell.org/bz/th3.htm > > Does anyone know if these tutorials moved to somewhere else? > > g

[Haskell-cafe] Template Haskell tutorials?

2011-04-13 Thread Kenneth Hoste
Hi, The links to the supposedly brilliant Template Haskell tutorials by Bulat are broken. http://www.haskell.org/bz/thdoc.htm http://www.haskell.org/bz/th3.htm Does anyone know if these tutorials moved to somewhere else? greetings, Kenneth___ Haske

Re: [Haskell-cafe] Template Haskell a Permanent solution?

2011-01-18 Thread Ian Lynagh
On Tue, Jan 04, 2011 at 04:15:07PM +0100, Christian Maeder wrote: > Am 04.01.2011 15:48, schrieb Henning Thielemann: > > Christian Maeder schrieb: > >> Am 27.12.2010 08:44, schrieb Henning Thielemann: > >>> On Mon, 27 Dec 2010, Jonathan Geddes wrote: > >>> > #2 Provide instances automatically.

Re: [Haskell-cafe] Template Haskell a Permanent solution?

2011-01-04 Thread Christian Maeder
Am 04.01.2011 15:48, schrieb Henning Thielemann: > Christian Maeder schrieb: >> Am 27.12.2010 08:44, schrieb Henning Thielemann: >>> On Mon, 27 Dec 2010, Jonathan Geddes wrote: >>> #2 Provide instances automatically. >>> http://www.haskell.org/ghc/docs/7.0-latest/html/users_guide/generic-class

Re: [Haskell-cafe] Template Haskell a Permanent solution?

2011-01-04 Thread Henning Thielemann
Christian Maeder schrieb: > Am 27.12.2010 08:44, schrieb Henning Thielemann: >> On Mon, 27 Dec 2010, Jonathan Geddes wrote: >> >>> #2 Provide instances automatically. >> http://www.haskell.org/ghc/docs/7.0-latest/html/users_guide/generic-classes.html > > I see the text below and have no idea where

Re: [Haskell-cafe] Template Haskell a Permanent solution?

2011-01-04 Thread Dominique Devriese
All, 2010/12/27 Jonathan Geddes : > I see TH used most for the following tasks: > > #1 Parse a string at compile-time so that a custom syntax for > representing data can be used. At the extreme, this "data" might even > be an EDSL. > #2 Provide instances automatically. Just a note that TH is also

Re: [Haskell-cafe] Template Haskell a Permanent solution?

2011-01-04 Thread Christian Maeder
Am 27.12.2010 08:44, schrieb Henning Thielemann: > > On Mon, 27 Dec 2010, Jonathan Geddes wrote: > >> #1 Parse a string at compile-time so that a custom syntax for >> representing data can be used. At the extreme, this "data" might even >> be an EDSL. > > I think it would be enough, if the compi

Re: [Haskell-cafe] Template Haskell a Permanent solution?

2010-12-28 Thread Jonathan Geddes
On Tue, Dec 28, 2010 at 8:17 AM, Tillmann Rendel wrote: > This seems simple enough to me, so it looks as if your use case is already > supported as a library on top of the more general API. This is exactly what I was looking for, and much simpler than my previous experiences with quasiQuoters. I

Re: [Haskell-cafe] Template Haskell a Permanent solution?

2010-12-28 Thread Tillmann Rendel
Hi, Jonathan Geddes wrote: For TH use #1, compile-time parsing of arbitrary strings, I think it would be nice for quasiquote semantics to be modified so that code like json :: String -> JsonObject json = ... data = [ json | { "name" : "Jonathan" , "favorite language": "Haskell" }

Re: [Haskell-cafe] Template Haskell a Permanent solution?

2010-12-27 Thread Jonathan Geddes
Thanks, everyone, for the responses. > I don't understand why the library/extension duality is a problem. I don't think it is a _problem_ it just feels strange to me. Maybe I'm misunderstanding, is it possible to use TH without using the library components? > Shouldn't specialized features be de

Re: [Haskell-cafe] Template Haskell a Permanent solution?

2010-12-27 Thread Jonathan Geddes
On Mon, Dec 27, 2010 at 1:14 AM, Stephen Tetley wrote: > By this are you meaning to add quasiquoting to the language "Haskell" > or the "Glasgow Haskell", taking it out of the domain of Template > Haskell? I believe that all new features should start as extensions and as an extension, these thin

Re: [Haskell-cafe] Template Haskell a Permanent solution?

2010-12-27 Thread Jonathan Geddes
On Mon, Dec 27, 2010 at 12:44 AM, Henning Thielemann wrote: > I think it would be enough, if the compiler could be told to unfold an > expression like >  parse "text in a domain specific language" >  at compile time. I'm afraid I have to disagree with you here. Being able to specify that the stri

Re: [Haskell-cafe] Template Haskell a Permanent solution?

2010-12-27 Thread Ivan Lazar Miljenovic
2010/12/27 Henning Thielemann : > Or look into package 'encoding'. It uses TemplateHaskell in order to convert > Text descriptions of character sets into Haskell tables. I think the > character tables could be simply rewritten to Haskell syntax, or they could > be parsed by a function, where the pa

Re: [Haskell-cafe] Template Haskell a Permanent solution?

2010-12-27 Thread Henning Thielemann
On Mon, 27 Dec 2010, Jonas Almström Duregård wrote: Hi Henning, > I also think that Template Haskell is used too much. Several > things that are done in existing libraries could be done in plain > Haskell in a better way. Can you give any examples of this? I'm not saying it's not true, I'm ju

Re: [Haskell-cafe] Template Haskell a Permanent solution?

2010-12-27 Thread Jonas Almström Duregård
Hi Henning, > I also think that Template Haskell is used too much. Several > things that are done in existing libraries could be done in plain > Haskell in a better way. Can you give any examples of this? I'm not saying it's not true, I'm just curious as to why you would venture into the realm of

Re: [Haskell-cafe] Template Haskell a Permanent solution?

2010-12-27 Thread Jonas Almström Duregård
Hi, > But TH gives me the same feeling as other language features that have > been described as "bolted on." Also, TH is both library and built-in > syntax (via an extension) which feels strange to me. I don't understand why the library/extension duality is a problem. I would say that the best ap

Re: [Haskell-cafe] Template Haskell a Permanent solution?

2010-12-27 Thread Stephen Tetley
On 27 December 2010 07:35, Jonathan Geddes wrote: > #1 Parse a string at compile-time so that a custom syntax for > representing data can be used. At the extreme, this "data" might even > be an EDSL. Hello Jonathan By this are you meaning to add quasiquoting to the language "Haskell" or the "G

Re: [Haskell-cafe] Template Haskell a Permanent solution?

2010-12-26 Thread Henning Thielemann
On Mon, 27 Dec 2010, Jonathan Geddes wrote: #1 Parse a string at compile-time so that a custom syntax for representing data can be used. At the extreme, this "data" might even be an EDSL. I think it would be enough, if the compiler could be told to unfold an expression like parse "text in

[Haskell-cafe] Template Haskell a Permanent solution?

2010-12-26 Thread Jonathan Geddes
Cafe, First let me say that Template Haskell is very powerful and a lot of great work has been done in this area. It fills in a number of holes in Haskell's feature set. But TH gives me the same feeling as other language features that have been described as "bolted on." Also, TH is both library a

[Haskell-cafe] Template Haskell: exchanging information between 'splicers'

2010-11-26 Thread jean-christophe mincke
Hello, Does anyone know a clean solution to pass information between 2 executions of splicers. Ex. $(splicer ) -- first invocation gather and store some data $(splicer ...) -- second one use the data gathered above. Thank you Regards J-C __

Re: [Haskell-cafe] template haskell for typeclass synonyms

2010-11-02 Thread Gábor Lehel
Well, Template Haskell is what you go to when what you want -can't- be reasonably expressed with standard GHC Haskell. It's something of a last resort (at least in my case). Typeclass synonyms can be faked reasonably well with UndecidableInstances, but if you want to, for example, automatically gen

Re: [Haskell-cafe] template haskell for typeclass synonyms

2010-11-02 Thread Paolino
It's first time I use TH. It would be nice to point out the motivations for using it. If everything TH does is doable without it, the point of using it is write less code, eliminating some necessary and automatically computable code. But I guess there is some more . paolino 2010/11/2 Antoine

Re: [Haskell-cafe] template haskell for typeclass synonyms

2010-11-01 Thread Antoine Latter
2010/11/1 Paolino : > I think I've got something nice in the end. > > http://hpaste.org/41042/classsynonymhs > > example: > > class  (    ParteDi (Servizio a) s >         ,    Read a >         ,    Eq a >         ,     Show a >         ,     Integer `ParteDi` s >         ) ⇒ SClass s a > > $(classS

Re: [Haskell-cafe] template haskell for typeclass synonyms

2010-11-01 Thread Paolino
I think I've got something nice in the end. http://hpaste.org/41042/classsynonymhs example: class (ParteDi (Servizio a) s ,Read a ,Eq a , Show a , Integer `ParteDi` s ) => SClass s a $(classSynonym ''SClass) ghci ":i SClass" command

Re: [Haskell-cafe] template haskell for typeclass synonyms

2010-11-01 Thread Paolino
Thanks. I annotated the function http://hpaste.org/paste/41035/test_simpleclasssynonym It seems to produce the right code. How should I use the "Parents" synonym in my functions? This is a noob question I suppose. paolino 2010/11/1 Gábor Lehel > On Mon, Nov 1, 2010 at 6:09 PM, Christopher Do

Re: [Haskell-cafe] template haskell for typeclass synonyms

2010-11-01 Thread Gábor Lehel
On Mon, Nov 1, 2010 at 6:09 PM, Christopher Done wrote: > On 1 November 2010 17:53, Paolino wrote: >> I'd like to have a template haskell function that take some constraints and >> a class name and write an empty class from those and relative empty instance >> to simulate typeclass synonyms. >> >

Re: [Haskell-cafe] template haskell for typeclass synonyms

2010-11-01 Thread Christopher Done
On 1 November 2010 17:53, Paolino wrote: > I'd like to have a template haskell function that take some constraints and > a class name and write an empty class from those and relative empty instance > to simulate typeclass synonyms. > > As I've never written TH and couldn't find a easily adaptable

[Haskell-cafe] template haskell for typeclass synonyms

2010-11-01 Thread Paolino
Hello. I'd like to have a template haskell function that take some constraints and a class name and write an empty class from those and relative empty instance to simulate typeclass synonyms. As I've never written TH and couldn't find a easily adaptable code around, I ask here for the code, or so

Re: [Haskell-cafe] Template Haskell: onward and upward

2010-10-19 Thread Brandon Moore
>From: Simon Peyton-Jones >Sent: Mon, October 18, 2010 5:02:57 PM > >Folks > >Following lots of feedback from users, especially at ICFP, I’ve evolved some >proposals for Template Haskell, that should make it both more expressive, and >more secure. > >http://hackage.haskell.org/trac/ghc/blog/

Re: [Haskell-cafe] Template Haskell: onward and upward

2010-10-18 Thread Gregory Crosswhite
Since you are proposing creating an abstract type TExp that can't be created manually in contrast to Exp, I have a question that might simply be a reflection of ignorance on my part on how TH works now. As far as I can tell by looking through the documentation, when I want to create an identi

[Haskell-cafe] Template Haskell: onward and upward

2010-10-18 Thread Simon Peyton-Jones
Folks Following lots of feedback from users, especially at ICFP, I've evolved some proposals for Template Haskell, that should make it both more expressive, and more secure. http://hackage.haskell.org/trac/ghc/blog/Template%20Haskell%20Proposal Do let me know what you think. Discussion by ema

Re: [Haskell-cafe] Template Haskell: hiding declarations

2010-10-04 Thread Liam O'Connor
Perhaps try importing the huge module with lots of imports in another module, and then only export the ones you want. Cheers. ~Liam 2010/10/4 Vo Minh Thu : > 2010/10/4 Jonas Almström Duregård : >> Hi Café, >> >> I'm doing some code generation with Template Haskell that results in >> few hundred

Re: [Haskell-cafe] Template Haskell: hiding declarations

2010-10-04 Thread Vo Minh Thu
2010/10/4 Jonas Almström Duregård : > Hi Café, > > I'm doing some code generation with Template Haskell that results in > few hundred top level declaration, of which only 10 or so should > actually be exposed to the user (the rest are only used by generated > code). > > Since I cant splice stuff in

[Haskell-cafe] Template Haskell: hiding declarations

2010-10-04 Thread Jonas Almström Duregård
Hi Café, I'm doing some code generation with Template Haskell that results in few hundred top level declaration, of which only 10 or so should actually be exposed to the user (the rest are only used by generated code). Since I cant splice stuff into the module header (i.e. into the export list),

Re: [Haskell-cafe] Template Haskell sees into abstract data types

2010-07-28 Thread Serguey Zefirov
2010/7/28 Simon Peyton-Jones : > I assume you've seen http://hackage.haskell.org/trac/ghc/ticket/4222 > There are non-obvious design choices here Yes, I've seen that. Right now I just cannot grok it fully. I feel like I should share my current understanding with cafe, so I wrote them in my answer

RE: [Haskell-cafe] Template Haskell sees into abstract data types

2010-07-28 Thread Simon Peyton-Jones
| To: Jonas Almström Duregård | Cc: Ivan Lazar Miljenovic; haskell | Subject: Re: [Haskell-cafe] Template Haskell sees into abstract data types | | 2010/7/28 Jonas Almström Duregård : | > Hi, | > | >> I cannot write classes that see into internal structure. For example, | >> I

Re: [Haskell-cafe] Template Haskell sees into abstract data types

2010-07-28 Thread Gábor Lehel
On Wed, Jul 28, 2010 at 12:55 PM, Gábor Lehel wrote: > 2010/7/28 Serguey Zefirov : >> 2010/7/28 Jonas Almström Duregård : >>> Hi, >>> I cannot write classes that see into internal structure. For example, I cannot write my own (de)serialization without using from/toAscList. >>> >>> Actual

Re: [Haskell-cafe] Template Haskell sees into abstract data types

2010-07-28 Thread Gábor Lehel
2010/7/28 Serguey Zefirov : > 2010/7/28 Jonas Almström Duregård : >> Hi, >> >>> I cannot write classes that see into internal structure. For example, >>> I cannot write my own (de)serialization without using from/toAscList. >> >> Actually I don't believe you can do this with TH either. TH splices >

Re: [Haskell-cafe] Template Haskell sees into abstract data types

2010-07-28 Thread Serguey Zefirov
2010/7/28 Jonas Almström Duregård : > Hi, > >> I cannot write classes that see into internal structure. For example, >> I cannot write my own (de)serialization without using from/toAscList. > > Actually I don't believe you can do this with TH either. TH splices > code into the module where you use

Re: [Haskell-cafe] Template Haskell sees into abstract data types

2010-07-28 Thread Jonas Almström Duregård
Hi, > I cannot write classes that see into internal structure. For example, > I cannot write my own (de)serialization without using from/toAscList. Actually I don't believe you can do this with TH either. TH splices code into the module where you use it. The generated code is then type checked in

RE: [Haskell-cafe] Template Haskell sees into abstract data types

2010-07-26 Thread Simon Peyton-Jones
| Data.Map.Map and Data.Set.Set are exported abstractly, without | exposing knowledge about their internal structure. | | I cannot directly create my own class instances for them because of | that. But I found that I can write Template Haskell code that could do | that - those data types cou

Re: [Haskell-cafe] Template Haskell sees into abstract data types

2010-07-03 Thread Brandon S Allbery KF8NH
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 7/4/10 00:29 , Ivan Lazar Miljenovic wrote: > David Menendez writes: >> I believe the point is that Template Haskell can see the internal >> structure of a type even when the constructors are not exported. The >> question is whether or not that is

Re: [Haskell-cafe] Template Haskell sees into abstract data types

2010-07-03 Thread Ivan Lazar Miljenovic
David Menendez writes: > I believe the point is that Template Haskell can see the internal > structure of a type even when the constructors are not exported. The > question is whether or not that is intentional. I was under the impression that the question was whether the hiding of the construct

Re: [Haskell-cafe] Template Haskell sees into abstract data types

2010-07-03 Thread David Menendez
On Sat, Jul 3, 2010 at 7:20 PM, Ivan Lazar Miljenovic wrote: > Serguey Zefirov writes: > I cannot directly create my own class instances for them because of that. But I found that I can write Template Haskell code that could do that - those data types could be reified just fine. >

Re: [Haskell-cafe] Template Haskell sees into abstract data types

2010-07-03 Thread Ivan Lazar Miljenovic
Serguey Zefirov writes: >>> I cannot directly create my own class instances for them because of >>> that. But I found that I can write Template Haskell code that could do >>> that - those data types could be reified just fine. >> Huh? Sure you can write class instances for them. >> , >> | in

Re: [Haskell-cafe] Template Haskell sees into abstract data types

2010-07-03 Thread Serguey Zefirov
>> I cannot directly create my own class instances for them because of >> that. But I found that I can write Template Haskell code that could do >> that - those data types could be reified just fine. > Huh? Sure you can write class instances for them. > , > | instance SizeOf (Map k v) where >

Re: [Haskell-cafe] Template Haskell sees into abstract data types

2010-07-03 Thread Ivan Lazar Miljenovic
Serguey Zefirov writes: > Data.Map.Map and Data.Set.Set are exported abstractly, without > exposing knowledge about their internal structure. > > I cannot directly create my own class instances for them because of > that. But I found that I can write Template Haskell code that could do > that - t

[Haskell-cafe] Template Haskell sees into abstract data types

2010-07-03 Thread Serguey Zefirov
Data.Map.Map and Data.Set.Set are exported abstractly, without exposing knowledge about their internal structure. I cannot directly create my own class instances for them because of that. But I found that I can write Template Haskell code that could do that - those data types could be reified just

Re: [Haskell-cafe] Template Haskell

2010-03-19 Thread Stephen Tetley
Hi Rafael There is a paper describing a variant of Conal Elliott's Pan implemented with Template Haskell - PanTH - which you might find interesting: Optimising Embedded DSLs using Template Haskell Sean Seefried, Manuel Chakravarty, and Gabriele Keller http://www.haskell.org/th/papers/th-pan.ps

Re: [Haskell-cafe] Template Haskell

2010-03-19 Thread Brandon S. Allbery KF8NH
On Mar 19, 2010, at 12:01 , Rafael Almeida wrote: I got the printf example to run, and it is an alright example of something to do with template haskell. You lose the ability to use a dynamic generated string for the format, but that's not a practical drawback (I can't think of a practical reason

[Haskell-cafe] Template Haskell

2010-03-19 Thread Rafael Almeida
I was reading the good old template haskell paper by Sheard and Peyton Jones [1]. It looks like some API have changed, but things seems to be more or less the same. I got the printf example to run, and it is an alright example of something to do with template haskell. You lose the ability to use a

Re: Re[2]: [Haskell-cafe] Template Haskell - substitution in pattern in a lambda

2010-01-04 Thread Gregory Crosswhite
Cool, Burat! Those are the first tutorials I've read on TH that have succeeded in giving me a sense of how I can actually use it! Thanks for writing them up. :-D Cheers, Greg On Jan 4, 2010, at 3:12 AM, Bulat Ziganshin wrote: > Hello Patrick, > > Monday, January 4, 2010, 5:59:18 AM, you wr

Re[2]: [Haskell-cafe] Template Haskell - substitution in pattern in a lambda

2010-01-04 Thread Bulat Ziganshin
Hello Patrick, Monday, January 4, 2010, 5:59:18 AM, you wrote: > I'm guessing no such syntax exists? you are right. look at http://www.haskell.org/bz/th3.htm http://www.haskell.org/bz/thdoc.htm -- Best regards, Bulatmailto:bulat.zigans...@gmail.com __

Re: [Haskell-cafe] Template Haskell - substitution in pattern in a lambda

2010-01-03 Thread Patrick Caldon
Tuomas Tynkkynen wrote: Here's something pretty generic that gets the patterns right: Thanks for that - about 2/3rds of the length of my proposed solution! Cheers, Patrick. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.o

Re: [Haskell-cafe] Template Haskell - substitution in pattern in a lambda

2010-01-03 Thread Tuomas Tynkkynen
2010/1/4 Patrick Caldon > > I'm trying to write some template haskell which will transform: > > $(buildCP 0)  into \(SimpleM d1 d2 d3) (SimpleM _ _ _) -> (SimpleM d1 d2 d3) > $(buildCP 1)  into \(SimpleM _ d2 d3) (SimpleM d1 _ _) -> (SimpleM d1 d2 d3) > $(buildCP 1)  into \(SimpleM d1 _ d3) (Simpl

Re: [Haskell-cafe] Template Haskell - substitution in pattern in a lambda

2010-01-03 Thread Patrick Caldon
Antoine Latter wrote: On Sun, Jan 3, 2010 at 8:30 PM, Patrick Caldon wrote: I'm trying to write some template haskell which will transform: $(buildCP 0) into \(SimpleM d1 d2 d3) (SimpleM _ _ _) -> (SimpleM d1 d2 d3) $(buildCP 1) into \(SimpleM _ d2 d3) (SimpleM d1 _ _) -> (SimpleM d1 d2 d

Re: [Haskell-cafe] Template Haskell - substitution in pattern in a lambda

2010-01-03 Thread Antoine Latter
On Sun, Jan 3, 2010 at 8:30 PM, Patrick Caldon wrote: > > I'm trying to write some template haskell which will transform: > > $(buildCP 0)  into \(SimpleM d1 d2 d3) (SimpleM _ _ _) -> (SimpleM d1 d2 d3) > $(buildCP 1)  into \(SimpleM _ d2 d3) (SimpleM d1 _ _) -> (SimpleM d1 d2 d3) > $(buildCP 1)  

[Haskell-cafe] Template Haskell - substitution in pattern in a lambda

2010-01-03 Thread Patrick Caldon
I'm trying to write some template haskell which will transform: $(buildCP 0) into \(SimpleM d1 d2 d3) (SimpleM _ _ _) -> (SimpleM d1 d2 d3) $(buildCP 1) into \(SimpleM _ d2 d3) (SimpleM d1 _ _) -> (SimpleM d1 d2 d3) $(buildCP 1) into \(SimpleM d1 _ d3) (SimpleM _ d2 _) -> (SimpleM d1 d2 d3) a

RE: [Haskell-cafe] Template Haskell very wordy w/r/t Decs and Types

2009-05-28 Thread Simon Peyton-Jones
ine: my nose tells me this is a swamp and I'm steering clear of it for now. Simon From: Matt Morrow [mailto:moonpa...@gmail.com] Sent: 28 May 2009 00:08 To: Simon Peyton-Jones Cc: Ross Mellgren; Haskell Cafe; GHC users Subject: Re: [Haskell-cafe] Template Haskell very wordy w/r/t Decs and Ty

  1   2   >