typenums-0.1.1: Type level numbers using existing Nat functionality

Copyright(c) 2018 Iris Ward
LicenseBSD3
Maintaineraditu.venyhandottir@gmail.com
Stabilityexperimental
Safe HaskellTrustworthy
LanguageHaskell2010

Data.TypeNums.Rats

Contents

Description

Type level rational numbers expressed as a ratio between a type-level integer and a type-level natural. For example Neg 3 :% 2.

See also: Data.TypeInts

Synopsis

Construction

data Rat Source #

Type constructor for a rational

Constructors

k :% Nat 

Instances

(KnownInt k n, KnownNat d, (/=) Nat d 0) => KnownRat Rat ((:%) k n d) Source # 

Methods

ratSing :: SRat ((k :% n) d) r

TypeError Constraint (Text "Denominator must not equal 0") => KnownRat Rat ((:%) k n 0) Source # 

Methods

ratSing :: SRat ((k :% n) 0) r

Linking type and value level

class KnownRat r Source #

This class gives the (value-level) rational associated with a type-level rational. There are instances of this class for every combination of a concrete integer and concrete natural.

Minimal complete definition

ratSing

Instances

KnownInt k n => KnownRat k n Source # 

Methods

ratSing :: SRat n r

(KnownInt k n, KnownNat d, (/=) Nat d 0) => KnownRat Rat ((:%) k n d) Source # 

Methods

ratSing :: SRat ((k :% n) d) r

TypeError Constraint (Text "Denominator must not equal 0") => KnownRat Rat ((:%) k n 0) Source # 

Methods

ratSing :: SRat ((k :% n) 0) r

ratVal :: forall proxy r. KnownRat r => proxy r -> Rational Source #

Get the value associated with a type-level rational

ratVal' :: forall r. KnownRat r => Proxy# r -> Rational Source #

Get the value associated with a type-level rational. The difference between this function and ratVal is that it takes a Proxy# parameter, which has zero runtime representation and so is entirely free.

data SomeRat Source #

This type represents unknown type-level integers.

Since: 0.1.1

Constructors

KnownRat r => SomeRat (Proxy r) 

someRatVal :: Rational -> SomeRat Source #

Convert a rational into an unknown type-level rational.

Since: 0.1.1