Skip to content

Commit

Permalink
Add (from|to)(Z|Q) unicode aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
tbidne committed Dec 9, 2024
1 parent 005db78 commit 1d75fbd
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Numeric/Literal/Integer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
-- @since 0.1
module Numeric.Literal.Integer
( FromInteger (..),
fromℤ,
ToInteger (..),
toℤ,
)
where

Expand Down Expand Up @@ -37,6 +39,12 @@ class FromInteger a where
-- | @since 0.1
fromZ :: (HasCallStack) => Integer -> a

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

-- | @since 0.1
instance FromInteger Double where
fromZ = fromInteger
Expand Down Expand Up @@ -134,6 +142,12 @@ class ToInteger a where
-- | @since 0.1
toZ :: (HasCallStack) => a -> Integer

-- | Unicode alias for 'toZ', with U+2114.
--
-- @since 0.1
toℤ :: (ToInteger a) => a -> Integer
toℤ = toZ

-- | @since 0.1
instance ToInteger Int where
toZ = toInteger
Expand Down
14 changes: 14 additions & 0 deletions src/Numeric/Literal/Rational.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
-- @since 0.1
module Numeric.Literal.Rational
( FromRational (..),
fromℚ,
ToRational (..),
toℚ,
)
where

Expand Down Expand Up @@ -37,6 +39,12 @@ class FromRational a where
-- | @since 0.1
fromQ :: (HasCallStack) => Rational -> a

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

-- | @since 0.1
instance FromRational Double where
fromQ = fromRational
Expand Down Expand Up @@ -72,6 +80,12 @@ class ToRational a where
-- | @since 0.1
toQ :: (HasCallStack) => a -> Rational

-- | Unicode alias for 'toQ', with U+211A.
--
-- @since 0.1
toℚ :: (ToRational a) => a -> Rational
toℚ = toQ

-- | @since 0.1
instance ToRational Double where
toQ = toRational
Expand Down

0 comments on commit 1d75fbd

Please sign in to comment.