module Data.Ix.Enum where
{-# INLINE range #-}
{-# INLINE index #-}
{-# INLINE unsafeIndex #-}
{-# INLINE inRange #-}
{-# INLINE rangeSize #-}
{-# INLINE unsafeRangeSize #-}
range :: Enum a => (a, a) -> [a]
index :: Enum a => (a, a) -> a -> Int
unsafeIndex :: Enum a => (a, a) -> a -> Int
inRange :: Enum a => (a, a) -> a -> Bool
rangeSize :: Enum a => (a, a) -> Int
unsafeRangeSize :: Enum a => (a, a) -> Int
range :: forall a. Enum a => (a, a) -> [a]
range (a
l,a
r) = forall a b. (a -> b) -> [a] -> [b]
map forall a. Enum a => Int -> a
toEnum forall a b. (a -> b) -> a -> b
$ forall a. Enum a => (a, a) -> [a]
range (forall a. Enum a => a -> Int
fromEnum a
l, forall a. Enum a => a -> Int
fromEnum a
r)
index :: forall a. Enum a => (a, a) -> a -> Int
index (a
l,a
r) a
i = forall a. Enum a => (a, a) -> a -> Int
index (forall a. Enum a => a -> Int
fromEnum a
l, forall a. Enum a => a -> Int
fromEnum a
r) (forall a. Enum a => a -> Int
fromEnum a
i)
unsafeIndex :: forall a. Enum a => (a, a) -> a -> Int
unsafeIndex (a
l,a
r) a
i = forall a. Enum a => (a, a) -> a -> Int
unsafeIndex (forall a. Enum a => a -> Int
fromEnum a
l, forall a. Enum a => a -> Int
fromEnum a
r) (forall a. Enum a => a -> Int
fromEnum a
i)
inRange :: forall a. Enum a => (a, a) -> a -> Bool
inRange (a
l,a
r) a
i = forall a. Enum a => (a, a) -> a -> Bool
inRange (forall a. Enum a => a -> Int
fromEnum a
l, forall a. Enum a => a -> Int
fromEnum a
r) (forall a. Enum a => a -> Int
fromEnum a
i)
rangeSize :: forall a. Enum a => (a, a) -> Int
rangeSize (a
l,a
r) = forall a. Enum a => (a, a) -> Int
rangeSize (forall a. Enum a => a -> Int
fromEnum a
l, forall a. Enum a => a -> Int
fromEnum a
r)
unsafeRangeSize :: forall a. Enum a => (a, a) -> Int
unsafeRangeSize (a
l,a
r) = forall a. Enum a => (a, a) -> Int
unsafeRangeSize (forall a. Enum a => a -> Int
fromEnum a
l, forall a. Enum a => a -> Int
fromEnum a
r)