Re: Coercible class (Was: newtype wrappers)

2013-09-16 Thread Joachim Breitner
Hi, Am Montag, den 16.09.2013, 05:53 + schrieb Simon Peyton-Jones: a) A newtype can be casted only if its constructor is visible. b) Casting below a type constructor (instance Coercible a b = Coercible (Maybe a) (Maybe b)) is possible if the roles allow it; the constructor

Re: Coercible class (Was: newtype wrappers)

2013-09-15 Thread Richard Eisenberg
Very cool! In the feature as pushed, is it possible to use coerce on any old newtype? If so, then it really is a language feature and probably should go into the manual, if `coerce` is exposed. What was the end result of the discussion on abstraction? Can a library control how its types are

Re: Coercible class (Was: newtype wrappers)

2013-09-15 Thread Joachim Breitner
Hi, Am Sonntag, den 15.09.2013, 16:48 -0400 schrieb Richard Eisenberg: What was the end result of the discussion on abstraction? Can a library control how its types are coerced? there is no end result, as this is just a language feature. But the current state of affairs is that: * A newtype

Re: Coercible class (Was: newtype wrappers)

2013-09-15 Thread Richard Eisenberg
Because, from a user's point of view, defining newtype Age = MkAge Int automatically creates Coercible instances instance Coercible Age Int instance Coercible Int Age and defining datatypes also creates instances. This looks like a user-visible language feature to me, and I think it

Re: Coercible class (Was: newtype wrappers)

2013-09-15 Thread Joachim Breitner
Hi, Am Sonntag, den 15.09.2013, 17:24 -0400 schrieb Richard Eisenberg: Because, from a user's point of view, defining newtype Age = MkAge Int automatically creates Coercible instances instance Coercible Age Int instance Coercible Int Age and defining datatypes also creates

Re: Coercible class (Was: newtype wrappers)

2013-09-15 Thread Richard Eisenberg
On Sep 15, 2013, at 5:44 PM, Joachim Breitner m...@joachim-breitner.de wrote: not really; if you type :info Coercible you see that there are no instances created. Just the type-checking of uses of coerce is a bit special. Even stranger, I think. I understand that there aren't really any

Re: Coercible class (Was: newtype wrappers)

2013-09-15 Thread Richard Eisenberg
Great -- that makes a lot of sense to me. Sorry if you had to repeat yourself here. Does this mean that it is impossible to coerce a (Map String Int) to a (Map String Age) in Safe code? I expect so. I think this is suboptimal, but there might be a small way to patch this small weakness in the

Re: Coercible class (Was: newtype wrappers)

2013-09-15 Thread Joachim Breitner
Hi, Am Sonntag, den 15.09.2013, 17:49 -0400 schrieb Richard Eisenberg: To be clear, I'm not asking for an explanation for me -- I think I know what's going on here. Sorry if you got that impression; I have no doubt that you understand the feature (possibly better than me!) I just think that

RE: Coercible class (Was: newtype wrappers)

2013-09-15 Thread Simon Peyton-Jones
and David even want (c)/(3) for Safe Haskell! Simon | -Original Message- | From: ghc-devs [mailto:ghc-devs-boun...@haskell.org] On Behalf Of Richard | Eisenberg | Sent: 15 September 2013 22:57 | To: Joachim Breitner | Cc: ghc-devs@haskell.org | Subject: Re: Coercible class

RE: Coercible class (Was: newtype wrappers)

2013-09-15 Thread Simon Peyton-Jones
Richard raises a question about coherence below. (Coherence, not soundness.) But it's a coherence problem we already have. Given his Foo type, | data Foo a where-- a's role is representational; this is NOT a GADT | MkFoo :: Ord a = a - Foo a suppose we define bar ::

RE: Coercible class (Was: newtype wrappers)

2013-09-15 Thread Simon Peyton-Jones
instances of it (c) look in the user manual. Simon | -Original Message- | From: ghc-devs [mailto:ghc-devs-boun...@haskell.org] On Behalf Of Joachim | Breitner | Sent: 15 September 2013 22:57 | To: ghc-devs@haskell.org | Subject: Re: Coercible class (Was: newtype wrappers) | | Hi

Coercible class (Was: newtype wrappers)

2013-09-13 Thread Joachim Breitner
Hi, Am Montag, den 09.09.2013, 11:26 -0500 schrieb Austin Seipp: It sounds like Simon thinks your work is good to go, so when your tree is clean, feel free to push. done! Given that in the final form the feature, to the user, looks like a library and not a language extension, I decided to put