cloudi 1.7.0 → 1.7.1
raw patch · 11 files changed
+209/−252 lines, 11 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Foreign.CloudI: type Result a = Either String a
Files
- LICENSE +17/−32
- README.markdown +12/−0
- changelog.md +1/−0
- cloudi.cabal +3/−3
- src/Foreign/CloudI.hs +65/−31
- src/Foreign/CloudI/Instance.hs +22/−31
- src/Foreign/Erlang.hs +21/−31
- src/Foreign/Erlang/Function.hs +17/−31
- src/Foreign/Erlang/Pid.hs +17/−31
- src/Foreign/Erlang/Port.hs +17/−31
- src/Foreign/Erlang/Reference.hs +17/−31
LICENSE view
@@ -1,36 +1,21 @@-BSD LICENSE - -Copyright (c) 2017, Michael Truog <mjtruog at gmail dot com> -All rights reserved. +MIT License -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: +Copyright (c) 2017 Michael Truog <mjtruog at gmail dot com> - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - * All advertising materials mentioning features or use of this - software must display the following acknowledgment: - This product includes software developed by Michael Truog - * The name of the author may not be used to endorse or promote - products derived from this software without specific prior - written permission +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH -DAMAGE. +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE.
README.markdown view
@@ -1,6 +1,8 @@ `cloudi_api_haskell` ==================== +[](https://hackage.haskell.org/package/cloudi)+ Haskell [CloudI API](http://cloudi.org/api.html#1_Intro) Build@@ -11,4 +13,14 @@ cabal install --only-dependencies cabal configure cabal build++Author+------++Michael Truog (mjtruog [at] gmail (dot) com)++License+-------++MIT License
+ changelog.md view
@@ -0,0 +1,1 @@+Please refer to the main repository [ChangeLog](https://github.com/CloudI/CloudI/blob/develop/src/ChangeLog)
cloudi.cabal view
@@ -1,9 +1,9 @@ name: cloudi-version: 1.7.0+version: 1.7.1 synopsis: Haskell CloudI API description: Haskell CloudI API homepage: https://github.com/CloudI/cloudi_api_haskell-license: BSD4+license: MIT license-file: LICENSE author: Michael Truog maintainer: mjtruog@gmail.com@@ -13,7 +13,7 @@ build-type: Simple cabal-version: >= 1.22 tested-with: GHC == 7.10.3, GHC == 8.0.2-extra-source-files: README.markdown+extra-source-files: README.markdown changelog.md library hs-source-dirs: src
src/Foreign/CloudI.hs view
@@ -3,44 +3,34 @@ {- - BSD LICENSE+ MIT License - Copyright (c) 2017, Michael Truog <mjtruog at gmail dot com>- All rights reserved.+ Copyright (c) 2017 Michael Truog <mjtruog at gmail dot com> - Redistribution and use in source and binary forms, with or without- modification, are permitted provided that the following conditions are met:+ Permission is hereby granted, free of charge, to any person obtaining a+ copy of this software and associated documentation files (the "Software"),+ to deal in the Software without restriction, including without limitation+ the rights to use, copy, modify, merge, publish, distribute, sublicense,+ and/or sell copies of the Software, and to permit persons to whom the+ Software is furnished to do so, subject to the following conditions: - * Redistributions of source code must retain the above copyright- notice, this list of conditions and the following disclaimer.- * Redistributions in binary form must reproduce the above copyright- notice, this list of conditions and the following disclaimer in- the documentation and/or other materials provided with the- distribution.- * All advertising materials mentioning features or use of this- software must display the following acknowledgment:- This product includes software developed by Michael Truog- * The name of the author may not be used to endorse or promote- products derived from this software without specific prior- written permission+ The above copyright notice and this permission notice shall be included in+ all copies or substantial portions of the Software. - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND- CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH- DAMAGE.+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER+ DEALINGS IN THE SOFTWARE. -} +-- | Haskell <http://cloudi.org/api.html#1_Intro CloudI API>.+-- Example usage is available in the+-- <http://cloudi.org/tutorials.html#cloudi_examples integration tests>.+ module Foreign.CloudI ( Instance.RequestType(..) , Instance.Source@@ -52,6 +42,7 @@ , messageDecodingError , terminateError , Exception+ , Result , api , threadCount , subscribe@@ -149,6 +140,8 @@ Int, Int, ByteString, Source) | MessageKeepalive +-- | a null trans_id is used to check for a timeout or+-- to get the oldest response with recv_async transIdNull :: ByteString transIdNull = Char8.pack $ List.replicate 16 '\0' @@ -184,6 +177,7 @@ type Result a = Either String a +-- | creates an instance of the CloudI API api :: Typeable s => Int -> s -> IO (Result (Instance.T s)) api threadIndex state = do@@ -217,6 +211,7 @@ (_, _) -> return $ Left invalidInputError +-- | returns the thread count from the service configuration threadCount :: IO (Result Int) threadCount = do threadCountValue <- POSIX.getEnv "CLOUDI_API_INIT_THREAD_COUNT"@@ -226,6 +221,7 @@ Just threadCountStr -> return $ Right (read threadCountStr :: Int) +-- | subscribes to a service name pattern with a callback subscribe :: Instance.T s -> ByteString -> Instance.Callback s -> IO (Result (Instance.T s)) subscribe api0 pattern f =@@ -240,6 +236,7 @@ send api0 subscribeBinary return $ Right $ Instance.callbacksAdd api0 pattern f +-- | returns the number of subscriptions for a single service name pattern subscribeCount :: Typeable s => Instance.T s -> ByteString -> IO (Result (Int, Instance.T s)) subscribeCount api0 pattern =@@ -259,6 +256,7 @@ Right (_, api1@Instance.T{Instance.subscribeCount = count}) -> return $ Right (count, api1) +-- | unsubscribes from a service name pattern once unsubscribe :: Instance.T s -> ByteString -> IO (Result (Instance.T s)) unsubscribe api0 pattern =@@ -273,6 +271,7 @@ send api0 unsubscribeBinary return $ Right $ Instance.callbacksRemove api0 pattern +-- | sends an asynchronous service request sendAsync :: Typeable s => Instance.T s -> ByteString -> ByteString -> Maybe Int -> Maybe ByteString -> Maybe Int -> IO (Result (ByteString, Instance.T s))@@ -303,6 +302,7 @@ Right (_, api1@Instance.T{Instance.transId = transId}) -> return $ Right (transId, api1) +-- | sends a synchronous service request sendSync :: Typeable s => Instance.T s -> ByteString -> ByteString -> Maybe Int -> Maybe ByteString -> Maybe Int -> IO (Result (ByteString, ByteString, ByteString, Instance.T s))@@ -336,6 +336,8 @@ , Instance.transId = transId}) -> return $ Right (responseInfo, response, transId, api1) +-- | sends asynchronous service requests to all subscribers+-- of the matching service name pattern mcastAsync :: Typeable s => Instance.T s -> ByteString -> ByteString -> Maybe Int -> Maybe ByteString -> Maybe Int -> IO (Result (Array Int ByteString, Instance.T s))@@ -366,6 +368,7 @@ Right (_, api1@Instance.T{Instance.transIds = transIds}) -> return $ Right (transIds, api1) +-- | forwards a service request to a different service name forward_ :: Typeable s => Instance.T s -> Instance.RequestType -> ByteString -> ByteString -> ByteString -> Int -> Int -> ByteString -> Source ->@@ -401,6 +404,7 @@ send api0 forwardBinary return $ Right api0 +-- | forwards an asynchronous service request to a different service name forwardAsync :: Typeable s => Instance.T s -> ByteString -> ByteString -> ByteString -> Int -> Int -> ByteString -> Source -> IO ()@@ -441,6 +445,7 @@ send api0 forwardBinary return $ Right api0 +-- | forwards a synchronous service request to a different service name forwardSync :: Typeable s => Instance.T s -> ByteString -> ByteString -> ByteString -> Int -> Int -> ByteString -> Source -> IO ()@@ -453,6 +458,7 @@ Right api1 -> Exception.throwIO $ ForwardSync api1 +-- | provides a response to a service request return_ :: Typeable s => Instance.T s -> Instance.RequestType -> ByteString -> ByteString -> ByteString -> ByteString -> Int -> ByteString -> Source ->@@ -488,6 +494,7 @@ send api0 returnBinary return $ Right api0 +-- | provides a response to an asynchronous service request returnAsync :: Typeable s => Instance.T s -> ByteString -> ByteString -> ByteString -> ByteString -> Int -> ByteString -> Source -> IO ()@@ -528,6 +535,7 @@ send api0 returnBinary return $ Right api0 +-- | provides a response to a synchronous service request returnSync :: Typeable s => Instance.T s -> ByteString -> ByteString -> ByteString -> ByteString -> Int -> ByteString -> Source -> IO ()@@ -540,6 +548,7 @@ Right api1 -> Exception.throwIO $ ReturnSync api1 +-- | blocks to receive an asynchronous service request response recvAsync :: Typeable s => Instance.T s -> Maybe Int -> Maybe ByteString -> Maybe Bool -> IO (Result (ByteString, ByteString, ByteString, Instance.T s))@@ -569,38 +578,53 @@ , Instance.transId = transId'}) -> return $ Right (responseInfo, response, transId', api1) +-- | returns the 0-based index of this process in the service instance processIndex :: Instance.T s -> Int processIndex Instance.T{Instance.processIndex = processIndex'} = processIndex' +-- | returns the current process count based on the service configuration processCount :: Instance.T s -> Int processCount Instance.T{Instance.processCount = processCount'} = processCount' +-- | returns the count_process_dynamic maximum count+-- based on the service configuration processCountMax :: Instance.T s -> Int processCountMax Instance.T{Instance.processCountMax = processCountMax'} = processCountMax' +-- | returns the count_process_dynamic minimum count+-- based on the service configuration processCountMin :: Instance.T s -> Int processCountMin Instance.T{Instance.processCountMin = processCountMin'} = processCountMin' +-- | returns the service name pattern prefix from the service configuration prefix :: Instance.T s -> ByteString prefix Instance.T{Instance.prefix = prefix'} = prefix' +-- | returns the service initialization timeout+-- from the service configuration timeoutInitialize :: Instance.T s -> Int timeoutInitialize Instance.T{Instance.timeoutInitialize = timeoutInitialize'} = timeoutInitialize' +-- | returns the default asynchronous service request send timeout+-- from the service configuration timeoutAsync :: Instance.T s -> Int timeoutAsync Instance.T{Instance.timeoutAsync = timeoutAsync'} = timeoutAsync' +-- | returns the default synchronous service request send timeout+-- from the service configuration timeoutSync :: Instance.T s -> Int timeoutSync Instance.T{Instance.timeoutSync = timeoutSync'} = timeoutSync' +-- | returns the service termination timeout+-- based on the service configuration timeoutTerminate :: Instance.T s -> Int timeoutTerminate Instance.T{Instance.timeoutTerminate = timeoutTerminate'} = timeoutTerminate'@@ -846,8 +870,10 @@ | cmd == messageRecvAsync || cmd == messageReturnSync -> do responseInfoSize <- Get.getWord32host responseInfo <- Get.getByteString $ fromIntegral responseInfoSize+ Get.skip 1 responseSize <- Get.getWord32host response <- Get.getByteString $ fromIntegral responseSize+ Get.skip 1 transId <- Get.getByteString 16 empty <- Get.isEmpty let api1 = Instance.setResponse api0@@ -1011,6 +1037,7 @@ else pollRequestLoopBegin api0 timeout external pollTimer +-- | blocks to process incoming CloudI service requests poll :: Typeable s => Instance.T s -> Int -> IO (Result (Bool, Instance.T s)) poll api0 timeout = pollRequest api0 timeout True@@ -1130,6 +1157,11 @@ threadList :: Concurrent.MVar [Concurrent.MVar ()] threadList = Unsafe.unsafePerformIO (Concurrent.newMVar []) +-- | simplifies thread creation and join+--+-- > Concurrent.setNumCapabilities threadCount+-- > mapM_ (CloudI.threadCreate task) [0..threadCount - 1]+-- > CloudI.threadsWait threadCreate :: (Int -> IO ()) -> Int -> IO ThreadId threadCreate f threadIndex = do thread <- Concurrent.newEmptyMVar@@ -1146,6 +1178,7 @@ Concurrent.forkOn threadIndex (Exception.try (restore action) >>= afterF) +-- | wait for threads to join after being created by 'threadCreate' threadsWait :: IO () threadsWait = do threads <- Concurrent.takeMVar threadList@@ -1174,6 +1207,7 @@ in loop Map.empty (Char8.split '\0' text) +-- | parses "text_pairs" in service request info infoKeyValueParse :: ByteString -> Map ByteString [ByteString] infoKeyValueParse = textKeyValueParse
src/Foreign/CloudI/Instance.hs view
@@ -3,41 +3,27 @@ {- - BSD LICENSE+ MIT License - Copyright (c) 2017, Michael Truog <mjtruog at gmail dot com>- All rights reserved.+ Copyright (c) 2017 Michael Truog <mjtruog at gmail dot com> - Redistribution and use in source and binary forms, with or without- modification, are permitted provided that the following conditions are met:+ Permission is hereby granted, free of charge, to any person obtaining a+ copy of this software and associated documentation files (the "Software"),+ to deal in the Software without restriction, including without limitation+ the rights to use, copy, modify, merge, publish, distribute, sublicense,+ and/or sell copies of the Software, and to permit persons to whom the+ Software is furnished to do so, subject to the following conditions: - * Redistributions of source code must retain the above copyright- notice, this list of conditions and the following disclaimer.- * Redistributions in binary form must reproduce the above copyright- notice, this list of conditions and the following disclaimer in- the documentation and/or other materials provided with the- distribution.- * All advertising materials mentioning features or use of this- software must display the following acknowledgment:- This product includes software developed by Michael Truog- * The name of the author may not be used to endorse or promote- products derived from this software without specific prior- written permission+ The above copyright notice and this permission notice shall be included in+ all copies or substantial portions of the Software. - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND- CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH- DAMAGE.+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER+ DEALINGS IN THE SOFTWARE. -} @@ -84,13 +70,16 @@ type Word8 = Word.Word8 type Word32 = Word.Word32 +-- | provided when handling a service request data RequestType = ASYNC | SYNC deriving (Eq, Show) +-- | the Erlang pid that is the source of the service request type Source = Erlang.Pid +-- | a function to handle a service request type Callback s = RequestType -> ByteString -> ByteString ->@@ -99,6 +88,7 @@ s -> T s -> IO (Response s) +-- | service request callback function return type data Response s = Response (ByteString, s, T s) | ResponseInfo (ByteString, ByteString, s, T s)@@ -108,6 +98,7 @@ | NullError (String, s, T s) deriving (Show, Typeable) +-- | an instance of the CloudI API data T s = T { state :: !s , socketHandle :: !Handle
src/Foreign/Erlang.hs view
@@ -3,44 +3,32 @@ {- - BSD LICENSE+ MIT License - Copyright (c) 2017, Michael Truog <mjtruog at gmail dot com>- All rights reserved.+ Copyright (c) 2017 Michael Truog <mjtruog at gmail dot com> - Redistribution and use in source and binary forms, with or without- modification, are permitted provided that the following conditions are met:+ Permission is hereby granted, free of charge, to any person obtaining a+ copy of this software and associated documentation files (the "Software"),+ to deal in the Software without restriction, including without limitation+ the rights to use, copy, modify, merge, publish, distribute, sublicense,+ and/or sell copies of the Software, and to permit persons to whom the+ Software is furnished to do so, subject to the following conditions: - * Redistributions of source code must retain the above copyright- notice, this list of conditions and the following disclaimer.- * Redistributions in binary form must reproduce the above copyright- notice, this list of conditions and the following disclaimer in- the documentation and/or other materials provided with the- distribution.- * All advertising materials mentioning features or use of this- software must display the following acknowledgment:- This product includes software developed by Michael Truog- * The name of the author may not be used to endorse or promote- products derived from this software without specific prior- written permission+ The above copyright notice and this permission notice shall be included in+ all copies or substantial portions of the Software. - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND- CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH- DAMAGE.+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER+ DEALINGS IN THE SOFTWARE. -} +-- | Erlang Binary Term Format Encoding/Decoding+ module Foreign.Erlang ( OtpErlangTerm(..) , Error(..)@@ -203,6 +191,7 @@ (<>) :: Monoid.Monoid m => m -> m -> m (<>) = Monoid.mappend +-- | Decode Erlang terms within binary data into Haskell types binaryToTerm :: LazyByteString -> Result OtpErlangTerm binaryToTerm binary = let size = LazyByteString.length binary in@@ -217,6 +206,7 @@ Right (_, _, term) -> ok term +-- | Encode Haskell types into Erlang terms in binary data termToBinary :: OtpErlangTerm -> Int -> Result LazyByteString termToBinary term compressed | compressed < (-1) || compressed > 9 =
src/Foreign/Erlang/Function.hs view
@@ -3,41 +3,27 @@ {- - BSD LICENSE+ MIT License - Copyright (c) 2017, Michael Truog <mjtruog at gmail dot com>- All rights reserved.+ Copyright (c) 2017 Michael Truog <mjtruog at gmail dot com> - Redistribution and use in source and binary forms, with or without- modification, are permitted provided that the following conditions are met:+ Permission is hereby granted, free of charge, to any person obtaining a+ copy of this software and associated documentation files (the "Software"),+ to deal in the Software without restriction, including without limitation+ the rights to use, copy, modify, merge, publish, distribute, sublicense,+ and/or sell copies of the Software, and to permit persons to whom the+ Software is furnished to do so, subject to the following conditions: - * Redistributions of source code must retain the above copyright- notice, this list of conditions and the following disclaimer.- * Redistributions in binary form must reproduce the above copyright- notice, this list of conditions and the following disclaimer in- the documentation and/or other materials provided with the- distribution.- * All advertising materials mentioning features or use of this- software must display the following acknowledgment:- This product includes software developed by Michael Truog- * The name of the author may not be used to endorse or promote- products derived from this software without specific prior- written permission+ The above copyright notice and this permission notice shall be included in+ all copies or substantial portions of the Software. - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND- CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH- DAMAGE.+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER+ DEALINGS IN THE SOFTWARE. -}
src/Foreign/Erlang/Pid.hs view
@@ -3,41 +3,27 @@ {- - BSD LICENSE+ MIT License - Copyright (c) 2017, Michael Truog <mjtruog at gmail dot com>- All rights reserved.+ Copyright (c) 2017 Michael Truog <mjtruog at gmail dot com> - Redistribution and use in source and binary forms, with or without- modification, are permitted provided that the following conditions are met:+ Permission is hereby granted, free of charge, to any person obtaining a+ copy of this software and associated documentation files (the "Software"),+ to deal in the Software without restriction, including without limitation+ the rights to use, copy, modify, merge, publish, distribute, sublicense,+ and/or sell copies of the Software, and to permit persons to whom the+ Software is furnished to do so, subject to the following conditions: - * Redistributions of source code must retain the above copyright- notice, this list of conditions and the following disclaimer.- * Redistributions in binary form must reproduce the above copyright- notice, this list of conditions and the following disclaimer in- the documentation and/or other materials provided with the- distribution.- * All advertising materials mentioning features or use of this- software must display the following acknowledgment:- This product includes software developed by Michael Truog- * The name of the author may not be used to endorse or promote- products derived from this software without specific prior- written permission+ The above copyright notice and this permission notice shall be included in+ all copies or substantial portions of the Software. - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND- CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH- DAMAGE.+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER+ DEALINGS IN THE SOFTWARE. -}
src/Foreign/Erlang/Port.hs view
@@ -3,41 +3,27 @@ {- - BSD LICENSE+ MIT License - Copyright (c) 2017, Michael Truog <mjtruog at gmail dot com>- All rights reserved.+ Copyright (c) 2017 Michael Truog <mjtruog at gmail dot com> - Redistribution and use in source and binary forms, with or without- modification, are permitted provided that the following conditions are met:+ Permission is hereby granted, free of charge, to any person obtaining a+ copy of this software and associated documentation files (the "Software"),+ to deal in the Software without restriction, including without limitation+ the rights to use, copy, modify, merge, publish, distribute, sublicense,+ and/or sell copies of the Software, and to permit persons to whom the+ Software is furnished to do so, subject to the following conditions: - * Redistributions of source code must retain the above copyright- notice, this list of conditions and the following disclaimer.- * Redistributions in binary form must reproduce the above copyright- notice, this list of conditions and the following disclaimer in- the documentation and/or other materials provided with the- distribution.- * All advertising materials mentioning features or use of this- software must display the following acknowledgment:- This product includes software developed by Michael Truog- * The name of the author may not be used to endorse or promote- products derived from this software without specific prior- written permission+ The above copyright notice and this permission notice shall be included in+ all copies or substantial portions of the Software. - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND- CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH- DAMAGE.+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER+ DEALINGS IN THE SOFTWARE. -}
src/Foreign/Erlang/Reference.hs view
@@ -3,41 +3,27 @@ {- - BSD LICENSE+ MIT License - Copyright (c) 2017, Michael Truog <mjtruog at gmail dot com>- All rights reserved.+ Copyright (c) 2017 Michael Truog <mjtruog at gmail dot com> - Redistribution and use in source and binary forms, with or without- modification, are permitted provided that the following conditions are met:+ Permission is hereby granted, free of charge, to any person obtaining a+ copy of this software and associated documentation files (the "Software"),+ to deal in the Software without restriction, including without limitation+ the rights to use, copy, modify, merge, publish, distribute, sublicense,+ and/or sell copies of the Software, and to permit persons to whom the+ Software is furnished to do so, subject to the following conditions: - * Redistributions of source code must retain the above copyright- notice, this list of conditions and the following disclaimer.- * Redistributions in binary form must reproduce the above copyright- notice, this list of conditions and the following disclaimer in- the documentation and/or other materials provided with the- distribution.- * All advertising materials mentioning features or use of this- software must display the following acknowledgment:- This product includes software developed by Michael Truog- * The name of the author may not be used to endorse or promote- products derived from this software without specific prior- written permission+ The above copyright notice and this permission notice shall be included in+ all copies or substantial portions of the Software. - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND- CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH- DAMAGE.+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER+ DEALINGS IN THE SOFTWARE. -}