Re: [GHC] #7395: DefaultSignatures conflict with default implementations

#7395: DefaultSignatures conflict with default implementations -------------------------------------+------------------------------------- Reporter: cgaebel | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.1 Resolution: | Keywords: | DefaultSignatures Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: 7346 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by aspiwack): I found myself, today, in a situation where I wanted to have two default signatures, something like: {{{#!haskell {-# LANGUAGE DefaultSignatures #-} module Test where class Foo a where foo :: a default foo :: (a~Int) => a foo = 0 default foo :: (a~Bool) => a foo = False }}} The practical situation was that the second default implementation requires an extra `MonadIO m` constraint and is more efficient. My proposal is to resolve default implementation like overlapping instances: the default with the most specific type amongst the well-typed ones is used. The compiler can check, when creating the class that default implementations of a same method either don't unify or are strictly ordered with the specialisation order. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/7395#comment:19 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC