on master help sign in
Re-add Streamly.Serialize and fix cyclic dependency
b5667aeAdithya Kumar
core/src/Streamly/Internal/Data/Serialize.hsnew file+54
@@ -0,0 +1,54 @@
1+{-# LANGUAGE TemplateHaskell #-}
2+
3+-- This is required as all the instances in this module are orphan instances.
4+{-# OPTIONS_GHC -fno-warn-orphans #-}
5+
6+-- |
7+-- Module : Streamly.Internal.Data.Serialize
8+-- Copyright : (c) 2023 Composewell Technologies
9+-- License : BSD3-3-Clause
10+-- Maintainer : streamly@composewell.com
11+-- Portability : GHC
12+--
13+
14+module Streamly.Internal.Data.Serialize
15+ ( module Streamly.Internal.Data.Serialize.Type
16+ ) where
17+
18+--------------------------------------------------------------------------------
19+-- Imports
20+--------------------------------------------------------------------------------
21+
22+import Data.Proxy (Proxy)
23+import Streamly.Internal.Data.Serialize.Type
24+import qualified Streamly.Internal.Data.Serialize.TH as Serialize
25+
26+--------------------------------------------------------------------------------
27+-- Common instances
28+--------------------------------------------------------------------------------
29+
30+-- Note
31+-- ====
32+--
33+-- Even a non-functional change such as changing the order of constructors will
34+-- change the instance derivation.
35+--
36+-- This will not pose a problem if both, encode, and decode are done by the same
37+-- version of the application. There *might* be a problem if version that
38+-- encodes differs from the version that decodes.
39+--
40+-- We need to add some compatibility tests using different versions of
41+-- dependencies.
42+--
43+-- Although such chages for the most basic types won't happen we need to detect
44+-- if it ever happens.
45+--
46+-- Should we worry about these kind of changes and this kind of compatibility?
47+-- This is a problem for all types of derivations that depend on the order of
48+-- constructors, for example, Enum.
49+
50+$(Serialize.deriveSerialize ''Maybe)
51+$(Serialize.deriveSerialize ''Either)
52+$(Serialize.deriveSerializeWith
53+ (Serialize.defaultConfig {Serialize.unconstrained = ["t"]})
54+ ''Proxy)
core/src/Streamly/Internal/Data/Serialize/TH.hs+1−1
@@ -27,7 +27,7 @@ import Streamly.Internal.System.IO (unsafeInlineIO)
27
27
28import Language.Haskell.TH
28import Language.Haskell.TH
29import Language.Haskell.TH.Syntax
29import Language.Haskell.TH.Syntax
30−import Streamly.Internal.Data.Serialize
30+import Streamly.Internal.Data.Serialize.Type
31
31
32import qualified Streamly.Internal.Data.Unbox as Unbox
32import qualified Streamly.Internal.Data.Unbox as Unbox
33
33
core/streamly-core.cabal+2
@@ -421,6 +421,8 @@ library
421
421
422 , Streamly.Internal.Data.Array.Type
422 , Streamly.Internal.Data.Array.Type
423
423
424+ , Streamly.Internal.Data.Serialize.Type
425+
424 , Streamly.Internal.Data.Producer.Type
426 , Streamly.Internal.Data.Producer.Type
425 , Streamly.Internal.Data.Producer.Source
427 , Streamly.Internal.Data.Producer.Source
426
428