Re: Overloaded record fields

2013-07-02 Thread Ryan Newton
+1 for orthogonal -XDotPostfixApply. I'm in the absolutely-love-using-dot-for-records camp, but I also like "foo s1.toUpper s2.toUpper". We're already so lazy about parentheses -- e.g. the non-haskellers I show code to are always appalled at $ ;-) -- and this helps scrap more parens! On Mon, J

Re: Exposing newtype coercions to Haskell

2013-07-02 Thread Nicolas Frisby
This is an exciting effort! Just a quick reaction to Simon's comments on CoreM. On Tue, Jul 2, 2013 at 9:11 AM, Simon Peyton-Jones wrote: > To your questions: > > ** > > **·**To do these kind of things, CoreM will need more reader > stuff. In particular: > > **o **The global TypeE

RE: Exposing newtype coercions to Haskell

2013-07-02 Thread Simon Peyton-Jones
| I also noticed a problem with my logic for creating the NT-lifting | function. Suppose | data C a = MkC (Foo a) | Just having the constructors of C in scope is not sufficient | to safely provide | NT a b -> NT (C a) (C b) | as the parameters of the constructor might wrap a in another

Re: Exposing newtype coercions to Haskell

2013-07-02 Thread Joachim Breitner
Hi, Am Dienstag, den 02.07.2013, 14:11 + schrieb Simon Peyton-Jones: > I'm not sure that a plugin is the way to go here, though it's a good > start. as I said, it is just to host the prototype that allows for quick experimentation and allows people to test it without having to compile GHC.

Re: Field accessor type inference woes

2013-07-02 Thread Twan van Laarhoven
On 02/07/13 10:57, Simon Peyton-Jones wrote: Here is Plan A: use fundep (or type function) class Has r f t | r f -> t where getFld :: r -> t instance Has (R a) “foo” (a -> a) where .. instance Has S “bar” (forall b. b -> b) where ... Lacking (as we still do) impredicative p

RE: Exposing newtype coercions to Haskell

2013-07-02 Thread Simon Peyton-Jones
Good stuff. The basic idea seems good to me. I'm not sure that a plugin is the way to go here, though it's a good start. ·Exactly which programs are type-correct? Eg coerce (listNT createNT) It all depends on exactly what type args createNT is applied to. ·A function f =

Re: Field accessor type inference woes

2013-07-02 Thread Edward Kmett
On Tue, Jul 2, 2013 at 4:53 AM, AntC wrote: > > > > I was envisaging that we might well need a functional dependency > > > > Hi Adam, Edward, (Simon), > > I think we should be really careful before introducing FunDeps (or type > functions). > > Can we get to the needed type inference with Undecid

Re: Field accessor type inference woes

2013-07-02 Thread Adam Gundry
Unfortunately, I don't think we get away with this... On 02/07/13 11:45, AntC wrote: > There's **three** alternatives. ... > >> >> data R a = MkR { foo :: a -> a } >> data S= MkS { bar :: forall b. b -> b } >> > > Try Plan C: use a cleverer (associated) type function >

Re: Field accessor type inference woes

2013-07-02 Thread AntC
> Simon Peyton-Jones microsoft.com> writes: > > ...; it’s a tradeoff between polymorphism and overloading. >   Hah! my post crossed with Simon's. This time I'll be succinct. There's **three** alternatives. ... > >   data R a = MkR { foo :: a -> a } >   data S    = MkS { bar ::

RE: Field accessor type inference woes

2013-07-02 Thread Simon Peyton-Jones
Edward, is quite right. Thank you for pointing this out; I hadn’t fully absorbed the consequences of the three-parameter Has class. This isn’t a fundep-vs-type-function thing; it’s a tradeoff between polymorphism and overloading. There seem to be two alternatives. I’ll use fundep notation j

Re: Field accessor type inference woes

2013-07-02 Thread AntC
> > I was envisaging that we might well need a functional dependency > Hi Adam, Edward, (Simon), I think we should be really careful before introducing FunDeps (or type functions). Can we get to the needed type inference with UndecidableInstances? Is that so bad? In the original SORF proposa