MultiParamTypeClasses + ExtendedDefaultRules
-XExtendedDefaultRules allows us to avoid ambiguity for unannotated numeric literals:
{-# LANGUAGE ExtendedDefaultRules #-}
data A = A deriving Show
class ToA a where
toA :: a -> A
instance ToA Double where
toA _ = A
main = print (toA 5 :: A)
But if we have a multi-param typeclass, -XExtendedDefaultRules doesn't help us:
{-# LANGUAGE ExtendedDefaultRules #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleInstances #-}
data A x = A deriving Show
class ToA a x where
toA :: a -> A x
instance ToA Double x where
toA _ = A
main = print (toA 5 :: A Bool)
It would be really nice for an EDSL of mine to be able to use extended defaults here! At the moment my only option has been to use incoherent instances, which has resulted in incoherent behavior...