plutus-tx-1.60.0.0: Libraries for Plutus Tx and its prelude
Safe HaskellSafe-Inferred
LanguageHaskell2010

PlutusTx.Enum

Synopsis

Documentation

class Enum a where #

Class Enum defines operations on sequentially ordered types.

Minimal complete definition

toEnum, fromEnum

Methods

succ :: a -> a #

The successor of a value. For numeric types, succ adds 1.

For types that implement Ord, succ x should be the least element that is greater than x, and error if there is none.

pred :: a -> a #

The predecessor of a value. For numeric types, pred subtracts 1.

For types that implement Ord, pred x should be the greatest element that is less than x, and error if there is none.

toEnum :: Integer -> a #

Convert from an Integer.

fromEnum :: a -> Integer #

Convert to an Integer.

enumFromTo :: a -> a -> [a] #

Construct a list from the given range (corresponds to [a..b]).

enumFromThenTo :: a -> a -> a -> [a] #

Construct a list from the given range (corresponds to [a,b..c]). This has the same semantics as the Haskell version,so if a==b and c>=b then you get an infinite list, which you probably don't want in Plutus Core.

Instances

Instances details
Enum Ordering # 
Instance details

Defined in PlutusTx.Enum

Enum Rational # 
Instance details

Defined in PlutusTx.Ratio

Enum Integer # 
Instance details

Defined in PlutusTx.Enum.Class

Enum () # 
Instance details

Defined in PlutusTx.Enum

Methods

succ :: () -> () #

pred :: () -> () #

toEnum :: Integer -> () #

fromEnum :: () -> Integer #

enumFromTo :: () -> () -> [()] #

enumFromThenTo :: () -> () -> () -> [()] #

Enum Bool # 
Instance details

Defined in PlutusTx.Enum

deriveEnum :: Name -> Q [Dec] #

Derive PlutusTx.Enum typeclass for datatypes, much like `deriving stock Enum` does for Haskell

Note: requires enabling OverloadedStrings language extension

Orphan instances

Enum Ordering # 
Instance details

Enum () # 
Instance details

Methods

succ :: () -> () #

pred :: () -> () #

toEnum :: Integer -> () #

fromEnum :: () -> Integer #

enumFromTo :: () -> () -> [()] #

enumFromThenTo :: () -> () -> () -> [()] #

Enum Bool # 
Instance details