git.iko.soy/distributed-process
on 6ea27d8 help sign in
distributed-process/distributed-process.cabal+6−6
since splitsnapshots
unifiedsplit
@@ -37,7 +37,6 @@ Library
37 transformers >= 0.2 && < 0.4,
37 transformers >= 0.2 && < 0.4,
38 mtl >= 2.0 && < 2.2,
38 mtl >= 2.0 && < 2.2,
39 data-accessor >= 0.2 && < 0.3,
39 data-accessor >= 0.2 && < 0.3,
40− bytestring >= 0.9 && < 0.11,
41 containers >= 0.4 && < 0.6,
40 containers >= 0.4 && < 0.6,
42 old-locale >= 1.0 && < 1.1,
41 old-locale >= 1.0 && < 1.1,
43 time >= 1.2 && < 1.5,
42 time >= 1.2 && < 1.5,
@@ -46,7 +45,8 @@ Library
46 ghc-prim >= 0.2 && < 0.4,
45 ghc-prim >= 0.2 && < 0.4,
47 distributed-static >= 0.1 && < 0.2,
46 distributed-static >= 0.1 && < 0.2,
48 rank1dynamic >= 0.1 && < 0.2,
47 rank1dynamic >= 0.1 && < 0.2,
49− syb >= 0.3 && < 0.4
48+ syb >= 0.3 && < 0.4,
49+ not-bytestring
50 Exposed-modules: Control.Distributed.Process,
50 Exposed-modules: Control.Distributed.Process,
51 Control.Distributed.Process.Serializable,
51 Control.Distributed.Process.Serializable,
52 Control.Distributed.Process.Closure,
52 Control.Distributed.Process.Closure,
@@ -82,7 +82,6 @@ Test-Suite TestCH
82 transformers >= 0.2 && < 0.4,
82 transformers >= 0.2 && < 0.4,
83 mtl >= 2.0 && < 2.2,
83 mtl >= 2.0 && < 2.2,
84 data-accessor >= 0.2 && < 0.3,
84 data-accessor >= 0.2 && < 0.3,
85− bytestring >= 0.9 && < 0.11,
86 containers >= 0.4 && < 0.6,
85 containers >= 0.4 && < 0.6,
87 old-locale >= 1.0 && < 1.1,
86 old-locale >= 1.0 && < 1.1,
88 time >= 1.2 && < 1.5,
87 time >= 1.2 && < 1.5,
@@ -91,7 +90,8 @@ Test-Suite TestCH
91 ghc-prim >= 0.2 && < 0.4,
90 ghc-prim >= 0.2 && < 0.4,
92 ansi-terminal >= 0.5 && < 0.6,
91 ansi-terminal >= 0.5 && < 0.6,
93 distributed-static >= 0.1 && < 0.2,
92 distributed-static >= 0.1 && < 0.2,
94− rank1dynamic >= 0.1 && < 0.2
93+ rank1dynamic >= 0.1 && < 0.2,
94+ not-bytestring
95 Extensions: RankNTypes,
95 Extensions: RankNTypes,
96 ScopedTypeVariables,
96 ScopedTypeVariables,
97 FlexibleInstances,
97 FlexibleInstances,
@@ -115,7 +115,6 @@ Test-Suite TestClosure
115 transformers >= 0.2 && < 0.4,
115 transformers >= 0.2 && < 0.4,
116 mtl >= 2.0 && < 2.2,
116 mtl >= 2.0 && < 2.2,
117 data-accessor >= 0.2 && < 0.3,
117 data-accessor >= 0.2 && < 0.3,
118− bytestring >= 0.9 && < 0.11,
119 containers >= 0.4 && < 0.6,
118 containers >= 0.4 && < 0.6,
120 old-locale >= 1.0 && < 1.1,
119 old-locale >= 1.0 && < 1.1,
121 time >= 1.2 && < 1.5,
120 time >= 1.2 && < 1.5,
@@ -125,7 +124,8 @@ Test-Suite TestClosure
125 ansi-terminal >= 0.5 && < 0.6,
124 ansi-terminal >= 0.5 && < 0.6,
126 distributed-static >= 0.1 && < 0.2,
125 distributed-static >= 0.1 && < 0.2,
127 rank1dynamic >= 0.1 && < 0.2,
126 rank1dynamic >= 0.1 && < 0.2,
128− syb >= 0.3 && < 0.4
127+ syb >= 0.3 && < 0.4,
128+ not-bytestring
129 Other-modules: TestAuxiliary
129 Other-modules: TestAuxiliary
130 Extensions: RankNTypes,
130 Extensions: RankNTypes,
131 ScopedTypeVariables,
131 ScopedTypeVariables,
distributed-process/src/Control/Distributed/Process.hs+13−6
@@ -294,14 +294,14 @@ spawn nid proc = do
294 `seqCP` proc
294 `seqCP` proc
295 mPid <- receiveWait
295 mPid <- receiveWait
296 [ matchIf (\(DidSpawn ref _) -> ref == sRef)
296 [ matchIf (\(DidSpawn ref _) -> ref == sRef)
297− (\(DidSpawn _ pid) -> return $ Just pid)
297+ (\(DidSpawn _ pid) -> return $ Right pid)
298 , matchIf (\(NodeMonitorNotification ref _ _) -> ref == mRef)
298 , matchIf (\(NodeMonitorNotification ref _ _) -> ref == mRef)
299− (\_ -> return Nothing)
299+ (\(NodeMonitorNotification _ _ err) -> return $ Left err)
300 ]
300 ]
301 unmonitor mRef
301 unmonitor mRef
302 case mPid of
302 case mPid of
303− Nothing -> fail "spawn: remote node failed"
303+ Left err -> fail $ "spawn: remote node failed: " ++ show err
304− Just pid -> send pid () >> return pid
304+ Right pid -> send pid () >> return pid
305
305
306-- | Spawn a process and link to it
306-- | Spawn a process and link to it
307--
307--
@@ -343,8 +343,15 @@ call dict nid proc = do
343 (\(ProcessMonitorNotification _ _ reason) -> return (Left reason))
343 (\(ProcessMonitorNotification _ _ reason) -> return (Left reason))
344 ]
344 ]
345 case mResult of
345 case mResult of
346+ Right a -> do
347+ -- Wait for the monitor message so that we the mailbox doesn't grow
348+ receiveWait
349+ [ matchIf (\(ProcessMonitorNotification ref _ _) -> ref == mRef)
350+ (\(ProcessMonitorNotification {}) -> return ())
351+ ]
346− Right a -> unmonitor mRef >> return a
352+ return a
353+ Left err ->
347− Left err -> fail $ "call: remote process died: " ++ show err
354+ fail $ "call: remote process died: " ++ show err
348
355
349-- | Spawn a child process, have the child link to the parent and the parent
356-- | Spawn a child process, have the child link to the parent and the parent
350-- monitor the child
357-- monitor the child
distributed-process/src/Control/Distributed/Process/Internal/Closure/BuiltIn.hs+2−2
@@ -23,8 +23,8 @@ module Control.Distributed.Process.Internal.Closure.BuiltIn
23 , cpNewChan
23 , cpNewChan
24 ) where
24 ) where
25
25
26−import Data.ByteString.Lazy (ByteString)
26+import Data.NotByteString.Lazy (ByteString)
27−import Data.Binary (decode, encode)
27+import Data.NotByteString.Lazy.Binary (decode, encode)
28import Data.Rank1Typeable (Typeable, ANY, ANY1, ANY2, ANY3, ANY4)
28import Data.Rank1Typeable (Typeable, ANY, ANY1, ANY2, ANY3, ANY4)
29import Data.Rank1Dynamic (toDynamic)
29import Data.Rank1Dynamic (toDynamic)
30import Control.Distributed.Static
30import Control.Distributed.Static
distributed-process/src/Control/Distributed/Process/Internal/Closure/TH.hs+1−1
@@ -39,7 +39,7 @@ import Language.Haskell.TH
39 , funD
39 , funD
40 , sigD
40 , sigD
41 )
41 )
42−import Data.Binary (encode)
42+import Data.NotByteString.Lazy.Binary (encode)
43import Data.Generics (everywhereM, mkM, gmapM)
43import Data.Generics (everywhereM, mkM, gmapM)
44import Data.Rank1Dynamic (toDynamic)
44import Data.Rank1Dynamic (toDynamic)
45import Data.Rank1Typeable
45import Data.Rank1Typeable
distributed-process/src/Control/Distributed/Process/Internal/Node.hs+4−3
@@ -6,9 +6,10 @@ module Control.Distributed.Process.Internal.Node
6 ) where
6 ) where
7
7
8import Data.Accessor ((^.), (^=))
8import Data.Accessor ((^.), (^=))
9−import Data.Binary (Binary, encode)
9+import Data.Binary (Binary)
10+import Data.NotByteString.Lazy.Binary (encode)
10−import qualified Data.ByteString.Lazy as BSL (toChunks)
11+import qualified Data.NotByteString.Lazy as BSL (toChunks)
11−import qualified Data.ByteString as BSS (ByteString)
12+import qualified Data.NotByteString as BSS (ByteString)
12import Control.Distributed.Process.Internal.StrictMVar (withMVar, modifyMVar_)
13import Control.Distributed.Process.Internal.StrictMVar (withMVar, modifyMVar_)
13import Control.Concurrent.Chan (writeChan)
14import Control.Concurrent.Chan (writeChan)
14import Control.Monad (unless)
15import Control.Monad (unless)
distributed-process/src/Control/Distributed/Process/Internal/Primitives.hs+1−1
@@ -65,7 +65,7 @@ module Control.Distributed.Process.Internal.Primitives
65import Prelude hiding (catch)
65import Prelude hiding (catch)
66#endif
66#endif
67
67
68−import Data.Binary (decode)
68+import Data.NotByteString.Lazy.Binary (decode)
69import Data.Time.Clock (getCurrentTime)
69import Data.Time.Clock (getCurrentTime)
70import Data.Time.Format (formatTime)
70import Data.Time.Format (formatTime)
71import System.Locale (defaultTimeLocale)
71import System.Locale (defaultTimeLocale)
distributed-process/src/Control/Distributed/Process/Internal/Types.hs+4−3
@@ -64,9 +64,10 @@ module Control.Distributed.Process.Internal.Types
64import Data.Map (Map)
64import Data.Map (Map)
65import Data.Int (Int32)
65import Data.Int (Int32)
66import Data.Typeable (Typeable)
66import Data.Typeable (Typeable)
67−import Data.Binary (Binary(put, get), putWord8, getWord8, encode)
67+import Data.Binary (Binary(put, get), putWord8, getWord8)
68+import Data.NotByteString.Lazy.Binary (encode)
68−import qualified Data.ByteString as BSS (ByteString, concat)
69+import qualified Data.NotByteString as BSS (ByteString, concat)
69−import qualified Data.ByteString.Lazy as BSL
70+import qualified Data.NotByteString.Lazy as BSL
70 ( ByteString
71 ( ByteString
71 , toChunks
72 , toChunks
72 , splitAt
73 , splitAt
distributed-process/src/Control/Distributed/Process/Node.hs+2−2
@@ -14,8 +14,8 @@ import Prelude hiding (catch)
14#endif
14#endif
15
15
16import System.IO (fixIO, hPutStrLn, stderr)
16import System.IO (fixIO, hPutStrLn, stderr)
17−import qualified Data.ByteString.Lazy as BSL (fromChunks)
17+import qualified Data.NotByteString.Lazy as BSL (fromChunks)
18−import Data.Binary (decode)
18+import Data.NotByteString.Lazy.Binary (decode)
19import Data.Map (Map)
19import Data.Map (Map)
20import qualified Data.Map as Map
20import qualified Data.Map as Map
21 ( empty
21 ( empty
distributed-process/src/Control/Distributed/Process/Serializable.hs+6−6
@@ -15,12 +15,12 @@ import Data.Typeable.Internal (TypeRep(TypeRep))
15import Numeric (showHex)
15import Numeric (showHex)
16import Control.Exception (throw)
16import Control.Exception (throw)
17import GHC.Fingerprint.Type (Fingerprint(..))
17import GHC.Fingerprint.Type (Fingerprint(..))
18−import Data.ByteString (ByteString)
18+import Data.NotByteString (ByteString)
19−import qualified Data.ByteString as BS
19+import qualified Data.NotByteString as BS
20−import qualified Data.ByteString.Internal as BSI ( unsafeCreate
20+import qualified Data.NotByteString.Internal as BSI ( unsafeCreate
21− , inlinePerformIO
21+ , inlinePerformIO
22− , toForeignPtr
22+ , toForeignPtr
23− )
23+ )
24import Foreign.Storable (pokeByteOff, peekByteOff, sizeOf)
24import Foreign.Storable (pokeByteOff, peekByteOff, sizeOf)
25import Foreign.ForeignPtr (withForeignPtr)
25import Foreign.ForeignPtr (withForeignPtr)
26
26
distributed-static/distributed-static.cabal+2−2
@@ -29,8 +29,8 @@ Library
29 Build-Depends: base >= 4 && < 5,
29 Build-Depends: base >= 4 && < 5,
30 rank1dynamic >= 0.1 && < 0.2,
30 rank1dynamic >= 0.1 && < 0.2,
31 containers >= 0.4 && < 0.6,
31 containers >= 0.4 && < 0.6,
32− bytestring >= 0.9 && < 0.11,
33− binary >= 0.5 && < 0.6
32+ binary >= 0.5 && < 0.6,
33+ not-bytestring
34 HS-Source-Dirs: src
34 HS-Source-Dirs: src
35 Extensions: DeriveDataTypeable,
35 Extensions: DeriveDataTypeable,
36 ScopedTypeVariables
36 ScopedTypeVariables
distributed-static/src/Control/Distributed/Static.hs+2−3
@@ -228,10 +228,9 @@ import Data.Binary
228 , Get
228 , Get
229 , putWord8
229 , putWord8
230 , getWord8
230 , getWord8
231− , encode
232− , decode
233 )
231 )
232+import Data.NotByteString.Lazy.Binary (decode, encode)
234−import Data.ByteString.Lazy (ByteString, empty)
233+import Data.NotByteString.Lazy (ByteString, empty)
235import Data.Map (Map)
234import Data.Map (Map)
236import qualified Data.Map as Map (lookup, empty, insert)
235import qualified Data.Map as Map (lookup, empty, insert)
237import Control.Applicative ((<$>), (<*>))
236import Control.Applicative ((<$>), (<*>))
network-transport-tcp/network-transport-tcp.cabal+5−3
@@ -25,8 +25,9 @@ Library
25 network-transport >= 0.2 && < 0.3,
25 network-transport >= 0.2 && < 0.3,
26 data-accessor >= 0.2 && < 0.3,
26 data-accessor >= 0.2 && < 0.3,
27 containers >= 0.4 && < 0.6,
27 containers >= 0.4 && < 0.6,
28+ network >= 2.3 && < 2.4,
28 bytestring >= 0.9 && < 0.11,
29 bytestring >= 0.9 && < 0.11,
29− network >= 2.3 && < 2.4
30+ not-bytestring
30 Exposed-modules: Network.Transport.TCP,
31 Exposed-modules: Network.Transport.TCP,
31 Network.Transport.TCP.Internal
32 Network.Transport.TCP.Internal
32 Extensions: CPP
33 Extensions: CPP
@@ -40,11 +41,12 @@ Test-Suite TestTCP
40 network-transport >= 0.2 && < 0.3,
41 network-transport >= 0.2 && < 0.3,
41 data-accessor >= 0.2 && < 0.3,
42 data-accessor >= 0.2 && < 0.3,
42 containers >= 0.4 && < 0.6,
43 containers >= 0.4 && < 0.6,
43− bytestring >= 0.9 && < 0.11,
44 network >= 2.3 && < 2.4,
44 network >= 2.3 && < 2.4,
45 random >= 1.0 && < 1.1,
45 random >= 1.0 && < 1.1,
46 ansi-terminal >= 0.5 && < 0.6,
46 ansi-terminal >= 0.5 && < 0.6,
47− mtl >= 2.0 && < 2.2
47+ mtl >= 2.0 && < 2.2,
48+ bytestring >= 0.9 && < 0.11,
49+ not-bytestring
48 Other-modules: TestAuxiliary,
50 Other-modules: TestAuxiliary,
49 TestTransport,
51 TestTransport,
50 Traced
52 Traced
network-transport-tcp/src/Network/Transport/TCP.hs+5−5
@@ -66,7 +66,7 @@ import qualified Network.Socket as N ( HostName
66 , sOMAXCONN
66 , sOMAXCONN
67 , AddrInfo
67 , AddrInfo
68 )
68 )
69−import Network.Socket.ByteString (sendMany)
69+import Data.NotByteString.NBS (sendMany)
70import Control.Concurrent (forkIO, ThreadId, killThread, myThreadId)
70import Control.Concurrent (forkIO, ThreadId, killThread, myThreadId)
71import Control.Concurrent.Chan (Chan, newChan, readChan, writeChan)
71import Control.Concurrent.Chan (Chan, newChan, readChan, writeChan)
72import Control.Concurrent.MVar ( MVar
72import Control.Concurrent.MVar ( MVar
@@ -95,9 +95,9 @@ import Control.Exception ( IOException
95 , fromException
95 , fromException
96 )
96 )
97import Data.IORef (IORef, newIORef, writeIORef, readIORef)
97import Data.IORef (IORef, newIORef, writeIORef, readIORef)
98−import Data.ByteString (ByteString)
98+import Data.NotByteString (ByteString)
99−import qualified Data.ByteString as BS (concat)
99+import qualified Data.NotByteString as BS (concat)
100−import qualified Data.ByteString.Char8 as BSC (pack, unpack, split)
100+import qualified Data.NotByteString.Char8 as BSC (pack, unpack, split)
101import Data.Int (Int32)
101import Data.Int (Int32)
102import Data.IntMap (IntMap)
102import Data.IntMap (IntMap)
103import qualified Data.IntMap as IntMap (empty)
103import qualified Data.IntMap as IntMap (empty)
@@ -1155,7 +1155,7 @@ setupRemoteEndPoint params (ourEndPoint, theirEndPoint) hints = do
1155 { remoteSocket = sock
1155 { remoteSocket = sock
1156 , _remoteOutgoing = 0
1156 , _remoteOutgoing = 0
1157 , _remoteIncoming = IntSet.empty
1157 , _remoteIncoming = IntSet.empty
1158− , sendOn = sendMany sock
1158+ , sendOn = sendMany sock
1159 , _pendingCtrlRequests = IntMap.empty
1159 , _pendingCtrlRequests = IntMap.empty
1160 , _nextCtrlRequestId = 0
1160 , _nextCtrlRequestId = 0
1161 }
1161 }
network-transport-tcp/src/Network/Transport/TCP/Internal.hs+3−3
@@ -28,13 +28,13 @@ import qualified Network.Socket as N ( HostName
28 , accept
28 , accept
29 , sClose
29 , sClose
30 )
30 )
31−import qualified Network.Socket.ByteString as NBS (recv)
31+import qualified Data.NotByteString.NBS as NBS (recv)
32import Control.Concurrent (ThreadId)
32import Control.Concurrent (ThreadId)
33import Control.Monad (forever, when)
33import Control.Monad (forever, when)
34import Control.Exception (SomeException, catch, bracketOnError, throwIO, mask_)
34import Control.Exception (SomeException, catch, bracketOnError, throwIO, mask_)
35import Control.Applicative ((<$>))
35import Control.Applicative ((<$>))
36−import Data.ByteString (ByteString)
36+import Data.NotByteString (ByteString)
37−import qualified Data.ByteString as BS (length, concat, null)
37+import qualified Data.NotByteString as BS (length, concat, null)
38import Data.Int (Int32)
38import Data.Int (Int32)
39
39
40-- | Start a server at the specified address.
40-- | Start a server at the specified address.
network-transport/network-transport.cabal+2−2
@@ -66,8 +66,8 @@ Source-Repository head
66Library
66Library
67 Build-Depends: base >= 4.3 && < 5,
67 Build-Depends: base >= 4.3 && < 5,
68 binary >= 0.5 && < 0.6,
68 binary >= 0.5 && < 0.6,
69− bytestring >= 0.9 && < 0.11,
70− transformers >= 0.2 && < 0.4
69+ transformers >= 0.2 && < 0.4,
70+ not-bytestring
71 Exposed-Modules: Network.Transport,
71 Exposed-Modules: Network.Transport,
72 Network.Transport.Util
72 Network.Transport.Util
73 Network.Transport.Internal
73 Network.Transport.Internal
network-transport/src/Network/Transport.hs+2−2
@@ -22,8 +22,8 @@ module Network.Transport ( -- * Types
22 , EventErrorCode(..)
22 , EventErrorCode(..)
23 ) where
23 ) where
24
24
25−import Data.ByteString (ByteString)
25+import Data.NotByteString (ByteString)
26−import qualified Data.ByteString.Char8 as BSC (unpack)
26+import qualified Data.NotByteString.Char8 as BSC (unpack)
27import Control.Exception (Exception)
27import Control.Exception (Exception)
28import Data.Typeable (Typeable)
28import Data.Typeable (Typeable)
29import Data.Binary (Binary)
29import Data.Binary (Binary)
network-transport/src/Network/Transport/Internal.hs+5−5
@@ -25,11 +25,11 @@ import Prelude hiding (catch)
25import Foreign.Storable (pokeByteOff, peekByteOff)
25import Foreign.Storable (pokeByteOff, peekByteOff)
26import Foreign.C (CInt(..), CShort(..))
26import Foreign.C (CInt(..), CShort(..))
27import Foreign.ForeignPtr (withForeignPtr)
27import Foreign.ForeignPtr (withForeignPtr)
28−import Data.ByteString (ByteString)
28+import Data.NotByteString (ByteString)
29−import qualified Data.ByteString as BS (length)
29+import qualified Data.NotByteString as BS (length)
30−import qualified Data.ByteString.Internal as BSI ( unsafeCreate
30+import qualified Data.NotByteString.Internal as BSI ( unsafeCreate
31− , toForeignPtr
31+ , toForeignPtr
32− , inlinePerformIO)
32+ , inlinePerformIO)
33import Control.Monad.IO.Class (MonadIO, liftIO)
33import Control.Monad.IO.Class (MonadIO, liftIO)
34import Control.Exception ( IOException
34import Control.Exception ( IOException
35 , SomeException
35 , SomeException
not-bytestring/LICENSEnew file+30
@@ -0,0 +1,30 @@
1+Copyright (c) 2012, Edsko de Vries
2+
3+All rights reserved.
4+
5+Redistribution and use in source and binary forms, with or without
6+modification, are permitted provided that the following conditions are met:
7+
8+ * Redistributions of source code must retain the above copyright
9+ notice, this list of conditions and the following disclaimer.
10+
11+ * Redistributions in binary form must reproduce the above
12+ copyright notice, this list of conditions and the following
13+ disclaimer in the documentation and/or other materials provided
14+ with the distribution.
15+
16+ * Neither the name of Edsko de Vries nor the names of other
17+ contributors may be used to endorse or promote products derived
18+ from this software without specific prior written permission.
19+
20+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
not-bytestring/Setup.hsnew file+2
@@ -0,0 +1,2 @@
1+import Distribution.Simple
2+main = defaultMain
not-bytestring/not-bytestring.cabalnew file+33
@@ -0,0 +1,33 @@
1+-- Initial not-bytestring.cabal generated by cabal init. For further
2+-- documentation, see http://haskell.org/cabal/users-guide/
3+
4+name: not-bytestring
5+version: 0.1.0.0
6+synopsis: Not bytestring
7+-- description:
8+homepage: http://github.com/haskell-distribute/distributed-process
9+license: BSD3
10+license-file: LICENSE
11+author: Edsko de Vries
12+maintainer: edsko@well-typed.com
13+-- copyright:
14+category: Data
15+build-type: Simple
16+cabal-version: >=1.8
17+
18+library
19+ exposed-modules: Data.NotByteString
20+ Data.NotByteString.Internal
21+ Data.NotByteString.Char8
22+ Data.NotByteString.Lazy
23+ Data.NotByteString.Lazy.Char8
24+ Data.NotByteString.NBS
25+ Data.NotByteString.Lazy.Binary
26+ build-depends: base ==4.5.*,
27+ bytestring >= 0.9 && < 0.11,
28+ binary >= 0.5 && < 0.6,
29+ network >= 2.3 && < 2.4
30+ hs-source-dirs: src
31+ ghc-options: -Wall
32+ extensions: GeneralizedNewtypeDeriving,
33+ DeriveDataTypeable
not-bytestring/src/Data/NotByteString.hsnew file+50
@@ -0,0 +1,50 @@
1+module Data.NotByteString
2+ ( ByteString
3+ , fromString
4+ , toString
5+ , fromByteString
6+ , toByteString
7+ , length
8+ , concat
9+ , null
10+ , empty
11+ , splitAt
12+ ) where
13+
14+import Prelude hiding (length, null, concat, splitAt)
15+import qualified Prelude (length, null, splitAt)
16+import Data.Binary (Binary)
17+import Data.Typeable (Typeable)
18+import qualified Data.ByteString as BS (ByteString)
19+import qualified Data.ByteString.Char8 as BSC (pack, unpack)
20+import Control.Arrow ((***))
21+
22+newtype ByteString = NotByteString { toString :: String }
23+ deriving (Eq, Ord, Binary, Typeable)
24+
25+instance Show ByteString where
26+ show = toString
27+
28+fromString :: String -> ByteString
29+fromString = NotByteString
30+
31+fromByteString :: BS.ByteString -> ByteString
32+fromByteString = fromString . BSC.unpack
33+
34+toByteString :: ByteString -> BS.ByteString
35+toByteString = BSC.pack . toString
36+
37+length :: ByteString -> Int
38+length = Prelude.length . toString
39+
40+concat :: [ByteString] -> ByteString
41+concat = fromString . concatMap toString
42+
43+null :: ByteString -> Bool
44+null = Prelude.null . toString
45+
46+empty :: ByteString
47+empty = fromString ""
48+
49+splitAt :: Int -> ByteString -> (ByteString, ByteString)
50+splitAt i = (fromString *** fromString) . Prelude.splitAt i . toString
not-bytestring/src/Data/NotByteString/Char8.hsnew file+23
@@ -0,0 +1,23 @@
1+module Data.NotByteString.Char8
2+ ( pack
3+ , unpack
4+ , split
5+ ) where
6+
7+import Data.NotByteString
8+ ( ByteString
9+ , fromString
10+ , toString
11+ , fromByteString
12+ , toByteString
13+ )
14+import qualified Data.ByteString.Char8 as BSC (split)
15+
16+pack :: String -> ByteString
17+pack = fromString
18+
19+unpack :: ByteString -> String
20+unpack = toString
21+
22+split :: Char -> ByteString -> [ByteString]
23+split c = map fromByteString . BSC.split c . toByteString
not-bytestring/src/Data/NotByteString/Internal.hsnew file+24
@@ -0,0 +1,24 @@
1+module Data.NotByteString.Internal
2+ ( unsafeCreate
3+ , toForeignPtr
4+ , inlinePerformIO
5+ ) where
6+
7+import Data.NotByteString (ByteString, fromByteString, toByteString)
8+import Foreign.Ptr (Ptr)
9+import Foreign.ForeignPtr (ForeignPtr)
10+import Data.Word (Word8)
11+import qualified Data.ByteString.Internal as BSI
12+ ( unsafeCreate
13+ , toForeignPtr
14+ , inlinePerformIO
15+ )
16+
17+unsafeCreate :: Int -> (Ptr Word8 -> IO ()) -> ByteString
18+unsafeCreate i f = fromByteString $ BSI.unsafeCreate i f
19+
20+toForeignPtr :: ByteString -> (ForeignPtr Word8, Int, Int)
21+toForeignPtr = BSI.toForeignPtr . toByteString
22+
23+inlinePerformIO :: IO a -> a
24+inlinePerformIO = BSI.inlinePerformIO
not-bytestring/src/Data/NotByteString/Lazy.hsnew file+40
@@ -0,0 +1,40 @@
1+module Data.NotByteString.Lazy
2+ ( ByteString
3+ , fromString
4+ , toString
5+ , fromByteString
6+ , toByteString
7+ , length
8+ , concat
9+ , null
10+ , empty
11+ , splitAt
12+ , toChunks
13+ , fromChunks
14+ ) where
15+
16+import Prelude hiding (length, concat, null, splitAt)
17+import Data.NotByteString
18+ ( ByteString
19+ , fromString
20+ , toString
21+ , length
22+ , concat
23+ , null
24+ , empty
25+ , splitAt
26+ )
27+import qualified Data.ByteString.Lazy as BSL (ByteString)
28+import qualified Data.ByteString.Lazy.Char8 as BSLC (pack, unpack)
29+
30+fromByteString :: BSL.ByteString -> ByteString
31+fromByteString = fromString . BSLC.unpack
32+
33+toByteString :: ByteString -> BSL.ByteString
34+toByteString = BSLC.pack . toString
35+
36+toChunks :: ByteString -> [ByteString]
37+toChunks = return
38+
39+fromChunks :: [ByteString] -> ByteString
40+fromChunks = concat
not-bytestring/src/Data/NotByteString/Lazy/Binary.hsnew file+14
@@ -0,0 +1,14 @@
1+module Data.NotByteString.Lazy.Binary
2+ ( encode
3+ , decode
4+ ) where
5+
6+import Data.NotByteString.Lazy (ByteString, fromByteString, toByteString)
7+import Data.Binary (Binary)
8+import qualified Data.Binary as Binary (encode, decode)
9+
10+encode :: Binary a => a -> ByteString
11+encode = fromByteString . Binary.encode
12+
13+decode :: Binary a => ByteString -> a
14+decode = Binary.decode . toByteString
not-bytestring/src/Data/NotByteString/Lazy/Char8.hsnew file+5
@@ -0,0 +1,5 @@
1+module Data.NotByteString.Lazy.Char8
2+ ( module Data.NotByteString.Char8
3+ ) where
4+
5+import Data.NotByteString.Char8
not-bytestring/src/Data/NotByteString/NBS.hsnew file+15
@@ -0,0 +1,15 @@
1+module Data.NotByteString.NBS
2+ ( recv
3+ , sendMany
4+ ) where
5+
6+import Control.Applicative ((<$>))
7+import Data.NotByteString (ByteString, fromByteString, toByteString)
8+import Network.Socket (Socket)
9+import qualified Network.Socket.ByteString as NSB (recv, sendMany)
10+
11+recv :: Socket -> Int -> IO ByteString
12+recv sock n = fromByteString <$> NSB.recv sock n
13+
14+sendMany :: Socket -> [ByteString] -> IO ()
15+sendMany sock = NSB.sendMany sock . map toByteString