Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Bytes container (~= Haskell Bytestring)
- Loading branch information
Showing
3 changed files
with
47 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
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,45 @@ | ||
module Prelude.Bytes where | ||
|
||
open import Prelude.Bool | ||
open import Prelude.Decidable | ||
open import Prelude.Equality | ||
open import Prelude.Equality.Unsafe | ||
|
||
{-# IMPORT Data.ByteString #-} | ||
|
||
postulate | ||
Bytes : Set | ||
{-# COMPILED_TYPE Bytes Data.ByteString.ByteString #-} | ||
|
||
|
||
private | ||
module Internal where | ||
postulate | ||
empty : Bytes | ||
append : Bytes → Bytes → Bytes | ||
{-# COMPILED empty Data.ByteString.empty #-} | ||
{-# COMPILED append Data.ByteString.append #-} | ||
|
||
-- Eq -- | ||
|
||
private | ||
postulate eqBytes : Bytes → Bytes → Bool | ||
{-# COMPILED eqBytes (==) #-} | ||
|
||
decEqBytes : (x y : Bytes) → Dec (x ≡ y) | ||
decEqBytes x y with eqBytes x y | ||
... | true = yes unsafeEqual | ||
... | false = no unsafeNotEqual | ||
|
||
instance | ||
EqBytes : Eq Bytes | ||
EqBytes = record { _==_ = decEqBytes } | ||
|
||
-- Monoid -- | ||
|
||
instance | ||
open import Prelude.Monoid | ||
MonoidBytes : Monoid Bytes | ||
MonoidBytes = record { mempty = Internal.empty; _<>_ = Internal.append } | ||
|
||
|
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