{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeSynonymInstances #-}

#if __GLASGOW_HASKELL__ >= 701
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE Trustworthy #-}
#endif

#if __GLASGOW_HASKELL__ >= 705
{-# LANGUAGE PolyKinds #-}
#endif

#include "HsBaseConfig.h"

module Generics.Deriving.Enum (

  -- * Generic enum class
    GEnum(..)

  -- * Default definitions for GEnum
  , genumDefault, toEnumDefault, fromEnumDefault

  -- * Internal enum class
  , Enum'(..)

  -- * Generic Ix class
  , GIx(..)

  -- * Default definitions for GIx
  , rangeDefault, indexDefault, inRangeDefault

  ) where

import           Control.Applicative (Const, ZipList)

import           Data.Int
import           Data.Monoid (All, Any, Dual, Product, Sum)
import qualified Data.Monoid as Monoid (First, Last)
import Data.Word

import           Foreign.C.Types
import           Foreign.Ptr

import           Generics.Deriving.Base
import           Generics.Deriving.Eq

import           System.Exit (ExitCode)
import           System.Posix.Types

#if MIN_VERSION_base(4,4,0)
import           Data.Complex (Complex)
#endif

#if MIN_VERSION_base(4,7,0)
import           Data.Coerce (coerce)
import           Data.Proxy (Proxy)
#else
import           Unsafe.Coerce (unsafeCoerce)
#endif

#if MIN_VERSION_base(4,8,0)
import           Data.Functor.Identity (Identity)
import           Data.Monoid (Alt)
import           Numeric.Natural (Natural)
#endif

#if MIN_VERSION_base(4,9,0)
import           Data.List.NonEmpty (NonEmpty)
import qualified Data.Semigroup as Semigroup (First, Last)
import           Data.Semigroup (Arg, Max, Min, WrappedMonoid)
#endif

-----------------------------------------------------------------------------
-- Utility functions for Enum'
-----------------------------------------------------------------------------

infixr 5 |||

-- | Interleave elements from two lists. Similar to (++), but swap left and
-- right arguments on every recursive application.
--
-- From Mark Jones' talk at AFP2008
(|||) :: [a] -> [a] -> [a]
[]     ||| :: forall a. [a] -> [a] -> [a]
||| [a]
ys = [a]
ys
(a
x:[a]
xs) ||| [a]
ys = a
x forall a. a -> [a] -> [a]
: [a]
ys forall a. [a] -> [a] -> [a]
||| [a]
xs

-- | Diagonalization of nested lists. Ensure that some elements from every
-- sublist will be included. Handles infinite sublists.
--
-- From Mark Jones' talk at AFP2008
diag :: [[a]] -> [a]
diag :: forall a. [[a]] -> [a]
diag = forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr forall a. [[a]] -> [[a]] -> [[a]]
skew [] forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> [a] -> [b]
map (forall a b. (a -> b) -> [a] -> [b]
map (\a
x -> [a
x]))

skew :: [[a]] -> [[a]] -> [[a]]
skew :: forall a. [[a]] -> [[a]] -> [[a]]
skew []     [[a]]
ys = [[a]]
ys
skew ([a]
x:[[a]]
xs) [[a]]
ys = [a]
x forall a. a -> [a] -> [a]
: forall a. (a -> a -> a) -> [a] -> [a] -> [a]
combine forall a. [a] -> [a] -> [a]
(++) [[a]]
xs [[a]]
ys

combine :: (a -> a -> a) -> [a] -> [a] -> [a]
combine :: forall a. (a -> a -> a) -> [a] -> [a] -> [a]
combine a -> a -> a
_ [a]
xs     []     = [a]
xs
combine a -> a -> a
_ []     [a]
ys     = [a]
ys
combine a -> a -> a
f (a
x:[a]
xs) (a
y:[a]
ys) = a -> a -> a
f a
x a
y forall a. a -> [a] -> [a]
: forall a. (a -> a -> a) -> [a] -> [a] -> [a]
combine a -> a -> a
f [a]
xs [a]
ys

findIndex :: (a -> Bool) -> [a] -> Maybe Int
findIndex :: forall a. (a -> Bool) -> [a] -> Maybe Int
findIndex a -> Bool
p [a]
xs = let l :: [Int]
l = [ Int
i | (a
y,Int
i) <- forall a b. [a] -> [b] -> [(a, b)]
zip [a]
xs [(Int
0::Int)..], a -> Bool
p a
y]
                 in if (forall (t :: * -> *) a. Foldable t => t a -> Bool
null [Int]
l)
                    then forall a. Maybe a
Nothing
                    else forall a. a -> Maybe a
Just (forall a. [a] -> a
head [Int]
l)

--------------------------------------------------------------------------------
-- Generic enum
--------------------------------------------------------------------------------

class Enum' f where
  enum' :: [f a]

instance Enum' U1 where
  enum' :: forall (a :: k). [U1 a]
enum' = [forall k (p :: k). U1 p
U1]

instance (GEnum c) => Enum' (K1 i c) where
  enum' :: forall (a :: k). [K1 i c a]
enum' = forall a b. (a -> b) -> [a] -> [b]
map forall k i c (p :: k). c -> K1 i c p
K1 forall a. GEnum a => [a]
genum

instance (Enum' f) => Enum' (M1 i c f) where
  enum' :: forall (a :: k). [M1 i c f a]
enum' = forall a b. (a -> b) -> [a] -> [b]
map forall k i (c :: Meta) (f :: k -> *) (p :: k). f p -> M1 i c f p
M1 forall {k} (f :: k -> *) (a :: k). Enum' f => [f a]
enum'

instance (Enum' f, Enum' g) => Enum' (f :+: g) where
  enum' :: forall (a :: k). [(:+:) f g a]
enum' = forall a b. (a -> b) -> [a] -> [b]
map forall k (f :: k -> *) (g :: k -> *) (p :: k). f p -> (:+:) f g p
L1 forall {k} (f :: k -> *) (a :: k). Enum' f => [f a]
enum' forall a. [a] -> [a] -> [a]
||| forall a b. (a -> b) -> [a] -> [b]
map forall k (f :: k -> *) (g :: k -> *) (p :: k). g p -> (:+:) f g p
R1 forall {k} (f :: k -> *) (a :: k). Enum' f => [f a]
enum'

instance (Enum' f, Enum' g) => Enum' (f :*: g) where
  enum' :: forall (a :: k). [(:*:) f g a]
enum' = forall a. [[a]] -> [a]
diag [ [ f a
x forall k (f :: k -> *) (g :: k -> *) (p :: k).
f p -> g p -> (:*:) f g p
:*: g a
y | g a
y <- forall {k} (f :: k -> *) (a :: k). Enum' f => [f a]
enum' ] | f a
x <- forall {k} (f :: k -> *) (a :: k). Enum' f => [f a]
enum' ]

genumDefault :: (Generic a, Enum' (Rep a)) => [a]
genumDefault :: forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault = forall a b. (a -> b) -> [a] -> [b]
map forall a x. Generic a => Rep a x -> a
to forall {k} (f :: k -> *) (a :: k). Enum' f => [f a]
enum'

toEnumDefault :: (Generic a, Enum' (Rep a)) => Int -> a
toEnumDefault :: forall a. (Generic a, Enum' (Rep a)) => Int -> a
toEnumDefault Int
i = let l :: [Rep a a]
l = forall {k} (f :: k -> *) (a :: k). Enum' f => [f a]
enum'
                  in if (forall (t :: * -> *) a. Foldable t => t a -> Int
length forall {a}. [Rep a a]
l forall a. Ord a => a -> a -> Bool
> Int
i)
                      then forall a x. Generic a => Rep a x -> a
to (forall {a}. [Rep a a]
l forall a. [a] -> Int -> a
!! Int
i)
                       else forall a. HasCallStack => [Char] -> a
error [Char]
"toEnum: invalid index"

fromEnumDefault :: (GEq a, Generic a, Enum' (Rep a))
                => a -> Int
fromEnumDefault :: forall a. (GEq a, Generic a, Enum' (Rep a)) => a -> Int
fromEnumDefault a
x = case forall a. (a -> Bool) -> [a] -> Maybe Int
findIndex (forall a. GEq a => a -> a -> Bool
geq a
x) (forall a b. (a -> b) -> [a] -> [b]
map forall a x. Generic a => Rep a x -> a
to forall {k} (f :: k -> *) (a :: k). Enum' f => [f a]
enum') of
      Maybe Int
Nothing -> forall a. HasCallStack => [Char] -> a
error [Char]
"fromEnum: no corresponding index"
      Just Int
i  -> Int
i


class GEnum a where
  genum :: [a]

#if __GLASGOW_HASKELL__ >= 701
  default genum :: (Generic a, Enum' (Rep a)) => [a]
  genum = forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault
#endif

genumNumUnbounded :: Num a => [a]
genumNumUnbounded :: forall a. Num a => [a]
genumNumUnbounded = forall {t}. Num t => t -> [t]
pos a
0 forall a. [a] -> [a] -> [a]
||| forall {t}. Num t => t -> [t]
neg a
0 where
  pos :: t -> [t]
pos t
n = t
n     forall a. a -> [a] -> [a]
: t -> [t]
pos (t
n forall a. Num a => a -> a -> a
+ t
1)
  neg :: t -> [t]
neg t
n = (t
nforall a. Num a => a -> a -> a
-t
1) forall a. a -> [a] -> [a]
: t -> [t]
neg (t
n forall a. Num a => a -> a -> a
- t
1)

genumNumSigned :: (Bounded a, Enum a, Num a) => [a]
genumNumSigned :: forall a. (Bounded a, Enum a, Num a) => [a]
genumNumSigned = [a
0 .. forall a. Bounded a => a
maxBound] forall a. [a] -> [a] -> [a]
||| [-a
1, -a
2 .. forall a. Bounded a => a
minBound]

genumNumUnsigned :: (Enum a, Num a) => [a]
genumNumUnsigned :: forall a. (Enum a, Num a) => [a]
genumNumUnsigned = [a
0 ..]

#if !(MIN_VERSION_base(4,7,0))
coerce :: a -> b
coerce = unsafeCoerce
#endif

-- Base types instances
instance GEnum () where
  genum :: [()]
genum = forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault

instance (GEnum a, GEnum b) => GEnum (a, b) where
  genum :: [(a, b)]
genum = forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault

instance (GEnum a, GEnum b, GEnum c) => GEnum (a, b, c) where
  genum :: [(a, b, c)]
genum = forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault

instance (GEnum a, GEnum b, GEnum c, GEnum d) => GEnum (a, b, c, d) where
  genum :: [(a, b, c, d)]
genum = forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault

instance (GEnum a, GEnum b, GEnum c, GEnum d, GEnum e) => GEnum (a, b, c, d, e) where
  genum :: [(a, b, c, d, e)]
genum = forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault

instance (GEnum a, GEnum b, GEnum c, GEnum d, GEnum e, GEnum f)
    => GEnum (a, b, c, d, e, f) where
  genum :: [(a, b, c, d, e, f)]
genum = forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault

instance (GEnum a, GEnum b, GEnum c, GEnum d, GEnum e, GEnum f, GEnum g)
    => GEnum (a, b, c, d, e, f, g) where
  genum :: [(a, b, c, d, e, f, g)]
genum = forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault

instance GEnum a => GEnum [a] where
  genum :: [[a]]
genum = forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault

instance (GEnum (f p), GEnum (g p)) => GEnum ((f :+: g) p) where
  genum :: [(:+:) f g p]
genum = forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault

instance (GEnum (f p), GEnum (g p)) => GEnum ((f :*: g) p) where
  genum :: [(:*:) f g p]
genum = forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault

instance GEnum (f (g p)) => GEnum ((f :.: g) p) where
  genum :: [(:.:) f g p]
genum = forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault

instance GEnum All where
  genum :: [All]
genum = forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault

#if MIN_VERSION_base(4,8,0)
instance GEnum (f a) => GEnum (Alt f a) where
  genum :: [Alt f a]
genum = forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault
#endif

instance GEnum Any where
  genum :: [Any]
genum = forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault

#if MIN_VERSION_base(4,9,0)
instance (GEnum a, GEnum b) => GEnum (Arg a b) where
  genum :: [Arg a b]
genum = forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault
#endif

#if !(MIN_VERSION_base(4,9,0))
instance GEnum Arity where
  genum = genumDefault
#endif

instance GEnum Associativity where
  genum :: [Associativity]
genum = forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault

instance GEnum Bool where
  genum :: [Bool]
genum = forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault

#if defined(HTYPE_CC_T)
instance GEnum CCc where
  genum :: [CCc]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [HTYPE_CC_T])
#endif

instance GEnum CChar where
  genum :: [CChar]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [HTYPE_CHAR])

instance GEnum CClock where
  genum :: [CClock]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [HTYPE_CLOCK_T])

#if defined(HTYPE_DEV_T)
instance GEnum CDev where
  genum :: [CDev]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [HTYPE_DEV_T])
#endif

instance GEnum CDouble where
  genum :: [CDouble]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [HTYPE_DOUBLE])

instance GEnum CFloat where
  genum :: [CFloat]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [HTYPE_FLOAT])

#if defined(HTYPE_GID_T)
instance GEnum CGid where
  genum :: [CGid]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [HTYPE_GID_T])
#endif

#if defined(HTYPE_INO_T)
instance GEnum CIno where
  genum :: [CIno]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [HTYPE_INO_T])
#endif

instance GEnum CInt where
  genum :: [CInt]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [HTYPE_INT])

instance GEnum CIntMax where
  genum :: [CIntMax]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [HTYPE_INTMAX_T])

instance GEnum CIntPtr where
  genum :: [CIntPtr]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [HTYPE_INTPTR_T])

instance GEnum CLLong where
  genum :: [CLLong]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [HTYPE_LONG_LONG])

instance GEnum CLong where
  genum :: [CLong]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [HTYPE_LONG])

#if defined(HTYPE_MODE_T)
instance GEnum CMode where
  genum :: [CMode]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [HTYPE_MODE_T])
#endif

#if defined(HTYPE_NLINK_T)
instance GEnum CNlink where
  genum :: [CNlink]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [HTYPE_NLINK_T])
#endif

#if defined(HTYPE_OFF_T)
instance GEnum COff where
  genum :: [COff]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [HTYPE_OFF_T])
#endif

#if MIN_VERSION_base(4,4,0)
instance GEnum a => GEnum (Complex a) where
  genum :: [Complex a]
genum = forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault
#endif

instance GEnum a => GEnum (Const a b) where
  genum :: [Const a b]
genum = forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault

#if defined(HTYPE_PID_T)
instance GEnum CPid where
  genum :: [CPid]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [HTYPE_PID_T])
#endif

instance GEnum CPtrdiff where
  genum :: [CPtrdiff]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [HTYPE_PTRDIFF_T])

#if defined(HTYPE_RLIM_T)
instance GEnum CRLim where
  genum :: [CRLim]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [HTYPE_RLIM_T])
#endif

instance GEnum CSChar where
  genum :: [CSChar]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [HTYPE_SIGNED_CHAR])

#if defined(HTYPE_SPEED_T)
instance GEnum CSpeed where
  genum :: [CSpeed]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [HTYPE_SPEED_T])
#endif

#if MIN_VERSION_base(4,4,0)
instance GEnum CSUSeconds where
  genum :: [CSUSeconds]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [HTYPE_SUSECONDS_T])
#endif

instance GEnum CShort where
  genum :: [CShort]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [HTYPE_SHORT])

instance GEnum CSigAtomic where
  genum :: [CSigAtomic]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [HTYPE_SIG_ATOMIC_T])

instance GEnum CSize where
  genum :: [CSize]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [HTYPE_SIZE_T])

#if defined(HTYPE_SSIZE_T)
instance GEnum CSsize where
  genum :: [CSsize]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [HTYPE_SSIZE_T])
#endif

#if defined(HTYPE_TCFLAG_T)
instance GEnum CTcflag where
  genum :: [CTcflag]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [HTYPE_TCFLAG_T])
#endif

instance GEnum CTime where
  genum :: [CTime]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [HTYPE_TIME_T])

instance GEnum CUChar where
  genum :: [CUChar]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [HTYPE_UNSIGNED_CHAR])

#if defined(HTYPE_UID_T)
instance GEnum CUid where
  genum :: [CUid]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [HTYPE_UID_T])
#endif

instance GEnum CUInt where
  genum :: [CUInt]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [HTYPE_UNSIGNED_INT])

instance GEnum CUIntMax where
  genum :: [CUIntMax]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [HTYPE_UINTMAX_T])

instance GEnum CUIntPtr where
  genum :: [CUIntPtr]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [HTYPE_UINTPTR_T])

instance GEnum CULLong where
  genum :: [CULLong]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [HTYPE_UNSIGNED_LONG_LONG])

instance GEnum CULong where
  genum :: [CULong]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [HTYPE_UNSIGNED_LONG])

#if MIN_VERSION_base(4,4,0)
instance GEnum CUSeconds where
  genum :: [CUSeconds]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [HTYPE_USECONDS_T])
#endif

instance GEnum CUShort where
  genum :: [CUShort]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [HTYPE_UNSIGNED_SHORT])

instance GEnum CWchar where
  genum :: [CWchar]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [HTYPE_WCHAR_T])

instance GEnum Double where
  genum :: [Double]
genum = forall a. Num a => [a]
genumNumUnbounded

instance GEnum a => GEnum (Dual a) where
  genum :: [Dual a]
genum = forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault

instance (GEnum a, GEnum b) => GEnum (Either a b) where
  genum :: [Either a b]
genum = forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault

instance GEnum ExitCode where
  genum :: [ExitCode]
genum = forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault

instance GEnum Fd where
  genum :: [Fd]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [CInt])

instance GEnum a => GEnum (Monoid.First a) where
  genum :: [First a]
genum = forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault

#if MIN_VERSION_base(4,9,0)
instance GEnum a => GEnum (Semigroup.First a) where
  genum :: [First a]
genum = forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault
#endif

instance GEnum Fixity where
  genum :: [Fixity]
genum = forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault

instance GEnum Float where
  genum :: [Float]
genum = forall a. Num a => [a]
genumNumUnbounded

#if MIN_VERSION_base(4,8,0)
instance GEnum a => GEnum (Identity a) where
  genum :: [Identity a]
genum = forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault
#endif

instance GEnum Int where
  genum :: [Int]
genum = forall a. (Bounded a, Enum a, Num a) => [a]
genumNumSigned

instance GEnum Int8 where
  genum :: [Int8]
genum = forall a. (Bounded a, Enum a, Num a) => [a]
genumNumSigned

instance GEnum Int16 where
  genum :: [Int16]
genum = forall a. (Bounded a, Enum a, Num a) => [a]
genumNumSigned

instance GEnum Int32 where
  genum :: [Int32]
genum = forall a. (Bounded a, Enum a, Num a) => [a]
genumNumSigned

instance GEnum Int64 where
  genum :: [Int64]
genum = forall a. (Bounded a, Enum a, Num a) => [a]
genumNumSigned

instance GEnum Integer where
  genum :: [Integer]
genum = forall a. Num a => [a]
genumNumUnbounded

instance GEnum IntPtr where
  genum :: [IntPtr]
genum = forall a. (Bounded a, Enum a, Num a) => [a]
genumNumSigned

instance GEnum c => GEnum (K1 i c p) where
  genum :: [K1 i c p]
genum = forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault

instance GEnum a => GEnum (Monoid.Last a) where
  genum :: [Last a]
genum = forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault

#if MIN_VERSION_base(4,9,0)
instance GEnum a => GEnum (Semigroup.Last a) where
  genum :: [Last a]
genum = forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault
#endif

instance GEnum (f p) => GEnum (M1 i c f p) where
  genum :: [M1 i c f p]
genum = forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault

#if MIN_VERSION_base(4,9,0)
instance GEnum a => GEnum (Max a) where
  genum :: [Max a]
genum = forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault
#endif

instance GEnum a => GEnum (Maybe a) where
  genum :: [Maybe a]
genum = forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault

#if MIN_VERSION_base(4,9,0)
instance GEnum a => GEnum (Min a) where
  genum :: [Min a]
genum = forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault
#endif

#if MIN_VERSION_base(4,8,0)
instance GEnum Natural where
  genum :: [Natural]
genum = forall a. (Enum a, Num a) => [a]
genumNumUnsigned
#endif

#if MIN_VERSION_base(4,9,0)
instance GEnum a => GEnum (NonEmpty a) where
  genum :: [NonEmpty a]
genum = forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault
#endif

instance GEnum Ordering where
  genum :: [Ordering]
genum = forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault

instance GEnum p => GEnum (Par1 p) where
  genum :: [Par1 p]
genum = forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault

instance GEnum a => GEnum (Product a) where
  genum :: [Product a]
genum = forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault

#if MIN_VERSION_base(4,7,0)
instance GEnum
# if MIN_VERSION_base(4,9,0)
               (Proxy s)
# else
               (Proxy (s :: *))
# endif
               where
  genum :: [Proxy s]
genum = forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault
#endif

instance GEnum (f p) => GEnum (Rec1 f p) where
  genum :: [Rec1 f p]
genum = forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault

instance GEnum a => GEnum (Sum a) where
  genum :: [Sum a]
genum = forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault

instance GEnum (U1 p) where
  genum :: [U1 p]
genum = forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault

instance GEnum Word where
  genum :: [Word]
genum = forall a. (Enum a, Num a) => [a]
genumNumUnsigned

instance GEnum Word8 where
  genum :: [Word8]
genum = forall a. (Enum a, Num a) => [a]
genumNumUnsigned

instance GEnum Word16 where
  genum :: [Word16]
genum = forall a. (Enum a, Num a) => [a]
genumNumUnsigned

instance GEnum Word32 where
  genum :: [Word32]
genum = forall a. (Enum a, Num a) => [a]
genumNumUnsigned

instance GEnum Word64 where
  genum :: [Word64]
genum = forall a. (Enum a, Num a) => [a]
genumNumUnsigned

instance GEnum WordPtr where
  genum :: [WordPtr]
genum = forall a. (Enum a, Num a) => [a]
genumNumUnsigned

#if MIN_VERSION_base(4,9,0)
instance GEnum m => GEnum (WrappedMonoid m) where
  genum :: [WrappedMonoid m]
genum = forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault
#endif

instance GEnum a => GEnum (ZipList a) where
  genum :: [ZipList a]
genum = forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault

#if MIN_VERSION_base(4,10,0)
instance GEnum CBool where
  genum :: [CBool]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [HTYPE_BOOL])

# if defined(HTYPE_BLKSIZE_T)
instance GEnum CBlkSize where
  genum :: [CBlkSize]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [HTYPE_BLKSIZE_T])
# endif

# if defined(HTYPE_BLKCNT_T)
instance GEnum CBlkCnt where
  genum :: [CBlkCnt]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [HTYPE_BLKCNT_T])
# endif

# if defined(HTYPE_CLOCKID_T)
instance GEnum CClockId where
  genum :: [CClockId]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [HTYPE_CLOCKID_T])
# endif

# if defined(HTYPE_FSBLKCNT_T)
instance GEnum CFsBlkCnt where
  genum :: [CFsBlkCnt]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [HTYPE_FSBLKCNT_T])
# endif

# if defined(HTYPE_FSFILCNT_T)
instance GEnum CFsFilCnt where
  genum :: [CFsFilCnt]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [HTYPE_FSFILCNT_T])
# endif

# if defined(HTYPE_ID_T)
instance GEnum CId where
  genum :: [CId]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [HTYPE_ID_T])
# endif

# if defined(HTYPE_KEY_T)
instance GEnum CKey where
  genum :: [CKey]
genum = coerce :: forall a b. Coercible a b => a -> b
coerce (forall a. GEnum a => [a]
genum :: [HTYPE_KEY_T])
# endif
#endif

--------------------------------------------------------------------------------
-- Generic Ix
--------------------------------------------------------------------------------

-- Minimal complete instance: 'range', 'index' and 'inRange'.
class (Ord a) => GIx a where
    -- | The list of values in the subrange defined by a bounding pair.
    range               :: (a,a) -> [a]
    -- | The position of a subscript in the subrange.
    index               :: (a,a) -> a -> Int
    -- | Returns 'True' the given subscript lies in the range defined
    -- the bounding pair.
    inRange             :: (a,a) -> a -> Bool
#if __GLASGOW_HASKELL__ >= 701
    default range :: (GEq a, Generic a, Enum' (Rep a)) => (a,a) -> [a]
    range = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault

    default index :: (GEq a, Generic a, Enum' (Rep a)) => (a,a) -> a -> Int
    index = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault

    default inRange :: (GEq a, Generic a, Enum' (Rep a)) => (a,a) -> a -> Bool
    inRange = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Bool
inRangeDefault
#endif

rangeDefault :: (GEq a, Generic a, Enum' (Rep a))
             => (a,a) -> [a]
rangeDefault :: forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault = forall {a}. GEq a => [a] -> (a, a) -> [a]
t (forall a b. (a -> b) -> [a] -> [b]
map forall a x. Generic a => Rep a x -> a
to forall {k} (f :: k -> *) (a :: k). Enum' f => [f a]
enum') where
  t :: [a] -> (a, a) -> [a]
t [a]
l (a
x,a
y) =
    case (forall a. (a -> Bool) -> [a] -> Maybe Int
findIndex (forall a. GEq a => a -> a -> Bool
geq a
x) [a]
l, forall a. (a -> Bool) -> [a] -> Maybe Int
findIndex (forall a. GEq a => a -> a -> Bool
geq a
y) [a]
l) of
      (Maybe Int
Nothing, Maybe Int
_)     -> forall a. HasCallStack => [Char] -> a
error [Char]
"rangeDefault: no corresponding index"
      (Maybe Int
_, Maybe Int
Nothing)     -> forall a. HasCallStack => [Char] -> a
error [Char]
"rangeDefault: no corresponding index"
      (Just Int
i, Just Int
j) -> forall a. Int -> [a] -> [a]
take (Int
jforall a. Num a => a -> a -> a
-Int
i) (forall a. Int -> [a] -> [a]
drop Int
i [a]
l)

indexDefault :: (GEq a, Generic a, Enum' (Rep a))
             => (a,a) -> a -> Int
indexDefault :: forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault = forall {a}. GEq a => [a] -> (a, a) -> a -> Int
t (forall a b. (a -> b) -> [a] -> [b]
map forall a x. Generic a => Rep a x -> a
to forall {k} (f :: k -> *) (a :: k). Enum' f => [f a]
enum') where
  t :: [a] -> (a, a) -> a -> Int
t [a]
l (a
x,a
y) a
z =
    case (forall a. (a -> Bool) -> [a] -> Maybe Int
findIndex (forall a. GEq a => a -> a -> Bool
geq a
x) [a]
l, forall a. (a -> Bool) -> [a] -> Maybe Int
findIndex (forall a. GEq a => a -> a -> Bool
geq a
y) [a]
l) of
      (Maybe Int
Nothing, Maybe Int
_)     -> forall a. HasCallStack => [Char] -> a
error [Char]
"indexDefault: no corresponding index"
      (Maybe Int
_, Maybe Int
Nothing)     -> forall a. HasCallStack => [Char] -> a
error [Char]
"indexDefault: no corresponding index"
      (Just Int
i, Just Int
j) -> case forall a. (a -> Bool) -> [a] -> Maybe Int
findIndex (forall a. GEq a => a -> a -> Bool
geq a
z) (forall a. Int -> [a] -> [a]
take (Int
jforall a. Num a => a -> a -> a
-Int
i) (forall a. Int -> [a] -> [a]
drop Int
i [a]
l)) of
                            Maybe Int
Nothing -> forall a. HasCallStack => [Char] -> a
error [Char]
"indexDefault: index out of range"
                            Just Int
k  -> Int
k

inRangeDefault :: (GEq a, Generic a, Enum' (Rep a))
               => (a,a) -> a -> Bool
inRangeDefault :: forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Bool
inRangeDefault = forall {a}. GEq a => [a] -> (a, a) -> a -> Bool
t (forall a b. (a -> b) -> [a] -> [b]
map forall a x. Generic a => Rep a x -> a
to forall {k} (f :: k -> *) (a :: k). Enum' f => [f a]
enum') where
  t :: [a] -> (a, a) -> a -> Bool
t [a]
l (a
x,a
y) a
z =
    case (forall a. (a -> Bool) -> [a] -> Maybe Int
findIndex (forall a. GEq a => a -> a -> Bool
geq a
x) [a]
l, forall a. (a -> Bool) -> [a] -> Maybe Int
findIndex (forall a. GEq a => a -> a -> Bool
geq a
y) [a]
l) of
      (Maybe Int
Nothing, Maybe Int
_)     -> forall a. HasCallStack => [Char] -> a
error [Char]
"indexDefault: no corresponding index"
      (Maybe Int
_, Maybe Int
Nothing)     -> forall a. HasCallStack => [Char] -> a
error [Char]
"indexDefault: no corresponding index"
      (Just Int
i, Just Int
j) -> forall b a. b -> (a -> b) -> Maybe a -> b
maybe Bool
False (forall a b. a -> b -> a
const Bool
True)
                            (forall a. (a -> Bool) -> [a] -> Maybe Int
findIndex (forall a. GEq a => a -> a -> Bool
geq a
z) (forall a. Int -> [a] -> [a]
take (Int
jforall a. Num a => a -> a -> a
-Int
i) (forall a. Int -> [a] -> [a]
drop Int
i [a]
l)))

rangeEnum :: Enum a => (a, a) -> [a]
rangeEnum :: forall a. Enum a => (a, a) -> [a]
rangeEnum (a
m,a
n) = [a
m..a
n]

indexIntegral :: Integral a => (a, a) -> a -> Int
indexIntegral :: forall a. Integral a => (a, a) -> a -> Int
indexIntegral (a
m,a
_n) a
i = forall a b. (Integral a, Num b) => a -> b
fromIntegral (a
i forall a. Num a => a -> a -> a
- a
m)

inRangeOrd :: Ord a => (a, a) -> a -> Bool
inRangeOrd :: forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd (a
m,a
n) a
i =  a
m forall a. Ord a => a -> a -> Bool
<= a
i Bool -> Bool -> Bool
&& a
i forall a. Ord a => a -> a -> Bool
<= a
n

-- Base types instances
instance GIx () where
  range :: ((), ()) -> [()]
range   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: ((), ()) -> () -> Int
index   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: ((), ()) -> () -> Bool
inRange = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Bool
inRangeDefault

instance (GEq a, GEnum a, GIx a, GEq b, GEnum b, GIx b) => GIx (a, b) where
  range :: ((a, b), (a, b)) -> [(a, b)]
range   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: ((a, b), (a, b)) -> (a, b) -> Int
index   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: ((a, b), (a, b)) -> (a, b) -> Bool
inRange = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Bool
inRangeDefault

instance (GEq a, GEnum a, GIx a, GEq b, GEnum b, GIx b, GEq c, GEnum c, GIx c)
    => GIx (a, b, c) where
  range :: ((a, b, c), (a, b, c)) -> [(a, b, c)]
range   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: ((a, b, c), (a, b, c)) -> (a, b, c) -> Int
index   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: ((a, b, c), (a, b, c)) -> (a, b, c) -> Bool
inRange = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Bool
inRangeDefault

instance (GEq a, GEnum a, GIx a, GEq b, GEnum b, GIx b, GEq c, GEnum c, GIx c,
          GEq d, GEnum d, GIx d)
    => GIx (a, b, c, d) where
  range :: ((a, b, c, d), (a, b, c, d)) -> [(a, b, c, d)]
range   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: ((a, b, c, d), (a, b, c, d)) -> (a, b, c, d) -> Int
index   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: ((a, b, c, d), (a, b, c, d)) -> (a, b, c, d) -> Bool
inRange = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Bool
inRangeDefault

instance (GEq a, GEnum a, GIx a, GEq b, GEnum b, GIx b, GEq c, GEnum c, GIx c,
          GEq d, GEnum d, GIx d, GEq e, GEnum e, GIx e)
    => GIx (a, b, c, d, e) where
  range :: ((a, b, c, d, e), (a, b, c, d, e)) -> [(a, b, c, d, e)]
range   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: ((a, b, c, d, e), (a, b, c, d, e)) -> (a, b, c, d, e) -> Int
index   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: ((a, b, c, d, e), (a, b, c, d, e)) -> (a, b, c, d, e) -> Bool
inRange = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Bool
inRangeDefault

instance (GEq a, GEnum a, GIx a, GEq b, GEnum b, GIx b, GEq c, GEnum c, GIx c,
          GEq d, GEnum d, GIx d, GEq e, GEnum e, GIx e, GEq f, GEnum f, GIx f)
    => GIx (a, b, c, d, e, f) where
  range :: ((a, b, c, d, e, f), (a, b, c, d, e, f)) -> [(a, b, c, d, e, f)]
range   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: ((a, b, c, d, e, f), (a, b, c, d, e, f))
-> (a, b, c, d, e, f) -> Int
index   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: ((a, b, c, d, e, f), (a, b, c, d, e, f))
-> (a, b, c, d, e, f) -> Bool
inRange = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Bool
inRangeDefault

instance (GEq a, GEnum a, GIx a, GEq b, GEnum b, GIx b, GEq c, GEnum c, GIx c,
          GEq d, GEnum d, GIx d, GEq e, GEnum e, GIx e, GEq f, GEnum f, GIx f,
          GEq g, GEnum g, GIx g)
    => GIx (a, b, c, d, e, f, g) where
  range :: ((a, b, c, d, e, f, g), (a, b, c, d, e, f, g))
-> [(a, b, c, d, e, f, g)]
range   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: ((a, b, c, d, e, f, g), (a, b, c, d, e, f, g))
-> (a, b, c, d, e, f, g) -> Int
index   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: ((a, b, c, d, e, f, g), (a, b, c, d, e, f, g))
-> (a, b, c, d, e, f, g) -> Bool
inRange = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Bool
inRangeDefault

instance (GEq a, GEnum a, GIx a) => GIx [a] where
  range :: ([a], [a]) -> [[a]]
range   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: ([a], [a]) -> [a] -> Int
index   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: ([a], [a]) -> [a] -> Bool
inRange = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Bool
inRangeDefault

instance GIx All where
  range :: (All, All) -> [All]
range   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: (All, All) -> All -> Int
index   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: (All, All) -> All -> Bool
inRange = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Bool
inRangeDefault

#if MIN_VERSION_base(4,8,0)
instance (GEq (f a), GEnum (f a), GIx (f a)) => GIx (Alt f a) where
  range :: (Alt f a, Alt f a) -> [Alt f a]
range   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: (Alt f a, Alt f a) -> Alt f a -> Int
index   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: (Alt f a, Alt f a) -> Alt f a -> Bool
inRange = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Bool
inRangeDefault
#endif

instance GIx Any where
  range :: (Any, Any) -> [Any]
range   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: (Any, Any) -> Any -> Int
index   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: (Any, Any) -> Any -> Bool
inRange = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Bool
inRangeDefault

#if MIN_VERSION_base(4,9,0)
instance (GEq a, GEnum a, GIx a, GEnum b) => GIx (Arg a b) where
  range :: (Arg a b, Arg a b) -> [Arg a b]
range   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: (Arg a b, Arg a b) -> Arg a b -> Int
index   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: (Arg a b, Arg a b) -> Arg a b -> Bool
inRange = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Bool
inRangeDefault
#endif

#if !(MIN_VERSION_base(4,9,0))
instance GIx Arity where
  range   = rangeDefault
  index   = indexDefault
  inRange = inRangeDefault
#endif

instance GIx Associativity where
  range :: (Associativity, Associativity) -> [Associativity]
range   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: (Associativity, Associativity) -> Associativity -> Int
index   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: (Associativity, Associativity) -> Associativity -> Bool
inRange = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Bool
inRangeDefault

instance GIx Bool where
  range :: (Bool, Bool) -> [Bool]
range   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: (Bool, Bool) -> Bool -> Int
index   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: (Bool, Bool) -> Bool -> Bool
inRange = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Bool
inRangeDefault

instance GIx CChar where
  range :: (CChar, CChar) -> [CChar]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (CChar, CChar) -> CChar -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (CChar, CChar) -> CChar -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd

#if defined(HTYPE_GID_T)
instance GIx CGid where
  range :: (CGid, CGid) -> [CGid]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (CGid, CGid) -> CGid -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (CGid, CGid) -> CGid -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd
#endif

#if defined(HTYPE_INO_T)
instance GIx CIno where
  range :: (CIno, CIno) -> [CIno]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (CIno, CIno) -> CIno -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (CIno, CIno) -> CIno -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd
#endif

instance GIx CInt where
  range :: (CInt, CInt) -> [CInt]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (CInt, CInt) -> CInt -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (CInt, CInt) -> CInt -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd

instance GIx CIntMax where
  range :: (CIntMax, CIntMax) -> [CIntMax]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (CIntMax, CIntMax) -> CIntMax -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (CIntMax, CIntMax) -> CIntMax -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd

instance GIx CIntPtr where
  range :: (CIntPtr, CIntPtr) -> [CIntPtr]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (CIntPtr, CIntPtr) -> CIntPtr -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (CIntPtr, CIntPtr) -> CIntPtr -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd

instance GIx CLLong where
  range :: (CLLong, CLLong) -> [CLLong]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (CLLong, CLLong) -> CLLong -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (CLLong, CLLong) -> CLLong -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd

instance GIx CLong where
  range :: (CLong, CLong) -> [CLong]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (CLong, CLong) -> CLong -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (CLong, CLong) -> CLong -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd

#if defined(HTYPE_MODE_T)
instance GIx CMode where
  range :: (CMode, CMode) -> [CMode]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (CMode, CMode) -> CMode -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (CMode, CMode) -> CMode -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd
#endif

#if defined(HTYPE_NLINK_T)
instance GIx CNlink where
  range :: (CNlink, CNlink) -> [CNlink]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (CNlink, CNlink) -> CNlink -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (CNlink, CNlink) -> CNlink -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd
#endif

#if defined(HTYPE_OFF_T)
instance GIx COff where
  range :: (COff, COff) -> [COff]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (COff, COff) -> COff -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (COff, COff) -> COff -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd
#endif

#if defined(HTYPE_PID_T)
instance GIx CPid where
  range :: (CPid, CPid) -> [CPid]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (CPid, CPid) -> CPid -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (CPid, CPid) -> CPid -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd
#endif

instance GIx CPtrdiff where
  range :: (CPtrdiff, CPtrdiff) -> [CPtrdiff]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (CPtrdiff, CPtrdiff) -> CPtrdiff -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (CPtrdiff, CPtrdiff) -> CPtrdiff -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd

#if defined(HTYPE_RLIM_T)
instance GIx CRLim where
  range :: (CRLim, CRLim) -> [CRLim]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (CRLim, CRLim) -> CRLim -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (CRLim, CRLim) -> CRLim -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd
#endif

instance GIx CSChar where
  range :: (CSChar, CSChar) -> [CSChar]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (CSChar, CSChar) -> CSChar -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (CSChar, CSChar) -> CSChar -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd

instance GIx CShort where
  range :: (CShort, CShort) -> [CShort]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (CShort, CShort) -> CShort -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (CShort, CShort) -> CShort -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd

instance GIx CSigAtomic where
  range :: (CSigAtomic, CSigAtomic) -> [CSigAtomic]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (CSigAtomic, CSigAtomic) -> CSigAtomic -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (CSigAtomic, CSigAtomic) -> CSigAtomic -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd

instance GIx CSize where
  range :: (CSize, CSize) -> [CSize]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (CSize, CSize) -> CSize -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (CSize, CSize) -> CSize -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd

#if defined(HTYPE_SSIZE_T)
instance GIx CSsize where
  range :: (CSsize, CSsize) -> [CSsize]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (CSsize, CSsize) -> CSsize -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (CSsize, CSsize) -> CSsize -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd
#endif

#if defined(HTYPE_TCFLAG_T)
instance GIx CTcflag where
  range :: (CTcflag, CTcflag) -> [CTcflag]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (CTcflag, CTcflag) -> CTcflag -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (CTcflag, CTcflag) -> CTcflag -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd
#endif

instance GIx CUChar where
  range :: (CUChar, CUChar) -> [CUChar]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (CUChar, CUChar) -> CUChar -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (CUChar, CUChar) -> CUChar -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd

#if defined(HTYPE_UID_T)
instance GIx CUid where
  range :: (CUid, CUid) -> [CUid]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (CUid, CUid) -> CUid -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (CUid, CUid) -> CUid -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd
#endif

instance GIx CUInt where
  range :: (CUInt, CUInt) -> [CUInt]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (CUInt, CUInt) -> CUInt -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (CUInt, CUInt) -> CUInt -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd

instance GIx CUIntMax where
  range :: (CUIntMax, CUIntMax) -> [CUIntMax]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (CUIntMax, CUIntMax) -> CUIntMax -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (CUIntMax, CUIntMax) -> CUIntMax -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd

instance GIx CUIntPtr where
  range :: (CUIntPtr, CUIntPtr) -> [CUIntPtr]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (CUIntPtr, CUIntPtr) -> CUIntPtr -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (CUIntPtr, CUIntPtr) -> CUIntPtr -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd

instance GIx CULLong where
  range :: (CULLong, CULLong) -> [CULLong]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (CULLong, CULLong) -> CULLong -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (CULLong, CULLong) -> CULLong -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd

instance GIx CULong where
  range :: (CULong, CULong) -> [CULong]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (CULong, CULong) -> CULong -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (CULong, CULong) -> CULong -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd

instance GIx CUShort where
  range :: (CUShort, CUShort) -> [CUShort]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (CUShort, CUShort) -> CUShort -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (CUShort, CUShort) -> CUShort -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd

instance GIx CWchar where
  range :: (CWchar, CWchar) -> [CWchar]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (CWchar, CWchar) -> CWchar -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (CWchar, CWchar) -> CWchar -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd

instance (GEq a, GEnum a, GIx a) => GIx (Dual a) where
  range :: (Dual a, Dual a) -> [Dual a]
range   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: (Dual a, Dual a) -> Dual a -> Int
index   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: (Dual a, Dual a) -> Dual a -> Bool
inRange = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Bool
inRangeDefault

instance (GEq a, GEnum a, GIx a, GEq b, GEnum b, GIx b) => GIx (Either a b) where
  range :: (Either a b, Either a b) -> [Either a b]
range   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: (Either a b, Either a b) -> Either a b -> Int
index   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: (Either a b, Either a b) -> Either a b -> Bool
inRange = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Bool
inRangeDefault

instance GIx ExitCode where
  range :: (ExitCode, ExitCode) -> [ExitCode]
range   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: (ExitCode, ExitCode) -> ExitCode -> Int
index   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: (ExitCode, ExitCode) -> ExitCode -> Bool
inRange = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Bool
inRangeDefault

instance GIx Fd where
  range :: (Fd, Fd) -> [Fd]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (Fd, Fd) -> Fd -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (Fd, Fd) -> Fd -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd

instance (GEq a, GEnum a, GIx a) => GIx (Monoid.First a) where
  range :: (First a, First a) -> [First a]
range   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: (First a, First a) -> First a -> Int
index   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: (First a, First a) -> First a -> Bool
inRange = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Bool
inRangeDefault

#if MIN_VERSION_base(4,9,0)
instance (GEq a, GEnum a, GIx a) => GIx (Semigroup.First a) where
  range :: (First a, First a) -> [First a]
range   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: (First a, First a) -> First a -> Int
index   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: (First a, First a) -> First a -> Bool
inRange = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Bool
inRangeDefault
#endif

instance GIx Fixity where
  range :: (Fixity, Fixity) -> [Fixity]
range   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: (Fixity, Fixity) -> Fixity -> Int
index   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: (Fixity, Fixity) -> Fixity -> Bool
inRange = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Bool
inRangeDefault

#if MIN_VERSION_base(4,8,0)
instance (GEq a, GEnum a, GIx a) => GIx (Identity a) where
  range :: (Identity a, Identity a) -> [Identity a]
range   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: (Identity a, Identity a) -> Identity a -> Int
index   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: (Identity a, Identity a) -> Identity a -> Bool
inRange = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Bool
inRangeDefault
#endif

instance GIx Int where
  range :: (Int, Int) -> [Int]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (Int, Int) -> Int -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (Int, Int) -> Int -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd

instance GIx Int8 where
  range :: (Int8, Int8) -> [Int8]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (Int8, Int8) -> Int8 -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (Int8, Int8) -> Int8 -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd

instance GIx Int16 where
  range :: (Int16, Int16) -> [Int16]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (Int16, Int16) -> Int16 -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (Int16, Int16) -> Int16 -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd

instance GIx Int32 where
  range :: (Int32, Int32) -> [Int32]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (Int32, Int32) -> Int32 -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (Int32, Int32) -> Int32 -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd

instance GIx Int64 where
  range :: (Int64, Int64) -> [Int64]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (Int64, Int64) -> Int64 -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (Int64, Int64) -> Int64 -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd

instance GIx Integer where
  range :: (Integer, Integer) -> [Integer]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (Integer, Integer) -> Integer -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (Integer, Integer) -> Integer -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd

instance GIx IntPtr where
  range :: (IntPtr, IntPtr) -> [IntPtr]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (IntPtr, IntPtr) -> IntPtr -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (IntPtr, IntPtr) -> IntPtr -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd

instance (GEq a, GEnum a, GIx a) => GIx (Monoid.Last a) where
  range :: (Last a, Last a) -> [Last a]
range   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: (Last a, Last a) -> Last a -> Int
index   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: (Last a, Last a) -> Last a -> Bool
inRange = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Bool
inRangeDefault

#if MIN_VERSION_base(4,9,0)
instance (GEq a, GEnum a, GIx a) => GIx (Semigroup.Last a) where
  range :: (Last a, Last a) -> [Last a]
range   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: (Last a, Last a) -> Last a -> Int
index   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: (Last a, Last a) -> Last a -> Bool
inRange = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Bool
inRangeDefault
#endif

#if MIN_VERSION_base(4,9,0)
instance (GEq a, GEnum a, GIx a) => GIx (Max a) where
  range :: (Max a, Max a) -> [Max a]
range   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: (Max a, Max a) -> Max a -> Int
index   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: (Max a, Max a) -> Max a -> Bool
inRange = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Bool
inRangeDefault
#endif

instance (GEq a, GEnum a, GIx a) => GIx (Maybe a) where
  range :: (Maybe a, Maybe a) -> [Maybe a]
range   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: (Maybe a, Maybe a) -> Maybe a -> Int
index   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: (Maybe a, Maybe a) -> Maybe a -> Bool
inRange = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Bool
inRangeDefault

#if MIN_VERSION_base(4,9,0)
instance (GEq a, GEnum a, GIx a) => GIx (Min a) where
  range :: (Min a, Min a) -> [Min a]
range   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: (Min a, Min a) -> Min a -> Int
index   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: (Min a, Min a) -> Min a -> Bool
inRange = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Bool
inRangeDefault
#endif

#if MIN_VERSION_base(4,8,0)
instance GIx Natural where
  range :: (Natural, Natural) -> [Natural]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (Natural, Natural) -> Natural -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (Natural, Natural) -> Natural -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd
#endif

#if MIN_VERSION_base(4,9,0)
instance (GEq a, GEnum a, GIx a) => GIx (NonEmpty a) where
  range :: (NonEmpty a, NonEmpty a) -> [NonEmpty a]
range   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: (NonEmpty a, NonEmpty a) -> NonEmpty a -> Int
index   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: (NonEmpty a, NonEmpty a) -> NonEmpty a -> Bool
inRange = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Bool
inRangeDefault
#endif

instance GIx Ordering where
  range :: (Ordering, Ordering) -> [Ordering]
range   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: (Ordering, Ordering) -> Ordering -> Int
index   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: (Ordering, Ordering) -> Ordering -> Bool
inRange = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Bool
inRangeDefault

instance (GEq a, GEnum a, GIx a) => GIx (Product a) where
  range :: (Product a, Product a) -> [Product a]
range   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: (Product a, Product a) -> Product a -> Int
index   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: (Product a, Product a) -> Product a -> Bool
inRange = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Bool
inRangeDefault

#if MIN_VERSION_base(4,7,0)
instance GIx
# if MIN_VERSION_base(4,9,0)
             (Proxy s)
# else
             (Proxy (s :: *))
# endif
             where
  range :: (Proxy s, Proxy s) -> [Proxy s]
range   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: (Proxy s, Proxy s) -> Proxy s -> Int
index   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: (Proxy s, Proxy s) -> Proxy s -> Bool
inRange = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Bool
inRangeDefault
#endif

instance (GEq a, GEnum a, GIx a) => GIx (Sum a) where
  range :: (Sum a, Sum a) -> [Sum a]
range   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: (Sum a, Sum a) -> Sum a -> Int
index   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: (Sum a, Sum a) -> Sum a -> Bool
inRange = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Bool
inRangeDefault

instance GIx Word where
  range :: (Word, Word) -> [Word]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (Word, Word) -> Word -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (Word, Word) -> Word -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd

instance GIx Word8 where
  range :: (Word8, Word8) -> [Word8]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (Word8, Word8) -> Word8 -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (Word8, Word8) -> Word8 -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd

instance GIx Word16 where
  range :: (Word16, Word16) -> [Word16]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (Word16, Word16) -> Word16 -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (Word16, Word16) -> Word16 -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd

instance GIx Word32 where
  range :: (Word32, Word32) -> [Word32]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (Word32, Word32) -> Word32 -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (Word32, Word32) -> Word32 -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd

instance GIx Word64 where
  range :: (Word64, Word64) -> [Word64]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (Word64, Word64) -> Word64 -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (Word64, Word64) -> Word64 -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd

instance GIx WordPtr where
  range :: (WordPtr, WordPtr) -> [WordPtr]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (WordPtr, WordPtr) -> WordPtr -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (WordPtr, WordPtr) -> WordPtr -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd

#if MIN_VERSION_base(4,9,0)
instance (GEq m, GEnum m, GIx m) => GIx (WrappedMonoid m) where
  range :: (WrappedMonoid m, WrappedMonoid m) -> [WrappedMonoid m]
range   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: (WrappedMonoid m, WrappedMonoid m) -> WrappedMonoid m -> Int
index   = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: (WrappedMonoid m, WrappedMonoid m) -> WrappedMonoid m -> Bool
inRange = forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Bool
inRangeDefault
#endif

#if MIN_VERSION_base(4,10,0)
instance GIx CBool where
  range :: (CBool, CBool) -> [CBool]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (CBool, CBool) -> CBool -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (CBool, CBool) -> CBool -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd

# if defined(HTYPE_BLKSIZE_T)
instance GIx CBlkSize where
  range :: (CBlkSize, CBlkSize) -> [CBlkSize]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (CBlkSize, CBlkSize) -> CBlkSize -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (CBlkSize, CBlkSize) -> CBlkSize -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd
# endif

# if defined(HTYPE_BLKCNT_T)
instance GIx CBlkCnt where
  range :: (CBlkCnt, CBlkCnt) -> [CBlkCnt]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (CBlkCnt, CBlkCnt) -> CBlkCnt -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (CBlkCnt, CBlkCnt) -> CBlkCnt -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd
# endif

# if defined(HTYPE_CLOCKID_T)
instance GIx CClockId where
  range :: (CClockId, CClockId) -> [CClockId]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (CClockId, CClockId) -> CClockId -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (CClockId, CClockId) -> CClockId -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd
# endif

# if defined(HTYPE_FSBLKCNT_T)
instance GIx CFsBlkCnt where
  range :: (CFsBlkCnt, CFsBlkCnt) -> [CFsBlkCnt]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (CFsBlkCnt, CFsBlkCnt) -> CFsBlkCnt -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (CFsBlkCnt, CFsBlkCnt) -> CFsBlkCnt -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd
# endif

# if defined(HTYPE_FSFILCNT_T)
instance GIx CFsFilCnt where
  range :: (CFsFilCnt, CFsFilCnt) -> [CFsFilCnt]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (CFsFilCnt, CFsFilCnt) -> CFsFilCnt -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (CFsFilCnt, CFsFilCnt) -> CFsFilCnt -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd
# endif

# if defined(HTYPE_ID_T)
instance GIx CId where
  range :: (CId, CId) -> [CId]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (CId, CId) -> CId -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (CId, CId) -> CId -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd
# endif

# if defined(HTYPE_KEY_T)
instance GIx CKey where
  range :: (CKey, CKey) -> [CKey]
range   = forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (CKey, CKey) -> CKey -> Int
index   = forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (CKey, CKey) -> CKey -> Bool
inRange = forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd
# endif
#endif