[Haskell-cafe] Status of TypeDirectedNameResolution proposal?

David Menendez dave at zednenem.com
Wed Nov 18 16:29:57 EST 2009


On Wed, Nov 18, 2009 at 4:12 PM, Edward Kmett <ekmett at gmail.com> wrote:
>
> Qualified imports are some times problematic when you need to work with
> classes from the module. You can't define a member of two instances from
> different two modules that define classes with conflicting member names.
> This can lead to situations where you have no option but to have orphan
> instances.
>
> module Bar where
> class Foo a where
>    foo :: a
>
> module Baz where
> class Quux a where
>   foo :: a
>
> module Quaffle where
> import qualified Bar
> import qualified Baz
>
> instance Bar.Foo Int where
>   Bar.foo = 1
> -- ^- syntax error.
>
> instance Baz.Quux Int where
>   Baz.foo = 2
>
> I suppose this could possibly be fixed if something deep in the parser
> allowed a QName there.

Try Quaffle without the qualifications.

> module Quaffle where
> import qualified Bar
> import qualified Baz
>
> instance Bar.Foo Int where
>   foo = 1
>
> instance Baz.Quux Int where
>   foo = 2


-- 
Dave Menendez <dave at zednenem.com>
<http://www.eyrie.org/~zednenem/>


More information about the Haskell-Cafe mailing list