Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions Stdlib/Data/Byte.juvix
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ 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.Nat open;
import Stdlib.Data.String.Base open;
import Stdlib.Debug.Fail open;

import Stdlib.Trait.Eq open public;
import Stdlib.Trait.FromNatural open;
Expand All @@ -17,7 +18,20 @@ eqByteI : Eq Byte := Eq.mk (Byte.==);
instance
showByteI : Show Byte :=
Show.mk@{
show (x : Byte) : String := Show.show (Byte.toNat x);
show (x : Byte) : String :=
let
nibble (n : Nat) : String :=
if
| n <= 9 := Show.show n
| n == 10 := "A"
| n == 11 := "B"
| n == 12 := "C"
| n == 13 := "D"
| n == 14 := "E"
| n == 15 := "F"
| else := impossible;
nat := Byte.toNat x;
in "0x" ++str nibble (div nat 16) ++str nibble (mod nat 16);
};

{-# specialize: true, inline: case #-}
Expand Down
2 changes: 2 additions & 0 deletions Stdlib/Debug/Fail.juvix
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ import Stdlib.Data.String.Base open;
--- Exit the program with an error message.
builtin fail
axiom failwith : {A : Type} -> (message : String) -> A;

impossible {A} : A := failwith "impossible";
2 changes: 2 additions & 0 deletions Stdlib/Trait/Show.juvix
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ type Show A :=
mk@{
show : A -> String;
};

open Show using {show} public;
2 changes: 1 addition & 1 deletion test/Package.juvix
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ package : Package :=
"anoma"
"juvix-quickcheck"
"a78bf8da2e14f639f57e2f5e73f6a82fd3a8ff86";
github "anoma" "juvix-test" "d093e3dcc3caaea48433059810b671e38cfb02f7";
github "anoma" "juvix-test" "81a1ee5176055c1002eca0b5f9dcba665986f3ec";
];
};
22 changes: 0 additions & 22 deletions test/juvix.lock.yaml

This file was deleted.