Safe Haskell | None |
---|---|
Language | Haskell2010 |
Another way to desugar overloaded numeric literals. See FromNumeral
.
Synopsis
- class FromNumeral (n :: Nat) a where
- fromNumeral :: a
- defaultFromNumeral :: forall n a. (KnownNat n, Integral a) => a
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.
fromNumeral :: a Source #
Instances
defaultFromNumeral :: forall n a. (KnownNat n, Integral a) => a Source #
Default implementation of fromNumeral
.
Usage example:
instance (KnownNat
n, ...) =>FromNumeral
n MyType wherefromNumeral
=defaultFromNumeral
@n