[Haskell-cafe] Automatically infer Newtype instance
KAction at gnu.org
Wed Apr 9 19:21:42 UTC 2014
* Alexander Solla <alex.solla at gmail.com> [2014-04-09 11:06:55-0700]
> On Wed, Apr 9, 2014 at 11:05 AM, Alexander Solla <alex.solla at gmail.com>wrote:
> > Try using scoped type variables, and explicitly declare the types for pack
> > and unpack at the call site:
> > instance (Newtype a b, Newtype b c) => Newtype a c where
> > pack = (pack :: b -> c)
> > . (pack :: a -> b)
> > Did I get those types right? They look free to me.
> Actually, I'm not sure if that will work. How will GHC know which b to
> choose for the pair a and c, unless there are functional dependencies on a
> and c?
In fact, in case of Newtype there is fundep:
class Newtype n o | n -> o where ...
so I should have c -> a. Unfortunatelly, somewhy it do not work.
But also I am interested in even more unsafe case, when there is no
Best regards, Dmitry Bogatov <KAction at gnu.org>,
Free Software supporter, esperantisto and netiquette guardian.
More information about the Haskell-Cafe