[Haskell-cafe] Type error with Type families
Marco Túlio Pimenta Gontijo
marcotmarcot at gmail.com
Tue Sep 18 14:57:13 CEST 2012
On Mon, Sep 17, 2012 at 6:27 PM, Alexander Solla <alex.solla at gmail.com> wrote:
> On Mon, Sep 17, 2012 at 10:59 AM, Ryan Ingram <ryani.spam at gmail.com> wrote:
>> The problem is that the function 'element' is ambiguous, for the reasons
>> MigMit pointed out.
>> The standard solution to this problem is to add a dummy argument to fix
>> the type argument to the type function:
>> data Proxy a = Proxy
>> class ... => ReplaceOneOf full where
>> type Item full :: *
>> -- implementations can just ignore the first argument
>> element :: Proxy full -> Item full -> [Item full] -> Bool
>> replaceOneOf :: ...
>> | element (Proxy :: Proxy full) x from = ...
>> Now the choice of which 'element' to use can be determined by the type of
>> the proxy.
> It might be best if we point users to a "standard" Proxy type so we don't
> end up lots of packages defining distinct/incompatible types for the same
> Edward Kmett's "tagged" package has a Proxy type.
Thank you for your answers.
More information about the Haskell-Cafe