-- |
-- Bidirectional versions of 'Enum' functions.
{-# LANGUAGE Safe, TypeOperators #-}
module Data.Invertible.Enum
  ( enum
  , succ
  ) where

import qualified Prelude
import Prelude hiding (succ)

import Data.Invertible.Bijection

-- |Convert between an 'Int' and an 'Enum' with 'P.toEnum' and 'P.fromEnum'.
enum :: Enum a => Int <-> a
enum :: forall a. Enum a => Int <-> a
enum = Int -> a
forall a. Enum a => Int -> a
toEnum (Int -> a) -> (a -> Int) -> Bijection (->) Int a
forall (a :: * -> * -> *) b c. a b c -> a c b -> Bijection a b c
:<->: a -> Int
forall a. Enum a => a -> Int
fromEnum

-- |Combine 'Prelude.succ' and 'pred'
succ :: Enum a => a <-> a
succ :: forall a. Enum a => a <-> a
succ = a -> a
forall a. Enum a => a -> a
Prelude.succ (a -> a) -> (a -> a) -> Bijection (->) a a
forall (a :: * -> * -> *) b c. a b c -> a c b -> Bijection a b c
:<->: a -> a
forall a. Enum a => a -> a
pred