Roman Cheplyaka | 12 Mar 14:18 2013

newtype a Constraint?

Is there a way to newtype a constraint?

Imagine a type class parameterised over constraints. What do I do if I
want multiple instances for (essentially) the same constraint?

Roman
Gábor Lehel | 12 Mar 14:26 2013
Picon

Re: newtype a Constraint?

{-# LANGUAGE UndecidableInstances #-}

class OldConstraint a => NewtypedConstraint a
instance OldConstraint a => NewtypedConstraint a

perhaps?

Nice thing is you don't even need to do wrapping/unwrapping, like you do with data newtypes.


On Tue, Mar 12, 2013 at 2:18 PM, Roman Cheplyaka <roma <at> ro-che.info> wrote:
Is there a way to newtype a constraint?

Imagine a type class parameterised over constraints. What do I do if I
want multiple instances for (essentially) the same constraint?

Roman

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



--
Your ship was destroyed in a monadic eruption.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Roman Cheplyaka | 12 Mar 14:30 2013

Re: newtype a Constraint?

Neat, thanks!

Roman

* Gábor Lehel <illissius <at> gmail.com> [2013-03-12 14:26:38+0100]
> {-# LANGUAGE UndecidableInstances #-}
> 
> class OldConstraint a => NewtypedConstraint a
> instance OldConstraint a => NewtypedConstraint a
> 
> perhaps?
> 
> Nice thing is you don't even need to do wrapping/unwrapping, like you do
> with data newtypes.
> 
> 
> On Tue, Mar 12, 2013 at 2:18 PM, Roman Cheplyaka <roma <at> ro-che.info> wrote:
> 
> > Is there a way to newtype a constraint?
> >
> > Imagine a type class parameterised over constraints. What do I do if I
> > want multiple instances for (essentially) the same constraint?
> >
> > Roman
> >
> > _______________________________________________
> > Haskell-Cafe mailing list
> > Haskell-Cafe <at> haskell.org
> > http://www.haskell.org/mailman/listinfo/haskell-cafe
> >
> 
> 
> 
> -- 
> Your ship was destroyed in a monadic eruption.
Max Bolingbroke | 12 Mar 22:07 2013
Picon

Re: newtype a Constraint?

On 12 March 2013 13:18, Roman Cheplyaka <roma <at> ro-che.info> wrote:
> Is there a way to newtype a constraint?
>
> Imagine a type class parameterised over constraints. What do I do if I
> want multiple instances for (essentially) the same constraint?

It would make sense to add support for this to newtype directly. I
think it would also make sense to allow newtypes over types of kind #.
"All" that is required is some implementation effort: I looked into
doing this as part of the constraint kinds patches but it is a bit
messy.

Max

Gmane