git.iko.soy/distributed-process
on fcfc19d help sign in
27 files changed+303−57
since splitsnapshots
unifiedsplit
distributed-process/distributed-process.cabal+6−6 distributed-process/src/Control/Distributed/Process.hs+13−6 distributed-process/src/Control/Distributed/Process/Internal/Closure/BuiltIn.hs+2−2 distributed-process/src/Control/Distributed/Process/Internal/Closure/TH.hs+1−1 distributed-process/src/Control/Distributed/Process/Internal/Node.hs+6−5 distributed-process/src/Control/Distributed/Process/Internal/Primitives.hs+1−1 distributed-process/src/Control/Distributed/Process/Internal/Types.hs+4−3 distributed-process/src/Control/Distributed/Process/Node.hs+2−2 distributed-process/src/Control/Distributed/Process/Serializable.hs+6−6 distributed-static/distributed-static.cabal+2−2 distributed-static/src/Control/Distributed/Static.hs+2−3 network-transport-tcp/network-transport-tcp.cabal+5−3 network-transport-tcp/src/Network/Transport/TCP.hs+5−5 network-transport-tcp/src/Network/Transport/TCP/Internal.hs+3−3 network-transport/network-transport.cabal+2−2 network-transport/src/Network/Transport.hs+2−2 network-transport/src/Network/Transport/Internal.hs+5−5 not-bytestring/LICENSE+30 not-bytestring/Setup.hs+2 not-bytestring/not-bytestring.cabal+33 not-bytestring/src/Data/NotByteString.hs+50 not-bytestring/src/Data/NotByteString/Char8.hs+23 not-bytestring/src/Data/NotByteString/Internal.hs+24 not-bytestring/src/Data/NotByteString/Lazy.hs+40 not-bytestring/src/Data/NotByteString/Lazy/Binary.hs+14 not-bytestring/src/Data/NotByteString/Lazy/Char8.hs+5 not-bytestring/src/Data/NotByteString/NBS.hs+15
distributed-process/distributed-process.cabal+6−6
@@ -37,7 +37,6 @@ Library
3737 transformers >= 0.2 && < 0.4,
3838 mtl >= 2.0 && < 2.2,
3939 data-accessor >= 0.2 && < 0.3,
40− bytestring >= 0.9 && < 0.11,
4140 containers >= 0.4 && < 0.6,
4241 old-locale >= 1.0 && < 1.1,
4342 time >= 1.2 && < 1.5,
@@ -46,7 +45,8 @@ Library
4645 ghc-prim >= 0.2 && < 0.4,
4746 distributed-static >= 0.1 && < 0.2,
4847 rank1dynamic >= 0.1 && < 0.2,
49− syb >= 0.3 && < 0.4
48+ syb >= 0.3 && < 0.4,
49+ not-bytestring
5050 Exposed-modules: Control.Distributed.Process,
5151 Control.Distributed.Process.Serializable,
5252 Control.Distributed.Process.Closure,
@@ -82,7 +82,6 @@ Test-Suite TestCH
8282 transformers >= 0.2 && < 0.4,
8383 mtl >= 2.0 && < 2.2,
8484 data-accessor >= 0.2 && < 0.3,
85− bytestring >= 0.9 && < 0.11,
8685 containers >= 0.4 && < 0.6,
8786 old-locale >= 1.0 && < 1.1,
8887 time >= 1.2 && < 1.5,
@@ -91,7 +90,8 @@ Test-Suite TestCH
9190 ghc-prim >= 0.2 && < 0.4,
9291 ansi-terminal >= 0.5 && < 0.6,
9392 distributed-static >= 0.1 && < 0.2,
94− rank1dynamic >= 0.1 && < 0.2
93+ rank1dynamic >= 0.1 && < 0.2,
94+ not-bytestring
9595 Extensions: RankNTypes,
9696 ScopedTypeVariables,
9797 FlexibleInstances,
@@ -115,7 +115,6 @@ Test-Suite TestClosure
115115 transformers >= 0.2 && < 0.4,
116116 mtl >= 2.0 && < 2.2,
117117 data-accessor >= 0.2 && < 0.3,
118− bytestring >= 0.9 && < 0.11,
119118 containers >= 0.4 && < 0.6,
120119 old-locale >= 1.0 && < 1.1,
121120 time >= 1.2 && < 1.5,
@@ -125,7 +124,8 @@ Test-Suite TestClosure
125124 ansi-terminal >= 0.5 && < 0.6,
126125 distributed-static >= 0.1 && < 0.2,
127126 rank1dynamic >= 0.1 && < 0.2,
128− syb >= 0.3 && < 0.4
127+ syb >= 0.3 && < 0.4,
128+ not-bytestring
129129 Other-modules: TestAuxiliary
130130 Extensions: RankNTypes,
131131 ScopedTypeVariables,
distributed-process/src/Control/Distributed/Process.hs+13−6
@@ -294,14 +294,14 @@ spawn nid proc = do
294294 `seqCP` proc
295295 mPid <- receiveWait
296296 [ matchIf (\(DidSpawn ref _) -> ref == sRef)
297− (\(DidSpawn _ pid) -> return $ Just pid)
297+ (\(DidSpawn _ pid) -> return $ Right pid)
298298 , matchIf (\(NodeMonitorNotification ref _ _) -> ref == mRef)
299− (\_ -> return Nothing)
299+ (\(NodeMonitorNotification _ _ err) -> return $ Left err)
300300 ]
301301 unmonitor mRef
302302 case mPid of
303− Nothing -> fail "spawn: remote node failed"
304− Just pid -> send pid () >> return pid
303+ Left err -> fail $ "spawn: remote node failed: " ++ show err
304+ Right pid -> send pid () >> return pid
305305
306306-- | Spawn a process and link to it
307307--
@@ -343,8 +343,15 @@ call dict nid proc = do
343343 (\(ProcessMonitorNotification _ _ reason) -> return (Left reason))
344344 ]
345345 case mResult of
346− Right a -> unmonitor mRef >> return a
347− Left err -> fail $ "call: remote process died: " ++ show err
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+ ]
352+ return a
353+ Left err ->
354+ fail $ "call: remote process died: " ++ show err
348355
349356-- | Spawn a child process, have the child link to the parent and the parent
350357-- 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
2323 , cpNewChan
2424 ) where
2525
26−import Data.ByteString.Lazy (ByteString)
27−import Data.Binary (decode, encode)
26+import Data.NotByteString.Lazy (ByteString)
27+import Data.NotByteString.Lazy.Binary (decode, encode)
2828import Data.Rank1Typeable (Typeable, ANY, ANY1, ANY2, ANY3, ANY4)
2929import Data.Rank1Dynamic (toDynamic)
3030import Control.Distributed.Static
distributed-process/src/Control/Distributed/Process/Internal/Closure/TH.hs+1−1
@@ -39,7 +39,7 @@ import Language.Haskell.TH
3939 , funD
4040 , sigD
4141 )
42−import Data.Binary (encode)
42+import Data.NotByteString.Lazy.Binary (encode)
4343import Data.Generics (everywhereM, mkM, gmapM)
4444import Data.Rank1Dynamic (toDynamic)
4545import Data.Rank1Typeable
distributed-process/src/Control/Distributed/Process/Internal/Node.hs+6−5
@@ -6,9 +6,10 @@ module Control.Distributed.Process.Internal.Node
66 ) where
77
88import Data.Accessor ((^.), (^=))
9−import Data.Binary (Binary, encode)
10−import qualified Data.ByteString.Lazy as BSL (toChunks)
11−import qualified Data.ByteString as BSS (ByteString)
9+import Data.Binary (Binary)
10+import Data.NotByteString.Lazy.Binary (encode)
11+import qualified Data.NotByteString.Lazy as BSL (toChunks)
12+import qualified Data.NotByteString as BSS (ByteString)
1213import Control.Distributed.Process.Internal.StrictMVar (withMVar, modifyMVar_)
1314import Control.Concurrent.Chan (writeChan)
1415import Control.Monad (unless)
@@ -44,8 +45,8 @@ sendPayload node from to payload = do
4445 Just conn -> do
4546 didSend <- NT.send conn payload
4647 case didSend of
47− Left _ -> return False
48− Right _ -> return True
48+ Left _err -> return False
49+ Right () -> return True
4950 Nothing -> return False
5051 unless didSend $
5152 writeChan (localCtrlChan node) NCMsg
distributed-process/src/Control/Distributed/Process/Internal/Primitives.hs+1−1
@@ -65,7 +65,7 @@ module Control.Distributed.Process.Internal.Primitives
6565import Prelude hiding (catch)
6666#endif
6767
68−import Data.Binary (decode)
68+import Data.NotByteString.Lazy.Binary (decode)
6969import Data.Time.Clock (getCurrentTime)
7070import Data.Time.Format (formatTime)
7171import System.Locale (defaultTimeLocale)
distributed-process/src/Control/Distributed/Process/Internal/Types.hs+4−3
@@ -64,9 +64,10 @@ module Control.Distributed.Process.Internal.Types
6464import Data.Map (Map)
6565import Data.Int (Int32)
6666import Data.Typeable (Typeable)
67−import Data.Binary (Binary(put, get), putWord8, getWord8, encode)
68−import qualified Data.ByteString as BSS (ByteString, concat)
69−import qualified Data.ByteString.Lazy as BSL
67+import Data.Binary (Binary(put, get), putWord8, getWord8)
68+import Data.NotByteString.Lazy.Binary (encode)
69+import qualified Data.NotByteString as BSS (ByteString, concat)
70+import qualified Data.NotByteString.Lazy as BSL
7071 ( ByteString
7172 , toChunks
7273 , splitAt
distributed-process/src/Control/Distributed/Process/Node.hs+2−2
@@ -14,8 +14,8 @@ import Prelude hiding (catch)
1414#endif
1515
1616import System.IO (fixIO, hPutStrLn, stderr)
17−import qualified Data.ByteString.Lazy as BSL (fromChunks)
18−import Data.Binary (decode)
17+import qualified Data.NotByteString.Lazy as BSL (fromChunks)
18+import Data.NotByteString.Lazy.Binary (decode)
1919import Data.Map (Map)
2020import qualified Data.Map as Map
2121 ( empty
distributed-process/src/Control/Distributed/Process/Serializable.hs+6−6
@@ -15,12 +15,12 @@ import Data.Typeable.Internal (TypeRep(TypeRep))
1515import Numeric (showHex)
1616import Control.Exception (throw)
1717import GHC.Fingerprint.Type (Fingerprint(..))
18−import Data.ByteString (ByteString)
19−import qualified Data.ByteString as BS
20−import qualified Data.ByteString.Internal as BSI ( unsafeCreate
21− , inlinePerformIO
22− , toForeignPtr
23− )
18+import Data.NotByteString (ByteString)
19+import qualified Data.NotByteString as BS
20+import qualified Data.NotByteString.Internal as BSI ( unsafeCreate
21+ , inlinePerformIO
22+ , toForeignPtr
23+ )
2424import Foreign.Storable (pokeByteOff, peekByteOff, sizeOf)
2525import Foreign.ForeignPtr (withForeignPtr)
2626
distributed-static/distributed-static.cabal+2−2
@@ -29,8 +29,8 @@ Library
2929 Build-Depends: base >= 4 && < 5,
3030 rank1dynamic >= 0.1 && < 0.2,
3131 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
3434 HS-Source-Dirs: src
3535 Extensions: DeriveDataTypeable,
3636 ScopedTypeVariables
distributed-static/src/Control/Distributed/Static.hs+2−3
@@ -228,10 +228,9 @@ import Data.Binary
228228 , Get
229229 , putWord8
230230 , getWord8
231− , encode
232− , decode
233231 )
234−import Data.ByteString.Lazy (ByteString, empty)
232+import Data.NotByteString.Lazy.Binary (decode, encode)
233+import Data.NotByteString.Lazy (ByteString, empty)
235234import Data.Map (Map)
236235import qualified Data.Map as Map (lookup, empty, insert)
237236import Control.Applicative ((<$>), (<*>))
network-transport-tcp/network-transport-tcp.cabal+5−3
@@ -25,8 +25,9 @@ Library
2525 network-transport >= 0.2 && < 0.3,
2626 data-accessor >= 0.2 && < 0.3,
2727 containers >= 0.4 && < 0.6,
28+ network >= 2.3 && < 2.4,
2829 bytestring >= 0.9 && < 0.11,
29− network >= 2.3 && < 2.4
30+ not-bytestring
3031 Exposed-modules: Network.Transport.TCP,
3132 Network.Transport.TCP.Internal
3233 Extensions: CPP
@@ -40,11 +41,12 @@ Test-Suite TestTCP
4041 network-transport >= 0.2 && < 0.3,
4142 data-accessor >= 0.2 && < 0.3,
4243 containers >= 0.4 && < 0.6,
43− bytestring >= 0.9 && < 0.11,
4444 network >= 2.3 && < 2.4,
4545 random >= 1.0 && < 1.1,
4646 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
4850 Other-modules: TestAuxiliary,
4951 TestTransport,
5052 Traced
network-transport-tcp/src/Network/Transport/TCP.hs+5−5
@@ -66,7 +66,7 @@ import qualified Network.Socket as N ( HostName
6666 , sOMAXCONN
6767 , AddrInfo
6868 )
69−import Network.Socket.ByteString (sendMany)
69+import Data.NotByteString.NBS (sendMany)
7070import Control.Concurrent (forkIO, ThreadId, killThread, myThreadId)
7171import Control.Concurrent.Chan (Chan, newChan, readChan, writeChan)
7272import Control.Concurrent.MVar ( MVar
@@ -95,9 +95,9 @@ import Control.Exception ( IOException
9595 , fromException
9696 )
9797import Data.IORef (IORef, newIORef, writeIORef, readIORef)
98−import Data.ByteString (ByteString)
99−import qualified Data.ByteString as BS (concat)
100−import qualified Data.ByteString.Char8 as BSC (pack, unpack, split)
98+import Data.NotByteString (ByteString)
99+import qualified Data.NotByteString as BS (concat)
100+import qualified Data.NotByteString.Char8 as BSC (pack, unpack, split)
101101import Data.Int (Int32)
102102import Data.IntMap (IntMap)
103103import qualified Data.IntMap as IntMap (empty)
@@ -1155,7 +1155,7 @@ setupRemoteEndPoint params (ourEndPoint, theirEndPoint) hints = do
11551155 { remoteSocket = sock
11561156 , _remoteOutgoing = 0
11571157 , _remoteIncoming = IntSet.empty
1158− , sendOn = sendMany sock
1158+ , sendOn = sendMany sock
11591159 , _pendingCtrlRequests = IntMap.empty
11601160 , _nextCtrlRequestId = 0
11611161 }
network-transport-tcp/src/Network/Transport/TCP/Internal.hs+3−3
@@ -28,13 +28,13 @@ import qualified Network.Socket as N ( HostName
2828 , accept
2929 , sClose
3030 )
31−import qualified Network.Socket.ByteString as NBS (recv)
31+import qualified Data.NotByteString.NBS as NBS (recv)
3232import Control.Concurrent (ThreadId)
3333import Control.Monad (forever, when)
3434import Control.Exception (SomeException, catch, bracketOnError, throwIO, mask_)
3535import Control.Applicative ((<$>))
36−import Data.ByteString (ByteString)
37−import qualified Data.ByteString as BS (length, concat, null)
36+import Data.NotByteString (ByteString)
37+import qualified Data.NotByteString as BS (length, concat, null)
3838import Data.Int (Int32)
3939
4040-- | Start a server at the specified address.
network-transport/network-transport.cabal+2−2
@@ -66,8 +66,8 @@ Source-Repository head
6666Library
6767 Build-Depends: base >= 4.3 && < 5,
6868 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
7171 Exposed-Modules: Network.Transport,
7272 Network.Transport.Util
7373 Network.Transport.Internal
network-transport/src/Network/Transport.hs+2−2
@@ -22,8 +22,8 @@ module Network.Transport ( -- * Types
2222 , EventErrorCode(..)
2323 ) where
2424
25−import Data.ByteString (ByteString)
26−import qualified Data.ByteString.Char8 as BSC (unpack)
25+import Data.NotByteString (ByteString)
26+import qualified Data.NotByteString.Char8 as BSC (unpack)
2727import Control.Exception (Exception)
2828import Data.Typeable (Typeable)
2929import Data.Binary (Binary)
network-transport/src/Network/Transport/Internal.hs+5−5
@@ -25,11 +25,11 @@ import Prelude hiding (catch)
2525import Foreign.Storable (pokeByteOff, peekByteOff)
2626import Foreign.C (CInt(..), CShort(..))
2727import Foreign.ForeignPtr (withForeignPtr)
28−import Data.ByteString (ByteString)
29−import qualified Data.ByteString as BS (length)
30−import qualified Data.ByteString.Internal as BSI ( unsafeCreate
31− , toForeignPtr
32− , inlinePerformIO)
28+import Data.NotByteString (ByteString)
29+import qualified Data.NotByteString as BS (length)
30+import qualified Data.NotByteString.Internal as BSI ( unsafeCreate
31+ , toForeignPtr
32+ , inlinePerformIO)
3333import Control.Monad.IO.Class (MonadIO, liftIO)
3434import Control.Exception ( IOException
3535 , 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