-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
>⚠️ Depends on: > * #117 > * anoma/juvix#2918 Adds support for the builtin Byte type introduced in: * anoma/juvix#2918
- Loading branch information
1 parent
5a4c63a
commit 5424a48
Showing
3 changed files
with
51 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
module Stdlib.Data.Byte; | ||
|
||
import Stdlib.Data.Byte.Base open using {Byte} public; | ||
import Stdlib.Data.Byte.Base as Byte public; | ||
import Stdlib.Function open; | ||
import Stdlib.Data.Nat; | ||
import Stdlib.Data.String.Base open; | ||
|
||
import Stdlib.Trait.Eq open public; | ||
import Stdlib.Trait.FromNatural open; | ||
import Stdlib.Trait.Show open public; | ||
|
||
{-# specialize: true, inline: case #-} | ||
instance | ||
eqByteI : Eq Byte := mkEq (Byte.==); | ||
|
||
instance | ||
showByteI : Show Byte := | ||
mkShow@{ | ||
show := Byte.toNat >> Show.show | ||
}; | ||
|
||
{-# specialize: true, inline: case #-} | ||
instance | ||
fromNaturalByteI : FromNatural Byte := | ||
mkFromNatural@{ | ||
fromNat := Byte.fromNat | ||
}; |
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,22 @@ | ||
module Stdlib.Data.Byte.Base; | ||
|
||
import Stdlib.Data.Bool.Base open; | ||
import Stdlib.Data.Fixity open; | ||
import Stdlib.Data.Nat.Base open; | ||
|
||
--- An 8-bit unsigned integer. | ||
builtin byte | ||
axiom Byte : Type; | ||
|
||
--- Converts a ;Nat; to a ;Byte;. It takes the modulus of the input natural number with 256. | ||
builtin byte-from-nat | ||
axiom fromNat : Nat -> Byte; | ||
|
||
--- Converts a ;Byte; to the corresponding ;Nat;. | ||
builtin byte-to-nat | ||
axiom toNat : Byte -> Nat; | ||
|
||
syntax operator == comparison; | ||
|
||
builtin byte-eq | ||
axiom == : Byte -> Byte -> Bool; |
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