Skip to content

Commit

Permalink
fix for ghc-8.2.2 replace <> with mappend
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcFontaine committed Aug 5, 2018
1 parent 8e06d84 commit aea5b3e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
17 changes: 17 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{ system ? builtins.currentSystem
, config ? {}
, pkgs ? ( import <nixpkgs> {})
}:
with pkgs;
let
hsPkgs = haskell.packages.ghc822;
in
haskell.lib.buildStackProject {
name = "wsjtx-to-mqtt";
ghc = hsPkgs.ghc;
buildInputs = [
cabal-install stack
hlint
hsPkgs.stylish-haskell
];
}
20 changes: 10 additions & 10 deletions src/MQTT.hs
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ sendMqtt packets = withSocketsDo $ do
connectMsg :: BSC.ByteString -> BSL.ByteString
connectMsg clientId = toLazyByteString $
connectHeader
<> remainingLength (
`mappend` remainingLength (
protocolName
<> protocolLevel
<> connectFlags
<> keepAlive
<> lenBS clientId
`mappend` protocolLevel
`mappend` connectFlags
`mappend` keepAlive
`mappend` lenBS clientId
)
where
connectHeader = word8 0x10
Expand All @@ -105,22 +105,22 @@ connectMsg clientId = toLazyByteString $
publishMsg :: Msg -> BSL.ByteString
publishMsg (Msg topic message) = toLazyByteString $
( pubHeader
<> remainingLength (
`mappend` remainingLength (
(lenBS $ encodeUtf8 $ Text.intercalate "/" topic)
<> identifier
<> lazyByteString message ))
`mappend` identifier
`mappend` lazyByteString message ))
where
pubHeader = word8 0x30
identifier = mempty

lenBS :: BSC.ByteString -> Builder
lenBS bs
= ( word16BE $ fromIntegral $ BSC.length bs) <> byteString bs
= ( word16BE $ fromIntegral $ BSC.length bs) `mappend` byteString bs

remainingLength :: Builder -> Builder
remainingLength c =
word8 len -- variable length
<> lazyByteString body
`mappend` lazyByteString body
where
body = toLazyByteString c
len = fromIntegral $ BSL.length body

0 comments on commit aea5b3e

Please sign in to comment.