Skip to content

Commit

Permalink
Add Serialize instance for Lazy Text
Browse files Browse the repository at this point in the history
  • Loading branch information
adithyaov committed Sep 21, 2023
1 parent 68b4d56 commit e5c8689
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
7 changes: 0 additions & 7 deletions src/Streamly/Data/Serialize/Instances.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@
-- Stability : experimental
-- Portability : GHC

{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE RecordWildCards #-}

-- This is required as all the instances in this module are orphan instances.
{-# OPTIONS_GHC -fno-warn-orphans #-}

module Streamly.Data.Serialize.Instances () where

--------------------------------------------------------------------------------
Expand Down
7 changes: 4 additions & 3 deletions src/Streamly/Data/Serialize/Instances/Text.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
-- This is required as all the instances in this module are orphan instances.
{-# OPTIONS_GHC -fno-warn-orphans #-}

-- |
-- Module : Streamly.Data.Serialize.Instances
-- Copyright : (c) 2023 Composewell technologies
Expand All @@ -20,7 +17,9 @@ import Streamly.Internal.Data.Serialize (Serialize(..))
import Streamly.Internal.Data.Unbox (MutableByteArray(..))

import qualified Data.Text.Internal as Strict (Text(..))
import qualified Data.Text.Lazy as Lazy
import qualified Streamly.Internal.Data.Unbox as Unbox
import qualified Streamly.Internal.Data.Serialize.TH as Serialize

#if MIN_VERSION_text(2,0,0)

Expand Down Expand Up @@ -84,3 +83,5 @@ instance Serialize Strict.Text where
--------------------------------------------------------------------------------
-- Lazy Text
--------------------------------------------------------------------------------

$(Serialize.deriveSerialize ''Lazy.Text)
5 changes: 4 additions & 1 deletion streamly-serialize-instances.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ extra-doc-files: CHANGELOG.md
-- extra-source-files:

common warnings
ghc-options: -Wall -Werror
-- -fno-warn-orphans is required as all the instances in this package are
-- orphan instances.
ghc-options: -Wall -Werror -fno-warn-orphans

common default-extensions
default-extensions:
Expand Down Expand Up @@ -84,6 +86,7 @@ common default-extensions
TypeFamilies
TypeOperators
ViewPatterns
TemplateHaskell

library
-- Import common warning flags.
Expand Down
4 changes: 4 additions & 0 deletions test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import qualified Streamly.Internal.Data.Serialize as Serialize
import Data.Time (UTCTime)

import qualified Data.Text as TextS
import qualified Data.Text.Lazy as TextL

import Test.Hspec.QuickCheck
import Test.Hspec as H
Expand Down Expand Up @@ -88,6 +89,9 @@ testCases = do
prop "Strict Text"
$ \(x :: TextS.Text) -> roundtrip x

prop "Lazy Text"
$ \(x :: TextL.Text) -> roundtrip x

--------------------------------------------------------------------------------
-- Main
--------------------------------------------------------------------------------
Expand Down

0 comments on commit e5c8689

Please sign in to comment.