Re: Why not allow empty record updates?

2011-11-23 Thread Evan Laforge
> Another place this problem has come up for me is in wanting to ensure > representation sharing for values constructed by data constructors which > don't make use of their type parameters. A trivial example would be sharing > the representation of Nothing between all the Maybe types, or sharing th

Re: Why not allow empty record updates?

2011-11-16 Thread wren ng thornton
On 11/15/11 8:07 PM, wagne...@seas.upenn.edu wrote: Quoting wren ng thornton : So far I've just defined helper functions to adjust the phantom type[1], each of which is implemented by (\x -> x { foo = foo x }). It's a horrible hack, but at least it's hidden away in library functions instead of s

RE: Why not allow empty record updates?

2011-11-16 Thread Simon Peyton-Jones
| >> Trouble is, what type does this have? | >> f x = x {} | >> | >> Malcolm Wallace wrote: | > f :: a -> a | >> | >> Ian Lynagh wrote: | That wouldn't help the original poster, as it is incompatible with | f :: Foo Clean -> Foo Dirty There are several different thing

Re: Why not allow empty record updates?

2011-11-16 Thread Yitzchak Gale
I wrote: >> Yes. The translation of record updates given in the Report >> makes perfect sense for {}. It is only forbidden by >> "n >= 1", but no reason is given for that restriction. d wagner wrote: > It doesn't make sense to me. The translation explodes a value into a case > statement over its c

Re: Why not allow empty record updates?

2011-11-15 Thread Edward Kmett
Sent from my iPad On Nov 15, 2011, at 7:18 PM, wren ng thornton wrote: > On 11/15/11 12:33 PM, Yitzchak Gale wrote: >> Simon Peyton-Jones wrote: >> Trouble is, what type does this have? >> f x = x {} >> >> Malcolm Wallace wrote: > f :: a -> a >> >> Ian Lynagh wrote: That

Re: Why not allow empty record updates?

2011-11-15 Thread wren ng thornton
On 11/15/11 12:33 PM, Yitzchak Gale wrote: Simon Peyton-Jones wrote: Trouble is, what type does this have? f x = x {} Malcolm Wallace wrote: f :: a -> a Ian Lynagh wrote: That wouldn't help the original poster, as it is incompatible with f :: Foo Clean -> Foo Dirty Only because in t

Re: Why not allow empty record updates?

2011-11-15 Thread wagnerdm
Quoting Yitzchak Gale : Yes. The translation of record updates given in the Report makes perfect sense for {}. It is only forbidden by "n >= 1", but no reason is given for that restriction. It doesn't make sense to me. The translation explodes a value into a case statement over its construct

Re: Why not allow empty record updates?

2011-11-15 Thread Yitzchak Gale
Simon Peyton-Jones wrote: Trouble is, what type does this have?   f x = x {} Malcolm Wallace wrote: >>> f :: a -> a Ian Lynagh wrote: >> That wouldn't help the original poster, as it is incompatible with >> f :: Foo Clean -> Foo Dirty Only because in that expression the type of x is no

RE: Why not allow empty record updates?

2011-11-15 Thread Simon Peyton-Jones
| > > Trouble is, what type does this have? | > > | > > f x = x {} | > | > f :: a -> a | | That wouldn't help the original poster, as it is incompatible with | f :: Foo Clean -> Foo Dirty Ah! *That* is why I said it was awkward. Thanks Ian. Simon ___

RE: Why not allow empty record updates?

2011-11-15 Thread Simon Peyton-Jones
| To: Malcolm Wallace | Cc: GHC-users List | Subject: Re: Why not allow empty record updates? | | Simon Peyton-Jones wrote: | >> Trouble is, what type does this have? | >>       f x = x {} | | Malcolm Wallace wrote: | > Empty record patterns {} are permitted, even for types | > tha

Re: Why not allow empty record updates?

2011-11-15 Thread Ian Lynagh
On Tue, Nov 15, 2011 at 08:34:01AM +, Malcolm Wallace wrote: > > On 14 Nov 2011, at 22:09, Simon Peyton-Jones wrote: > > > Trouble is, what type does this have? > > > > f x = x {} > > f :: a -> a That wouldn't help the original poster, as it is incompatible with f :: Foo Clean -> Foo D

Re: Why not allow empty record updates?

2011-11-15 Thread Yitzchak Gale
Simon Peyton-Jones wrote: >> Trouble is, what type does this have? >>       f x = x {} Malcolm Wallace wrote: > Empty record patterns {} are permitted, even for types > that are not declared with named fields. > So I don't see why an empty record update should > require the type to be declared wit

Re: Why not allow empty record updates?

2011-11-15 Thread Malcolm Wallace
On 14 Nov 2011, at 22:09, Simon Peyton-Jones wrote: > Trouble is, what type does this have? > > f x = x {} f :: a -> a Empty record patterns {} are permitted, even for types that are not declared with named fields. So I don't see why an empty record update should require the type to b

RE: Why not allow empty record updates?

2011-11-14 Thread Simon Peyton-Jones
users- | boun...@haskell.org] On Behalf Of Herbert Valerio Riedel | Sent: 14 November 2011 14:31 | To: glasgow-haskell-users@haskell.org | Subject: Why not allow empty record updates? | | Hello GHC HQ, | | I have been toying with phantom types in combination with "polymorphic" |

Why not allow empty record updates?

2011-11-14 Thread Herbert Valerio Riedel
Hello GHC HQ, I have been toying with phantom types in combination with "polymorphic" record-updates (which is a great feature imho), but stumbled over a limitation: GHC doesn't allow empty record updates (see toy example below), and I couldn't find a GHC language extension to relax this constrain