finite-typelits-0.1.6.0: A type inhabited by finitely many values, indexed by type-level naturals
Copyright (C) 2015-2022 mniip
License BSD3
Maintainer mniip <mniip@mniip.com>
Stability experimental
Portability portable
Safe Haskell Safe-Inferred
Language Haskell2010

Data.Finite.Internal

Description

Synopsis

Documentation

newtype Finite (n :: Nat ) Source #

Finite number type. Finite n is inhabited by exactly n values the range [0, n) including 0 but excluding n . Invariants:

getFinite x < natVal x
getFinite x >= 0

Constructors

Finite Integer

Instances

Instances details
KnownNat n => Bounded ( Finite n) Source #

Throws an error for Finite 0

Instance details

Defined in Data.Finite.Internal

KnownNat n => Enum ( Finite n) Source #
Instance details

Defined in Data.Finite.Internal

Eq ( Finite n) Source #
Instance details

Defined in Data.Finite.Internal

KnownNat n => Integral ( Finite n) Source #

quot and rem are the same as div and mod and they implement regular division of numbers in the range [0, n) , not modular arithmetic.

Instance details

Defined in Data.Finite.Internal

KnownNat n => Num ( Finite n) Source #

+ , - , and * implement arithmetic modulo n . The fromInteger function raises an error for inputs outside of bounds.

Instance details

Defined in Data.Finite.Internal

Ord ( Finite n) Source #
Instance details

Defined in Data.Finite.Internal

KnownNat n => Read ( Finite n) Source #
Instance details

Defined in Data.Finite.Internal

KnownNat n => Real ( Finite n) Source #
Instance details

Defined in Data.Finite.Internal

Show ( Finite n) Source #
Instance details

Defined in Data.Finite.Internal

Generic ( Finite n) Source #
Instance details

Defined in Data.Finite.Internal

Associated Types

type Rep ( Finite n) :: Type -> Type Source #

NFData ( Finite n) Source #
Instance details

Defined in Data.Finite.Internal

Methods

rnf :: Finite n -> () Source #

type Rep ( Finite n) Source #
Instance details

Defined in Data.Finite.Internal

type Rep ( Finite n) = D1 (' MetaData "Finite" "Data.Finite.Internal" "finite-typelits-0.1.6.0-JWQ68Fc4Po0IMMqLp3mmi2" ' True ) ( C1 (' MetaCons "Finite" ' PrefixI ' False ) ( S1 (' MetaSel (' Nothing :: Maybe Symbol ) ' NoSourceUnpackedness ' NoSourceStrictness ' DecidedLazy ) ( Rec0 Integer )))

finite :: KnownNat n => Integer -> Finite n Source #

Convert an Integer into a Finite , throwing an error if the input is out of bounds.