| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Bytes: simple bindings to Haskell types and functions |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
{-# OPTIONS --cubical-compatible #-} |
| 8 |
|
| 9 |
module Data.Word8.Primitive where |
| 10 |
|
| 11 |
open import Agda.Builtin.Bool using (Bool) |
| 12 |
open import Agda.Builtin.Nat using (Nat) |
| 13 |
open import Agda.Builtin.String using (String) |
| 14 |
|
| 15 |
postulate |
| 16 |
Word8 : Set |
| 17 |
testBit : Word8 → Nat → Bool |
| 18 |
setBit : Word8 → Nat → Word8 |
| 19 |
clearBit : Word8 → Nat → Word8 |
| 20 |
fromNat : Nat → Word8 |
| 21 |
toNat : Word8 → Nat |
| 22 |
_+_ : Word8 → Word8 → Word8 |
| 23 |
show : Word8 → String |
| 24 |
|
| 25 |
{-# FOREIGN GHC import GHC.Word #-} |
| 26 |
{-# FOREIGN GHC import qualified Data.Bits as B #-} |
| 27 |
{-# FOREIGN GHC import qualified Data.Text as T #-} |
| 28 |
|
| 29 |
{-# COMPILE GHC Word8 = type Word8 #-} |
| 30 |
{-# COMPILE GHC testBit = \ w -> B.testBit w . fromIntegral #-} |
| 31 |
{-# COMPILE GHC setBit = \ w -> B.setBit w . fromIntegral #-} |
| 32 |
{-# COMPILE GHC clearBit = \ w -> B.clearBit w . fromIntegral #-} |
| 33 |
{-# COMPILE GHC fromNat = fromIntegral #-} |
| 34 |
{-# COMPILE GHC toNat = fromIntegral #-} |
| 35 |
{-# COMPILE GHC _+_ = (+) #-} |
| 36 |
{-# COMPILE GHC show = T.pack . Prelude.show #-} |