on master help sign in
Move some types into an internal module that is shared.
75c299bBryan O'Sullivan
Data/Text/Encoding/Fusion/Common.hs+1−7
@@ -30,16 +30,10 @@ module Data.Text.Encoding.Fusion.Common
30import Data.Bits (shiftL, shiftR, (.&.))
30import Data.Bits (shiftL, shiftR, (.&.))
31import Data.Char (ord)
31import Data.Char (ord)
32import Data.Text.Fusion (Step(..), Stream(..))
32import Data.Text.Fusion (Step(..), Stream(..))
33−import Data.Text.Fusion.Internal (M(..))
33+import Data.Text.Fusion.Internal (M(..), S(..))
34import Data.Word (Word8)
34import Data.Word (Word8)
35import qualified Data.Text.Encoding.Utf8 as U8
35import qualified Data.Text.Encoding.Utf8 as U8
36
36
37−type M8 = M Word8
38−
39−-- Restreaming state.
40−data S s = S {-# UNPACK #-} !s
41− {-# UNPACK #-} !M8 {-# UNPACK #-} !M8 {-# UNPACK #-} !M8
42−
43-- | /O(n)/ Convert a Stream Char into a UTF-8 encoded Stream Word8.
37-- | /O(n)/ Convert a Stream Char into a UTF-8 encoded Stream Word8.
44restreamUtf8 :: Stream Char -> Stream Word8
38restreamUtf8 :: Stream Char -> Stream Word8
45restreamUtf8 (Stream next0 s0 len) =
39restreamUtf8 (Stream next0 s0 len) =
Data/Text/Fusion/Internal.hs+13−1
@@ -16,24 +16,36 @@
16module Data.Text.Fusion.Internal
16module Data.Text.Fusion.Internal
17 (
17 (
18 M(..)
18 M(..)
19+ , M8
19 , PairS(..)
20 , PairS(..)
20− , Switch(..)
21+ , S(..)
21 , Step(..)
22 , Step(..)
22 , Stream(..)
23 , Stream(..)
24+ , Switch(..)
23 , empty
25 , empty
24 ) where
26 ) where
25
27
28+import Data.Word (Word8)
29+
26-- | Specialised, strict Maybe-like type.
30-- | Specialised, strict Maybe-like type.
27data M a = N
31data M a = N
28 | J {-# UNPACK #-} !a
32 | J {-# UNPACK #-} !a
29 deriving (Eq, Ord, Show)
33 deriving (Eq, Ord, Show)
30
34
35+type M8 = M Word8
36+
37+-- Restreaming state.
38+data S s = S {-# UNPACK #-} !s
39+ {-# UNPACK #-} !M8 {-# UNPACK #-} !M8 {-# UNPACK #-} !M8
40+ deriving (Eq, Ord, Show)
41+
31infixl 2 :!:
42infixl 2 :!:
32data PairS a b = !a :!: !b
43data PairS a b = !a :!: !b
33 deriving (Eq, Ord, Read, Show)
44 deriving (Eq, Ord, Read, Show)
34
45
35-- | Allow a function over a stream to switch between two states.
46-- | Allow a function over a stream to switch between two states.
36data Switch = S1 | S2
47data Switch = S1 | S2
48+ deriving (Eq, Ord, Show)
37
49
38data Step s a = Done
50data Step s a = Done
39 | Skip !s
51 | Skip !s