I have a container Foldablefor as. One of the methods provided by class Foldablein BasicPreludeis elem :: (Eq a) => a -> t a -> Bool. Now for my container, I can implement elemmore efficiently than the default if mine ais an instance Ord, but only in this case.
Now I would like to have a more efficient one elemavailable, if possible, preferably with the same signature (that is, "transparently"). However, I can only see one way to do this, which requires an (Ord a)instance restriction Foldablefor my container, which does not make sense in the general case.
Is it possible for me to have specialized elemonly for cases when it ais Ord, and common elemfor others anyway? I do not mind using GHC extensions if necessary.
source
share