-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from bruderj15/prelude-like-api
Prelude like api
- Loading branch information
Showing
12 changed files
with
129 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{-# LANGUAGE DefaultSignatures #-} | ||
|
||
module Language.Hasmtlib.Integraled where | ||
|
||
import qualified Prelude as P | ||
import Numeric.Natural | ||
import Data.Word | ||
import Data.Functor.Identity | ||
import Data.Functor.Const | ||
|
||
class Integraled a where | ||
quot :: a -> a -> a | ||
n `quot` d = q where (q,_) = quotRem n d | ||
|
||
rem :: a -> a -> a | ||
n `rem` d = r where (_,r) = quotRem n d | ||
|
||
div :: a -> a -> a | ||
n `div` d = q where (q,_) = divMod n d | ||
|
||
mod :: a -> a -> a | ||
n `mod` d = r where (_,r) = divMod n d | ||
|
||
quotRem :: a -> a -> (a, a) | ||
default quotRem :: P.Integral a => a -> a -> (a, a) | ||
quotRem = P.quotRem | ||
|
||
divMod :: a -> a -> (a, a) | ||
default divMod :: P.Integral a => a -> a -> (a, a) | ||
divMod = P.quotRem | ||
|
||
instance Integraled P.Int | ||
instance Integraled P.Integer | ||
instance Integraled P.Word | ||
instance Integraled Natural | ||
instance Integraled Word8 | ||
instance Integraled Word16 | ||
instance Integraled Word32 | ||
instance Integraled Word64 | ||
instance P.Integral a => Integraled (Identity a) | ||
instance P.Integral a => Integraled (Const a b) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.