overloaded-0.1: Overloaded pragmas as a plugin

Safe HaskellNone
LanguageHaskell2010

Overloaded.Numerals

Description

Another way to desugar overloaded numeric literals. See FromNumeral.

Synopsis

Documentation

class FromNumeral (n :: Nat) a where Source #

Another way to desugar numerals.

A numeric literal 123 is desugared to

fromNumeral @123

Enabled with:

{-# OPTIONS -fplugin=Overloaded -fplugin-opt=Overloaded:Numerals #-}

One can do type-level computations with this.

Methods

fromNumeral :: a Source #

Instances
KnownNat n => FromNumeral n Nat Source # 
Instance details

Defined in Overloaded.Numerals

(KnownNat n, OverflowCheck n "Word8" (n <=? 18446744073709551615)) => FromNumeral n Word64 Source # 
Instance details

Defined in Overloaded.Numerals

(KnownNat n, OverflowCheck n "Word8" (n <=? 4294967295)) => FromNumeral n Word32 Source # 
Instance details

Defined in Overloaded.Numerals

(KnownNat n, OverflowCheck n "Word8" (n <=? 65535)) => FromNumeral n Word16 Source # 
Instance details

Defined in Overloaded.Numerals

(KnownNat n, OverflowCheck n "Word8" (n <=? 255)) => FromNumeral n Word8 Source # 
Instance details

Defined in Overloaded.Numerals

KnownNat n => FromNumeral n Int Source #

TODO: currently there is no range check

Instance details

Defined in Overloaded.Numerals

KnownNat n => FromNumeral n Integer Source # 
Instance details

Defined in Overloaded.Numerals

KnownNat n => FromNumeral n Natural Source # 
Instance details

Defined in Overloaded.Numerals

(FinFromNumeral (FromGHC n) m, IsLess (FromGHC n) m n (ToGHC m)) => FromNumeral n (Fin m) Source # 
Instance details

Defined in Overloaded.Numerals

Methods

fromNumeral :: Fin m Source #

defaultFromNumeral :: forall n a. (KnownNat n, Integral a) => a Source #

Default implementation of fromNumeral.

Usage example:

instance (KnownNat n, ...) => FromNumeral n MyType where
    fromNumeral = defaultFromNumeral @n