primes-type-0.2.0.1: Type-safe prime numbers.

Data.Numbers.Primes.Type

Synopsis

# Documentation

data Prime int Source #

An abstract type for primes.

It will only ever hold a valid prime, along with its zero-based index.

Instances

 Integral int => Enum (Prime int) Source # Methodssucc :: Prime int -> Prime int #pred :: Prime int -> Prime int #toEnum :: Int -> Prime int #fromEnum :: Prime int -> Int #enumFrom :: Prime int -> [Prime int] #enumFromThen :: Prime int -> Prime int -> [Prime int] #enumFromTo :: Prime int -> Prime int -> [Prime int] #enumFromThenTo :: Prime int -> Prime int -> Prime int -> [Prime int] # Eq (Prime int) Source # Methods(==) :: Prime int -> Prime int -> Bool #(/=) :: Prime int -> Prime int -> Bool # Ord (Prime int) Source # Methodscompare :: Prime int -> Prime int -> Ordering #(<) :: Prime int -> Prime int -> Bool #(<=) :: Prime int -> Prime int -> Bool #(>) :: Prime int -> Prime int -> Bool #(>=) :: Prime int -> Prime int -> Bool #max :: Prime int -> Prime int -> Prime int #min :: Prime int -> Prime int -> Prime int # Show int => Show (Prime int) Source # MethodsshowsPrec :: Int -> Prime int -> ShowS #show :: Prime int -> String #showList :: [Prime int] -> ShowS #

getValue :: Prime int -> int Source #

Given a Prime, give back its value.

getIndex :: Prime int -> Int Source #

Given a Prime, give back its index.

deconstruct :: Prime int -> (int, Int) Source #

Given a Prime, give back its value and index as a tuple.

primeIndex :: Integral n => n -> Maybe Int Source #

If a given number is prime, give back its index.

getPrime :: Integral int => Int -> Prime int Source #

Give n-th prime.

maybePrime :: Integral int => int -> Maybe (Prime int) Source #

If a given number is prime, give it back wrapped as such.

indexedPrimes :: Integral int => [Prime int] Source #

List of indexed primes.