[Haskell-cafe] Automatically infer Newtype instance

Alexander Solla alex.solla at gmail.com
Wed Apr 9 18:06:55 UTC 2014


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?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140409/76a3516f/attachment.html>


More information about the Haskell-Cafe mailing list