#define HAVE_GHC_GENERICS (__GLASGOW_HASKELL__ >= 704)
#if HAVE_GHC_GENERICS
#endif
module Data.Default.Class (
Default(..)
) where
import Data.Int
import Data.Word
import Data.Monoid
import Data.Ratio
import Data.Complex
import Foreign.C.Types
#if HAVE_GHC_GENERICS
import GHC.Generics
class GDefault f where
gdef :: f a
instance GDefault U1 where
gdef = U1
instance (Default a) => GDefault (K1 i a) where
gdef = K1 def
instance (GDefault a, GDefault b) => GDefault (a :*: b) where
gdef = gdef :*: gdef
instance (GDefault a) => GDefault (M1 i c a) where
gdef = M1 gdef
#endif
class Default a where
def :: a
#if HAVE_GHC_GENERICS
default def :: (Generic a, GDefault (Rep a)) => a
def = to gdef
#endif
instance Default Int where def = 0
instance Default Int8 where def = 0
instance Default Int16 where def = 0
instance Default Int32 where def = 0
instance Default Int64 where def = 0
instance Default Word where def = 0
instance Default Word8 where def = 0
instance Default Word16 where def = 0
instance Default Word32 where def = 0
instance Default Word64 where def = 0
instance Default Integer where def = 0
instance Default Float where def = 0
instance Default Double where def = 0
instance (Integral a) => Default (Ratio a) where def = 0
instance (Default a, RealFloat a) => Default (Complex a) where def = def :+ def
instance Default CShort where def = 0
instance Default CUShort where def = 0
instance Default CInt where def = 0
instance Default CUInt where def = 0
instance Default CLong where def = 0
instance Default CULong where def = 0
instance Default CLLong where def = 0
instance Default CULLong where def = 0
instance Default CPtrdiff where def = 0
instance Default CSize where def = 0
instance Default CSigAtomic where def = 0
instance Default CIntPtr where def = 0
instance Default CUIntPtr where def = 0
instance Default CIntMax where def = 0
instance Default CUIntMax where def = 0
instance Default CClock where def = 0
instance Default CTime where def = 0
#if MIN_VERSION_base(4, 4, 0)
instance Default CUSeconds where def = 0
instance Default CSUSeconds where def = 0
#endif
instance Default CFloat where def = 0
instance Default CDouble where def = 0
instance (Default r) => Default (e -> r) where def = const def
instance (Default a) => Default (IO a) where def = return def
instance Default (Maybe a) where def = Nothing
instance Default () where def = mempty
instance Default [a] where def = mempty
instance Default Ordering where def = mempty
instance Default Any where def = mempty
instance Default All where def = mempty
instance Default (Last a) where def = mempty
instance Default (First a) where def = mempty
instance (Num a) => Default (Sum a) where def = mempty
instance (Num a) => Default (Product a) where def = mempty
instance Default (Endo a) where def = mempty
instance (Default a) => Default (Dual a) where def = Dual def
instance (Default a, Default b) => Default (a, b) where def = (def, def)
instance (Default a, Default b, Default c) => Default (a, b, c) where def = (def, def, def)
instance (Default a, Default b, Default c, Default d) => Default (a, b, c, d) where def = (def, def, def, def)
instance (Default a, Default b, Default c, Default d, Default e) => Default (a, b, c, d, e) where def = (def, def, def, def, def)
instance (Default a, Default b, Default c, Default d, Default e, Default f) => Default (a, b, c, d, e, f) where def = (def, def, def, def, def, def)
instance (Default a, Default b, Default c, Default d, Default e, Default f, Default g) => Default (a, b, c, d, e, f, g) where def = (def, def, def, def, def, def, def)