[Haskell-cafe] Type error with Type families
alex.solla at gmail.com
Mon Sep 17 23:27:20 CEST 2012
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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe