{-# 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]
[]     ||| :: [a] -> [a] -> [a]
||| [a]
ys = [a]
ys
(a
x:[a]
xs) ||| [a]
ys = a
x a -> [a] -> [a]
forall a. a -> [a] -> [a]
: [a]
ys [a] -> [a] -> [a]
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 :: [[a]] -> [a]
diag = [[a]] -> [a]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat ([[a]] -> [a]) -> ([[a]] -> [[a]]) -> [[a]] -> [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([[a]] -> [[a]] -> [[a]]) -> [[a]] -> [[[a]]] -> [[a]]
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr [[a]] -> [[a]] -> [[a]]
forall a. [[a]] -> [[a]] -> [[a]]
skew [] ([[[a]]] -> [[a]]) -> ([[a]] -> [[[a]]]) -> [[a]] -> [[a]]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([a] -> [[a]]) -> [[a]] -> [[[a]]]
forall a b. (a -> b) -> [a] -> [b]
map ((a -> [a]) -> [a] -> [[a]]
forall a b. (a -> b) -> [a] -> [b]
map (\a
x -> [a
x]))

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

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

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

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

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

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

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

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

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

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

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

fromEnumDefault :: (GEq a, Generic a, Enum' (Rep a))
                => a -> Int
fromEnumDefault :: a -> Int
fromEnumDefault a
x = case (a -> Bool) -> [a] -> Maybe Int
forall a. (a -> Bool) -> [a] -> Maybe Int
findIndex (a -> a -> Bool
forall a. GEq a => a -> a -> Bool
geq a
x) ((Rep a Any -> a) -> [Rep a Any] -> [a]
forall a b. (a -> b) -> [a] -> [b]
map Rep a Any -> a
forall a x. Generic a => Rep a x -> a
to [Rep a Any]
forall k (f :: k -> *) (a :: k). Enum' f => [f a]
enum') of
      Maybe Int
Nothing -> [Char] -> Int
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 = [a]
forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault
#endif

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

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

genumNumUnsigned :: (Enum a, Num a) => [a]
genumNumUnsigned :: [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 = [(a, b)]
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 = [(a, b, c)]
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 = [(a, b, c, d)]
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 = [(a, b, c, d, e)]
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 = [(a, b, c, d, e, f)]
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 = [(a, b, c, d, e, f, g)]
forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault

instance GEnum a => GEnum [a] where
  genum :: [[a]]
genum = [[a]]
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 = [(:+:) f g p]
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 = [(:*:) f g p]
forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault

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

instance GEnum All where
  genum :: [All]
genum = [All]
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 = [Alt f a]
forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault
#endif

instance GEnum Any where
  genum :: [Any]
genum = [Any]
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 = [Arg a b]
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 = [Associativity]
forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

#if defined(HTYPE_OFF_T)
instance GEnum COff where
  genum :: [COff]
genum = [Int64] -> [COff]
coerce ([Int64]
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 = [Complex a]
forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault
#endif

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

instance GEnum a => GEnum (Monoid.First a) where
  genum :: [First a]
genum = [First a]
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 = [First a]
forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault
#endif

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

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

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

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

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

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

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

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

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

instance GEnum IntPtr where
  genum :: [IntPtr]
genum = [IntPtr]
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 = [K1 i c p]
forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault

instance GEnum a => GEnum (Monoid.Last a) where
  genum :: [Last a]
genum = [Last a]
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 = [Last a]
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 = [M1 i c f p]
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 = [Max a]
forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault
#endif

instance GEnum a => GEnum (Maybe a) where
  genum :: [Maybe a]
genum = [Maybe a]
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 = [Min a]
forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault
#endif

#if MIN_VERSION_base(4,8,0)
instance GEnum Natural where
  genum :: [Natural]
genum = [Natural]
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 = [NonEmpty a]
forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault
#endif

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

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

instance GEnum a => GEnum (Product a) where
  genum :: [Product a]
genum = [Product a]
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 = [Proxy s]
forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault
#endif

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

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

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

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

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

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

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

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

instance GEnum WordPtr where
  genum :: [WordPtr]
genum = [WordPtr]
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 = [WrappedMonoid m]
forall a. (Generic a, Enum' (Rep a)) => [a]
genumDefault
#endif

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

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

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

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

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

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

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

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

# if defined(HTYPE_KEY_T)
instance GEnum CKey where
  genum :: [CKey]
genum = [Int32] -> [CKey]
coerce ([Int32]
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 = (a, a) -> [a]
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 = (a, a) -> a -> Int
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 = (a, a) -> a -> Bool
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 :: (a, a) -> [a]
rangeDefault = [a] -> (a, a) -> [a]
forall a. GEq a => [a] -> (a, a) -> [a]
t ((Rep a Any -> a) -> [Rep a Any] -> [a]
forall a b. (a -> b) -> [a] -> [b]
map Rep a Any -> a
forall a x. Generic a => Rep a x -> a
to [Rep a Any]
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 ((a -> Bool) -> [a] -> Maybe Int
forall a. (a -> Bool) -> [a] -> Maybe Int
findIndex (a -> a -> Bool
forall a. GEq a => a -> a -> Bool
geq a
x) [a]
l, (a -> Bool) -> [a] -> Maybe Int
forall a. (a -> Bool) -> [a] -> Maybe Int
findIndex (a -> a -> Bool
forall a. GEq a => a -> a -> Bool
geq a
y) [a]
l) of
      (Maybe Int
Nothing, Maybe Int
_)     -> [Char] -> [a]
forall a. HasCallStack => [Char] -> a
error [Char]
"rangeDefault: no corresponding index"
      (Maybe Int
_, Maybe Int
Nothing)     -> [Char] -> [a]
forall a. HasCallStack => [Char] -> a
error [Char]
"rangeDefault: no corresponding index"
      (Just Int
i, Just Int
j) -> Int -> [a] -> [a]
forall a. Int -> [a] -> [a]
take (Int
jInt -> Int -> Int
forall a. Num a => a -> a -> a
-Int
i) (Int -> [a] -> [a]
forall a. Int -> [a] -> [a]
drop Int
i [a]
l)

indexDefault :: (GEq a, Generic a, Enum' (Rep a))
             => (a,a) -> a -> Int
indexDefault :: (a, a) -> a -> Int
indexDefault = [a] -> (a, a) -> a -> Int
forall a. GEq a => [a] -> (a, a) -> a -> Int
t ((Rep a Any -> a) -> [Rep a Any] -> [a]
forall a b. (a -> b) -> [a] -> [b]
map Rep a Any -> a
forall a x. Generic a => Rep a x -> a
to [Rep a Any]
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 ((a -> Bool) -> [a] -> Maybe Int
forall a. (a -> Bool) -> [a] -> Maybe Int
findIndex (a -> a -> Bool
forall a. GEq a => a -> a -> Bool
geq a
x) [a]
l, (a -> Bool) -> [a] -> Maybe Int
forall a. (a -> Bool) -> [a] -> Maybe Int
findIndex (a -> a -> Bool
forall a. GEq a => a -> a -> Bool
geq a
y) [a]
l) of
      (Maybe Int
Nothing, Maybe Int
_)     -> [Char] -> Int
forall a. HasCallStack => [Char] -> a
error [Char]
"indexDefault: no corresponding index"
      (Maybe Int
_, Maybe Int
Nothing)     -> [Char] -> Int
forall a. HasCallStack => [Char] -> a
error [Char]
"indexDefault: no corresponding index"
      (Just Int
i, Just Int
j) -> case (a -> Bool) -> [a] -> Maybe Int
forall a. (a -> Bool) -> [a] -> Maybe Int
findIndex (a -> a -> Bool
forall a. GEq a => a -> a -> Bool
geq a
z) (Int -> [a] -> [a]
forall a. Int -> [a] -> [a]
take (Int
jInt -> Int -> Int
forall a. Num a => a -> a -> a
-Int
i) (Int -> [a] -> [a]
forall a. Int -> [a] -> [a]
drop Int
i [a]
l)) of
                            Maybe Int
Nothing -> [Char] -> Int
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 :: (a, a) -> a -> Bool
inRangeDefault = [a] -> (a, a) -> a -> Bool
forall a. GEq a => [a] -> (a, a) -> a -> Bool
t ((Rep a Any -> a) -> [Rep a Any] -> [a]
forall a b. (a -> b) -> [a] -> [b]
map Rep a Any -> a
forall a x. Generic a => Rep a x -> a
to [Rep a Any]
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 ((a -> Bool) -> [a] -> Maybe Int
forall a. (a -> Bool) -> [a] -> Maybe Int
findIndex (a -> a -> Bool
forall a. GEq a => a -> a -> Bool
geq a
x) [a]
l, (a -> Bool) -> [a] -> Maybe Int
forall a. (a -> Bool) -> [a] -> Maybe Int
findIndex (a -> a -> Bool
forall a. GEq a => a -> a -> Bool
geq a
y) [a]
l) of
      (Maybe Int
Nothing, Maybe Int
_)     -> [Char] -> Bool
forall a. HasCallStack => [Char] -> a
error [Char]
"indexDefault: no corresponding index"
      (Maybe Int
_, Maybe Int
Nothing)     -> [Char] -> Bool
forall a. HasCallStack => [Char] -> a
error [Char]
"indexDefault: no corresponding index"
      (Just Int
i, Just Int
j) -> Bool -> (Int -> Bool) -> Maybe Int -> Bool
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Bool
False (Bool -> Int -> Bool
forall a b. a -> b -> a
const Bool
True)
                            ((a -> Bool) -> [a] -> Maybe Int
forall a. (a -> Bool) -> [a] -> Maybe Int
findIndex (a -> a -> Bool
forall a. GEq a => a -> a -> Bool
geq a
z) (Int -> [a] -> [a]
forall a. Int -> [a] -> [a]
take (Int
jInt -> Int -> Int
forall a. Num a => a -> a -> a
-Int
i) (Int -> [a] -> [a]
forall a. Int -> [a] -> [a]
drop Int
i [a]
l)))

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

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

inRangeOrd :: Ord a => (a, a) -> a -> Bool
inRangeOrd :: (a, a) -> a -> Bool
inRangeOrd (a
m,a
n) a
i =  a
m a -> a -> Bool
forall a. Ord a => a -> a -> Bool
<= a
i Bool -> Bool -> Bool
&& a
i a -> a -> Bool
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   = ((), ()) -> () -> Int
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: ((), ()) -> () -> Bool
inRange = ((), ()) -> () -> Bool
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   = ((a, b), (a, b)) -> [(a, b)]
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: ((a, b), (a, b)) -> (a, b) -> Int
index   = ((a, b), (a, b)) -> (a, b) -> Int
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: ((a, b), (a, b)) -> (a, b) -> Bool
inRange = ((a, b), (a, b)) -> (a, b) -> Bool
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   = ((a, b, c), (a, b, c)) -> [(a, b, c)]
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   = ((a, b, c), (a, b, c)) -> (a, b, c) -> Int
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 = ((a, b, c), (a, b, c)) -> (a, b, c) -> Bool
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   = ((a, b, c, d), (a, b, c, d)) -> [(a, b, c, d)]
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   = ((a, b, c, d), (a, b, c, d)) -> (a, b, c, d) -> Int
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 = ((a, b, c, d), (a, b, c, d)) -> (a, b, c, d) -> Bool
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   = ((a, b, c, d, e), (a, b, c, d, e)) -> [(a, b, c, d, e)]
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   = ((a, b, c, d, e), (a, b, c, d, e)) -> (a, b, c, d, e) -> Int
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 = ((a, b, c, d, e), (a, b, c, d, e)) -> (a, b, c, d, e) -> Bool
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   = ((a, b, c, d, e, f), (a, b, c, d, e, f)) -> [(a, b, c, d, e, f)]
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   = ((a, b, c, d, e, f), (a, b, c, d, e, f))
-> (a, b, c, d, e, f) -> Int
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 = ((a, b, c, d, e, f), (a, b, c, d, e, f))
-> (a, b, c, d, e, f) -> Bool
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   = ((a, b, c, d, e, f, g), (a, b, c, d, e, f, g))
-> [(a, b, c, d, e, f, g)]
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   = ((a, b, c, d, e, f, g), (a, b, c, d, e, f, g))
-> (a, b, c, d, e, f, g) -> Int
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 = ((a, b, c, d, e, f, g), (a, b, c, d, e, f, g))
-> (a, b, c, d, e, f, g) -> Bool
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   = ([a], [a]) -> [[a]]
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: ([a], [a]) -> [a] -> Int
index   = ([a], [a]) -> [a] -> Int
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: ([a], [a]) -> [a] -> Bool
inRange = ([a], [a]) -> [a] -> Bool
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Bool
inRangeDefault

instance GIx All where
  range :: (All, All) -> [All]
range   = (All, All) -> [All]
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: (All, All) -> All -> Int
index   = (All, All) -> All -> Int
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: (All, All) -> All -> Bool
inRange = (All, All) -> All -> Bool
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   = (Alt f a, Alt f a) -> [Alt f a]
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   = (Alt f a, Alt f a) -> Alt f a -> Int
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 = (Alt f a, Alt f a) -> Alt f a -> Bool
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Bool
inRangeDefault
#endif

instance GIx Any where
  range :: (Any, Any) -> [Any]
range   = (Any, Any) -> [Any]
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: (Any, Any) -> Any -> Int
index   = (Any, Any) -> Any -> Int
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: (Any, Any) -> Any -> Bool
inRange = (Any, Any) -> Any -> Bool
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   = (Arg a b, Arg a b) -> [Arg a b]
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   = (Arg a b, Arg a b) -> Arg a b -> Int
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 = (Arg a b, Arg a b) -> Arg a b -> Bool
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   = (Associativity, Associativity) -> [Associativity]
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: (Associativity, Associativity) -> Associativity -> Int
index   = (Associativity, Associativity) -> Associativity -> Int
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: (Associativity, Associativity) -> Associativity -> Bool
inRange = (Associativity, Associativity) -> Associativity -> Bool
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Bool
inRangeDefault

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

instance GIx CWchar where
  range :: (CWchar, CWchar) -> [CWchar]
range   = (CWchar, CWchar) -> [CWchar]
forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (CWchar, CWchar) -> CWchar -> Int
index   = (CWchar, CWchar) -> CWchar -> Int
forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (CWchar, CWchar) -> CWchar -> Bool
inRange = (CWchar, CWchar) -> CWchar -> Bool
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   = (Dual a, Dual a) -> [Dual a]
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: (Dual a, Dual a) -> Dual a -> Int
index   = (Dual a, Dual a) -> Dual a -> Int
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: (Dual a, Dual a) -> Dual a -> Bool
inRange = (Dual a, Dual a) -> Dual a -> Bool
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   = (Either a b, Either a b) -> [Either a b]
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   = (Either a b, Either a b) -> Either a b -> Int
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 = (Either a b, Either a b) -> Either a b -> Bool
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Bool
inRangeDefault

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

instance GIx Fd where
  range :: (Fd, Fd) -> [Fd]
range   = (Fd, Fd) -> [Fd]
forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (Fd, Fd) -> Fd -> Int
index   = (Fd, Fd) -> Fd -> Int
forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (Fd, Fd) -> Fd -> Bool
inRange = (Fd, Fd) -> Fd -> Bool
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   = (First a, First a) -> [First a]
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: (First a, First a) -> First a -> Int
index   = (First a, First a) -> First a -> Int
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: (First a, First a) -> First a -> Bool
inRange = (First a, First a) -> First a -> Bool
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   = (First a, First a) -> [First a]
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: (First a, First a) -> First a -> Int
index   = (First a, First a) -> First a -> Int
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: (First a, First a) -> First a -> Bool
inRange = (First a, First a) -> First a -> Bool
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Bool
inRangeDefault
#endif

instance GIx Fixity where
  range :: (Fixity, Fixity) -> [Fixity]
range   = (Fixity, Fixity) -> [Fixity]
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: (Fixity, Fixity) -> Fixity -> Int
index   = (Fixity, Fixity) -> Fixity -> Int
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: (Fixity, Fixity) -> Fixity -> Bool
inRange = (Fixity, Fixity) -> Fixity -> Bool
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   = (Identity a, Identity a) -> [Identity a]
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: (Identity a, Identity a) -> Identity a -> Int
index   = (Identity a, Identity a) -> Identity a -> Int
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: (Identity a, Identity a) -> Identity a -> Bool
inRange = (Identity a, Identity a) -> Identity a -> Bool
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Bool
inRangeDefault
#endif

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

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

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

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

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

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

instance GIx IntPtr where
  range :: (IntPtr, IntPtr) -> [IntPtr]
range   = (IntPtr, IntPtr) -> [IntPtr]
forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (IntPtr, IntPtr) -> IntPtr -> Int
index   = (IntPtr, IntPtr) -> IntPtr -> Int
forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (IntPtr, IntPtr) -> IntPtr -> Bool
inRange = (IntPtr, IntPtr) -> IntPtr -> Bool
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   = (Last a, Last a) -> [Last a]
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: (Last a, Last a) -> Last a -> Int
index   = (Last a, Last a) -> Last a -> Int
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: (Last a, Last a) -> Last a -> Bool
inRange = (Last a, Last a) -> Last a -> Bool
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   = (Last a, Last a) -> [Last a]
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: (Last a, Last a) -> Last a -> Int
index   = (Last a, Last a) -> Last a -> Int
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: (Last a, Last a) -> Last a -> Bool
inRange = (Last a, Last a) -> Last a -> Bool
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   = (Max a, Max a) -> [Max a]
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: (Max a, Max a) -> Max a -> Int
index   = (Max a, Max a) -> Max a -> Int
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: (Max a, Max a) -> Max a -> Bool
inRange = (Max a, Max a) -> Max a -> Bool
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   = (Maybe a, Maybe a) -> [Maybe a]
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: (Maybe a, Maybe a) -> Maybe a -> Int
index   = (Maybe a, Maybe a) -> Maybe a -> Int
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: (Maybe a, Maybe a) -> Maybe a -> Bool
inRange = (Maybe a, Maybe a) -> Maybe a -> Bool
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   = (Min a, Min a) -> [Min a]
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: (Min a, Min a) -> Min a -> Int
index   = (Min a, Min a) -> Min a -> Int
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: (Min a, Min a) -> Min a -> Bool
inRange = (Min a, Min a) -> Min a -> Bool
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   = (Natural, Natural) -> [Natural]
forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (Natural, Natural) -> Natural -> Int
index   = (Natural, Natural) -> Natural -> Int
forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (Natural, Natural) -> Natural -> Bool
inRange = (Natural, Natural) -> Natural -> Bool
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   = (NonEmpty a, NonEmpty a) -> [NonEmpty a]
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: (NonEmpty a, NonEmpty a) -> NonEmpty a -> Int
index   = (NonEmpty a, NonEmpty a) -> NonEmpty a -> Int
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: (NonEmpty a, NonEmpty a) -> NonEmpty a -> Bool
inRange = (NonEmpty a, NonEmpty a) -> NonEmpty a -> Bool
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Bool
inRangeDefault
#endif

instance GIx Ordering where
  range :: (Ordering, Ordering) -> [Ordering]
range   = (Ordering, Ordering) -> [Ordering]
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: (Ordering, Ordering) -> Ordering -> Int
index   = (Ordering, Ordering) -> Ordering -> Int
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: (Ordering, Ordering) -> Ordering -> Bool
inRange = (Ordering, Ordering) -> Ordering -> Bool
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   = (Product a, Product a) -> [Product a]
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: (Product a, Product a) -> Product a -> Int
index   = (Product a, Product a) -> Product a -> Int
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: (Product a, Product a) -> Product a -> Bool
inRange = (Product a, Product a) -> Product a -> Bool
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   = (Proxy s, Proxy s) -> [Proxy s]
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: (Proxy s, Proxy s) -> Proxy s -> Int
index   = (Proxy s, Proxy s) -> Proxy s -> Int
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: (Proxy s, Proxy s) -> Proxy s -> Bool
inRange = (Proxy s, Proxy s) -> Proxy s -> Bool
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   = (Sum a, Sum a) -> [Sum a]
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: (Sum a, Sum a) -> Sum a -> Int
index   = (Sum a, Sum a) -> Sum a -> Int
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: (Sum a, Sum a) -> Sum a -> Bool
inRange = (Sum a, Sum a) -> Sum a -> Bool
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Bool
inRangeDefault

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

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

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

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

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

instance GIx WordPtr where
  range :: (WordPtr, WordPtr) -> [WordPtr]
range   = (WordPtr, WordPtr) -> [WordPtr]
forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (WordPtr, WordPtr) -> WordPtr -> Int
index   = (WordPtr, WordPtr) -> WordPtr -> Int
forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (WordPtr, WordPtr) -> WordPtr -> Bool
inRange = (WordPtr, WordPtr) -> WordPtr -> Bool
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   = (WrappedMonoid m, WrappedMonoid m) -> [WrappedMonoid m]
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
rangeDefault
  index :: (WrappedMonoid m, WrappedMonoid m) -> WrappedMonoid m -> Int
index   = (WrappedMonoid m, WrappedMonoid m) -> WrappedMonoid m -> Int
forall a. (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
indexDefault
  inRange :: (WrappedMonoid m, WrappedMonoid m) -> WrappedMonoid m -> Bool
inRange = (WrappedMonoid m, WrappedMonoid m) -> WrappedMonoid m -> Bool
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   = (CBool, CBool) -> [CBool]
forall a. Enum a => (a, a) -> [a]
rangeEnum
  index :: (CBool, CBool) -> CBool -> Int
index   = (CBool, CBool) -> CBool -> Int
forall a. Integral a => (a, a) -> a -> Int
indexIntegral
  inRange :: (CBool, CBool) -> CBool -> Bool
inRange = (CBool, CBool) -> CBool -> Bool
forall a. Ord a => (a, a) -> a -> Bool
inRangeOrd

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

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

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

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

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

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

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