Skip to content

Commit 3fd46c3

Browse files
committed
Add instances for ByteArrays
1 parent cd86f7c commit 3fd46c3

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

ChangeLog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.2.2
2+
3+
- Add instances for base and primitive's `ByteArray`s.
4+
15
## 0.2.1.1
26

37
- Support `base-4.16` (GHC-9.2)

src/Data/TreeDiff/Class.hs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,11 @@ import qualified Data.Strict as Strict
106106
import Data.These (These (..))
107107

108108
-- primitive
109-
-- import qualified Data.Primitive as Prim
109+
import qualified Data.Primitive as Prim
110+
111+
#if MIN_VERSION_base(4,17,0)
112+
import Data.Array.Byte (ByteArray (..))
113+
#endif
110114

111115
-- $setup
112116
-- >>> :set -XDeriveGeneric
@@ -593,4 +597,14 @@ instance (ToExpr a, ToExpr b) => ToExpr (These a b) where
593597
-- primitive
594598
-------------------------------------------------------------------------------
595599

596-
-- TODO: add instances
600+
-- | @since 0.2.2
601+
instance ToExpr Prim.ByteArray where
602+
toExpr ba = App "Prim.byteArrayFromList" [toExpr (Prim.foldrByteArray (:) [] ba :: [Word8])]
603+
604+
#if MIN_VERSION_base(4,17,0)
605+
-- | @since 0.2.2
606+
instance ToExpr ByteArray where
607+
toExpr (ByteArray ba) = App "byteArrayFromList" [toExpr (Prim.foldrByteArray (:) [] (Prim.ByteArray ba) :: [Word8])]
608+
#endif
609+
610+
-- TODO: add more instances

0 commit comments

Comments
 (0)