Jose A. Lopes | 29 Aug 15:03 2013
Picon

Template Haskell and Unit

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 appears as (TupleT 0).

Is this the expected behaviour ?

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
Umsatzsteueridentifikationsnummer: DE813741370
Richard Eisenberg | 29 Aug 16:13 2013

Re: Template Haskell and Unit

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 Haskell syntax
should probably treat the two constructs equivalently.

In a week or so, I'm hoping to release the first version of a new th-desugar package, which attempts to remove
these redundancies by converting TH syntax into a smaller syntax tree. I'll announce here when it's ready
for public consumption.

I hope this helps,
Richard

On Aug 29, 2013, at 9:03 AM, Jose A. Lopes wrote:

> 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 appears as (TupleT 0).
> 
> Is this the expected behaviour ?
> 
> Thanks,
> Jose
(Continue reading)

Jose A. Lopes | 29 Aug 17:08 2013
Picon

Re: Template Haskell and Unit

> 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 Haskell syntax should probably treat
> the two constructs equivalently.

I am not sure I agree that those two constructions should be
identical.  The Unit type is just a normal type with a single
inhabitant: the unit value.  How is this related to tuples ?

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
Umsatzsteueridentifikationsnummer: DE813741370

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
(Continue reading)

Richard Eisenberg | 29 Aug 18:25 2013

Re: Template Haskell and Unit

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 several places.

Thanks,
Richard

On Aug 29, 2013, at 11:08 AM, "Jose A. Lopes" <jabolopes <at> google.com> wrote:

>> 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 Haskell syntax should probably treat
>> the two constructs equivalently.
> 
> I am not sure I agree that those two constructions should be
> identical.  The Unit type is just a normal type with a single
> inhabitant: the unit value.  How is this related to tuples ?
> 
> Jose
> 
> -- 
> Jose Antonio Lopes
> Ganeti Engineering
> Google Germany GmbH
> Dienerstr. 12, 80331, München
> 
> Registergericht und -nummer: Hamburg, HRB 86891
> Sitz der Gesellschaft: Hamburg
(Continue reading)

adam vogt | 29 Aug 17:44 2013
Picon

Re: Template Haskell and Unit

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 <eir <at> cis.upenn.edu> wrote:
> 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 Haskell syntax
should probably treat the two constructs equivalently.
>
> In a week or so, I'm hoping to release the first version of a new th-desugar package, which attempts to
remove these redundancies by converting TH syntax into a smaller syntax tree. I'll announce here when
it's ready for public consumption.
>
> I hope this helps,
> Richard
>
> On Aug 29, 2013, at 9:03 AM, Jose A. Lopes wrote:
>
>> 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
(Continue reading)

Simon Peyton-Jones | 13 Sep 11:11 2005
Picon

RE: Template Haskell and Types


| >     putStrLn $(mysplice ''MyData)
| >
| 
| Thanks for responses. Is there any up-to-date documentation avaliable?

Template Haskell is, alas, poorly documented.  I would really welcome
someone to volunteer to help write better documentation.  Meanwhile, as
the user manual says, the stuff about quoting names is described in a
design note http://research.microsoft.com/~simonpj/tmp/notes2.ps

Simon
Gracjan Polak | 13 Sep 18:03 2005

Re: Template Haskell and Types

Simon Peyton-Jones wrote:
> | >     putStrLn $(mysplice ''MyData)
> | >
> | 
> | Thanks for responses. Is there any up-to-date documentation avaliable?
> 
> Template Haskell is, alas, poorly documented.  I would really welcome
> someone to volunteer to help write better documentation.  Meanwhile, as
> the user manual says, the stuff about quoting names is described in a
> design note http://research.microsoft.com/~simonpj/tmp/notes2.ps

Thanks. With haddoc documentation it is quite easy to translate old 
names to new names and guess the meanning of others.

Next quiestion is: how do I debug my macros? When I make some error in 
my program, I get coredump (or the windows equivalent)?

--

-- 
Gracjan
Gracjan Polak | 20 Sep 11:42 2005

Re: Template Haskell and Types

Simon Peyton-Jones wrote:
> design note http://research.microsoft.com/~simonpj/tmp/notes2.ps

In the above paper there is something about 'giveUp'. Seems to quite 
useful, but there is no such thing in ghc 6.4.

Where did my giveUp go? And why?

--

-- 
Gracjan
Simon Peyton-Jones | 23 Sep 14:22 2005
Picon

RE: Template Haskell and Types

Hmm.  Q is a monad, so I think
	fail :: Monad m => String -> m a
will do the job.

'recover' should catch the exception, and let you try something else.

Simon

| -----Original Message-----
| From: Gracjan Polak [mailto:gracjan <at> acchsh.com]
| Sent: 20 September 2005 10:43
| To: Simon Peyton-Jones
| Cc: haskell-cafe <at> haskell.org
| Subject: Re: [Haskell-cafe] Template Haskell and Types
| 
| Simon Peyton-Jones wrote:
| > design note http://research.microsoft.com/~simonpj/tmp/notes2.ps
| 
| 
| In the above paper there is something about 'giveUp'. Seems to quite
| useful, but there is no such thing in ghc 6.4.
| 
| Where did my giveUp go? And why?
| 
| --
| Gracjan
Gracjan Polak | 26 Sep 10:36 2005

Re: Template Haskell and Types

Simon Peyton-Jones wrote:
> Hmm.  Q is a monad, so I think
> 	fail :: Monad m => String -> m a
> will do the job.
> 
> 'recover' should catch the exception, and let you try something else.

So I think I have bug report :)

Haskell-cafe is probably wrong place for this, where do I go now with my 
failing test cases?

--

-- 
Gracjan

> 
> Simon
> 
> | -----Original Message-----
> | From: Gracjan Polak [mailto:gracjan <at> acchsh.com]
> | Sent: 20 September 2005 10:43
> | To: Simon Peyton-Jones
> | Cc: haskell-cafe <at> haskell.org
> | Subject: Re: [Haskell-cafe] Template Haskell and Types
> | 
> | Simon Peyton-Jones wrote:
> | > design note http://research.microsoft.com/~simonpj/tmp/notes2.ps
> | 
> | 
> | In the above paper there is something about 'giveUp'. Seems to quite
(Continue reading)

Duncan Coutts | 26 Sep 10:58 2005
Picon
Picon

Re: Template Haskell and Types

On Mon, 2005-09-26 at 10:36 +0200, Gracjan Polak wrote:
> Simon Peyton-Jones wrote:
> > Hmm.  Q is a monad, so I think
> > 	fail :: Monad m => String -> m a
> > will do the job.
> > 
> > 'recover' should catch the exception, and let you try something else.
> 
> So I think I have bug report :)
> 
> Haskell-cafe is probably wrong place for this, where do I go now with my 
> failing test cases?

glasgow-haskell-bugs <at> haskell.org

or if it's not clear if it's a bug or not you could ask for advice on:

template-haskell <at> haskell.org
or

glasgow-haskell-users <at> haskell.org

Duncan

Gmane