Re: Exposing newtype coercions to Haskell

2013-07-04 Thread Joachim Breitner
Hi, small update: I generalized the code at https://github.com/nomeata/nt-coerce/blob/9349dd3/GHC/NT/Plugin.hs a bit, it is now able to handle to create NT-values for unwarpping arbitrary newtypes and for lifting across type constructors. It does so unconditionally, i.e. does _not_ yet check wheth

Re: Exposing newtype coercions to Haskell

2013-07-03 Thread Joachim Breitner
Hi again, Am Mittwoch, den 03.07.2013, 10:01 +0200 schrieb Joachim Breitner: > Am Dienstag, den 02.07.2013, 16:28 + schrieb 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

RE: Exposing newtype coercions to Haskell

2013-07-03 Thread Simon Peyton-Jones
| Is this really the compiler’s job here? After all, the programmer would be able to | write | | deriving cNT' :: NT (Foo a) (Foo b) -> NT (C a) (C b) | cNT :: NT a b -> NT (C a) (C b) | cNT = cNT' . fooNT | | and expose just cNT to his users, so no expressiveness

Re: Exposing newtype coercions to Haskell

2013-07-03 Thread Nicolas Frisby
On Wed, Jul 3, 2013 at 5:33 AM, Joachim Breitner wrote: > [snip] > > strange, why did I miss that? > > But I can’t get [the GlobalRdrEnv lookup] to work, even looking up an > element that I took from > the GRE itself returns []: > > let e' = head (head (occEnvElts env)) > putMsgS $ showSDo

Re: Exposing newtype coercions to Haskell

2013-07-03 Thread Joachim Breitner
Hi, Am Dienstag, den 02.07.2013, 12:56 -0500 schrieb Nicolas Frisby: > For my light experimentation, I have recovered these two values from > the ModGuts that all plugins receive. Hopefully someone will shout out > if there's pitfalls to avoid. > > * The mg_rdr_env field is of type GlobalRdrEnv

Re: Exposing newtype coercions to Haskell

2013-07-03 Thread Joachim Breitner
Hi, Am Dienstag, den 02.07.2013, 16:28 + schrieb 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

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: Exposing newtype coercions to Haskell

2013-07-02 Thread Simon Peyton-Jones
ers- | boun...@haskell.org] On Behalf Of Joachim Breitner | Sent: 01 July 2013 13:00 | To: glasgow-haskell-users@haskell.org | Subject: Exposing newtype coercions to Haskell | | Hi, | | this is related to | http://hackage.haskell.org/trac/ghc/wiki/NewtypeWrappers#Proposal3. | I tried

Exposing newtype coercions to Haskell

2013-07-01 Thread Joachim Breitner
Hi, this is related to http://hackage.haskell.org/trac/ghc/wiki/NewtypeWrappers#Proposal3. I tried to hack up a little prototype of this, and this “works” now: import GHC.NT newtype Age = Age Int deriving Show ageNT :: NT Age Int ageNT = createNT