Skip to content

Commit

Permalink
Add more unicode aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
tbidne committed Feb 7, 2025
1 parent 973852f commit 37ec712
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 12 deletions.
1 change: 1 addition & 0 deletions algebra-simple.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ source-repository head
common common-exts
default-extensions:
BangPatterns
ConstraintKinds
DataKinds
DeriveAnyClass
DeriveFunctor
Expand Down
29 changes: 25 additions & 4 deletions src/Numeric/Convert/Integer.hs
Original file line number Diff line number Diff line change
@@ -1,25 +1,46 @@
-- | Provides the 'FromInteger' and 'ToInteger' typeclasses.
-- | Provides the 'Internal.FromInteger' and 'Internal.ToInteger'
-- typeclasses.
--
-- @since 0.1
module Numeric.Convert.Integer
( Internal.FromInteger (..),
fromℤ,
Internal.ToInteger (..),

-- * Aliases
,
Fromℤ,
fromℤ,
Toℤ,
toℤ,
)
where

import GHC.Stack (HasCallStack)
import Numeric.Convert.Internal qualified as Internal

-- | Unicode alias for 'Integer', with U+2114.
--
-- @since 0.1
type = Integer

-- | Unicode alias for 'Internal.FromInteger', with U+2114.
--
-- @since 0.1
type Fromℤ = Internal.FromInteger

-- | Unicode alias for 'Internal.fromZ', with U+2114.
--
-- @since 0.1
fromℤ :: (Internal.FromInteger a, HasCallStack) => Integer -> a
fromℤ :: (Fromℤ a, HasCallStack) => -> a
fromℤ = Internal.fromZ

-- | Unicode alias for 'Internal.ToInteger', with U+2114.
--
-- @since 0.1
type Toℤ = Internal.ToInteger

-- | Unicode alias for 'Internal.toZ', with U+2114.
--
-- @since 0.1
toℤ :: (HasCallStack, Internal.ToInteger a) => a -> Integer
toℤ :: (HasCallStack, Toℤ a) => a ->
toℤ = Internal.toZ
29 changes: 25 additions & 4 deletions src/Numeric/Convert/Rational.hs
Original file line number Diff line number Diff line change
@@ -1,25 +1,46 @@
-- | Provides the 'FromRational' and 'ToRational typeclasses.
-- | Provides the 'Internal.FromRational' and 'Internal.ToRational
-- typeclasses.
--
-- @since 0.1
module Numeric.Convert.Rational
( Internal.FromRational (..),
fromℚ,
Internal.ToRational (..),

-- * Aliases
,
Fromℚ,
fromℚ,
Toℚ,
toℚ,
)
where

import GHC.Stack (HasCallStack)
import Numeric.Convert.Internal qualified as Internal

-- | Unicode alias for 'Rational', with U+211A.
--
-- @since 0.1
type = Rational

-- | Unicode alias for 'Internal.FromRational', with U+211A.
--
-- @since 0.1
type Fromℚ = Internal.FromRational

-- | Unicode alias for 'Internal.fromQ', with U+211A.
--
-- @since 0.1
fromℚ :: (Internal.FromRational a, HasCallStack) => Rational -> a
fromℚ :: (Fromℚ a, HasCallStack) => -> a
fromℚ = Internal.fromQ

-- | Unicode alias for 'Internal.ToRational', with U+211A.
--
-- @since 0.1
type Toℚ = Internal.ToRational

-- | Unicode alias for 'Internal.toQ', with U+211A.
--
-- @since 0.1
toℚ :: (HasCallStack, Internal.ToRational a) => a -> Rational
toℚ :: (HasCallStack, Toℚ a) => a ->
toℚ = Internal.toQ
28 changes: 24 additions & 4 deletions src/Numeric/Convert/Real.hs
Original file line number Diff line number Diff line change
@@ -1,25 +1,45 @@
-- | Provides the 'FromReal' and 'ToReal' typeclasses.
-- | Provides the 'Internal.FromReal' and 'Internal.ToReal' typeclasses.
--
-- @since 0.1
module Numeric.Convert.Real
( Internal.FromReal (..),
fromℝ,
Internal.ToReal (..),

-- * Aliases
,
Fromℝ,
fromℝ,
Toℝ,
toℝ,
)
where

import GHC.Stack (HasCallStack)
import Numeric.Convert.Internal qualified as Internal

-- | Unicode alias for 'Double', with U+211D.
--
-- @since 0.1
type = Double

-- | Unicode alias for 'Internal.FromReal', with U+211D.
--
-- @since 0.1
type Fromℝ = Internal.FromReal

-- | Unicode alias for 'Internal.fromR', with U+211D.
--
-- @since 0.1
fromℝ :: (Internal.FromReal a, HasCallStack) => Double -> a
fromℝ :: (Fromℝ a, HasCallStack) => -> a
fromℝ = Internal.fromR

-- | Unicode alias for 'Internal.ToReal', with U+211D.
--
-- @since 0.1
type Toℝ = Internal.ToReal

-- | Unicode alias for 'Internal.toR', with U+211D.
--
-- @since 0.1
toℝ :: (HasCallStack, Internal.ToReal a) => a -> Double
toℝ :: (HasCallStack, Toℝ a) => a ->
toℝ = Internal.toR

0 comments on commit 37ec712

Please sign in to comment.