packages feed

net-mqtt-lens (empty) → 0.1.0.0

raw patch · 7 files changed

+209/−0 lines, 7 filesdep +HUnitdep +basedep +lenssetup-changed

Dependencies added: HUnit, base, lens, net-mqtt, net-mqtt-lens, tasty, tasty-hunit, tasty-quickcheck

Files

+ ChangeLog.md view
@@ -0,0 +1,3 @@+# Changelog for net-mqtt-lens++## Unreleased changes
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright Author name here (c) 2020++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++    * 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.++    * Neither the name of Author name here nor the names of other+      contributors may be used to endorse or promote products derived+      from this software without specific prior written permission.++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.
+ README.md view
@@ -0,0 +1,3 @@+# net-mqtt-lens++Lenses for `Network.MQTT.Types`.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ net-mqtt-lens.cabal view
@@ -0,0 +1,63 @@+cabal-version: 1.12++-- This file has been generated from package.yaml by hpack version 0.33.0.+--+-- see: https://github.com/sol/hpack+--+-- hash: 15ecc4ef559f4803df7a1a942b2d3d35fb684addcb86a076e2edf3a113dc55d8++name:           net-mqtt-lens+version:        0.1.0.0+synopsis:       Optics for net-mqtt+description:    Please see the README on GitHub at <https://github.com/dustin/net-mqtt-lens#readme>+category:       Network+homepage:       https://github.com/dustin/net-mqtt-lens#readme+bug-reports:    https://github.com/dustin/net-mqtt-lens/issues+author:         Dustin Sallings+maintainer:     dustin@spy.net+copyright:      2020 Dustin Sallings+license:        BSD3+license-file:   LICENSE+build-type:     Simple+extra-source-files:+    README.md+    ChangeLog.md++source-repository head+  type: git+  location: https://github.com/dustin/net-mqtt-lens++library+  exposed-modules:+      Network.MQTT.Lens+  other-modules:+      Paths_net_mqtt_lens+  hs-source-dirs:+      src+  default-extensions: OverloadedStrings RecordWildCards NamedFieldPuns+  ghc-options: -Wall+  build-depends:+      base >=4.7 && <5+    , lens+    , net-mqtt >=0.7.0.0 && <0.8.0.0+  default-language: Haskell2010++test-suite net-mqtt-lens-test+  type: exitcode-stdio-1.0+  main-is: Spec.hs+  other-modules:+      Paths_net_mqtt_lens+  hs-source-dirs:+      test+  default-extensions: OverloadedStrings RecordWildCards NamedFieldPuns+  ghc-options: -threaded -rtsopts -with-rtsopts=-N+  build-depends:+      HUnit+    , base >=4.7 && <5+    , lens+    , net-mqtt >=0.7.0.0 && <0.8.0.0+    , net-mqtt-lens+    , tasty+    , tasty-hunit+    , tasty-quickcheck+  default-language: Haskell2010
+ src/Network/MQTT/Lens.hs view
@@ -0,0 +1,97 @@+{-# LANGUAGE TemplateHaskell #-}++module Network.MQTT.Lens where++import           Control.Lens+import           Network.MQTT.Types++class HasProperties c where+  properties :: Lens' c [Property]++class HasPktID c where+  pktID :: Lens' c PktID++makeLenses ''ConnectRequest+instance HasProperties ConnectRequest where properties = connProperties++makeLenses ''LastWill+instance HasProperties LastWill where properties = willProps++makeLenses ''PublishRequest+instance HasProperties PublishRequest where properties = pubProps+instance HasPktID PublishRequest where pktID = pubPktID++makeLenses ''SubOptions++makePrisms ''ConnACKRC+makePrisms ''DiscoReason+makePrisms ''MQTTPkt+makePrisms ''Property+makePrisms ''ProtocolLevel+makePrisms ''QoS+makePrisms ''RetainHandling+makePrisms ''SessionReuse+makePrisms ''SubErr+makePrisms ''UnsubStatus++-- Manual lenses for unnamed fields++-- TODO: AuthRequest+instance HasProperties AuthRequest where+  properties = lens (\(AuthRequest _ ps) -> ps) (\(AuthRequest a _) p -> AuthRequest a p)++-- TODO: ConnACKFlags+instance HasProperties ConnACKFlags where+  properties = lens (\(ConnACKFlags _ _ ps) -> ps) (\(ConnACKFlags a b _) p -> ConnACKFlags a b p)++-- TODO: DisconnectRequest+instance HasProperties DisconnectRequest where+  properties = lens (\(DisconnectRequest _ ps) -> ps) (\(DisconnectRequest a _) p -> DisconnectRequest a p)++-- TODO: PubACK+instance HasProperties PubACK where+  properties = lens (\(PubACK _ _ ps) -> ps) (\(PubACK a b _) p -> PubACK a b p)+instance HasPktID PubACK where+  pktID = lens (\(PubACK i _ _) -> i) (\(PubACK _ a b) i -> PubACK i a b)++-- TODO: PubCOMP+instance HasProperties PubCOMP where+  properties = lens (\(PubCOMP _ _ ps) -> ps) (\(PubCOMP a b _) p -> PubCOMP a b p)+instance HasPktID PubCOMP where+  pktID = lens (\(PubCOMP i _ _) -> i) (\(PubCOMP _ a b) i -> PubCOMP i a b)++-- TODO: PubREC+instance HasProperties PubREC where+  properties = lens (\(PubREC _ _ ps) -> ps) (\(PubREC a b _) p -> PubREC a b p)+instance HasPktID PubREC where+  pktID = lens (\(PubREC i _ _) -> i) (\(PubREC _ a b) i -> PubREC i a b)++-- TODO: PubREL+instance HasProperties PubREL where+  properties = lens (\(PubREL _ _ ps) -> ps) (\(PubREL a b _) p -> PubREL a b p)+instance HasPktID PubREL where+  pktID = lens (\(PubREL i _ _) -> i) (\(PubREL _ a b) i -> PubREL i a b)++-- TODO: SubscribeRequest+instance HasProperties SubscribeRequest where+  properties = lens (\(SubscribeRequest _ _ ps) -> ps) (\(SubscribeRequest a b _) p -> SubscribeRequest a b p)+instance HasPktID SubscribeRequest where+  pktID = lens (\(SubscribeRequest i _ _) -> i) (\(SubscribeRequest _ a b) i -> SubscribeRequest i a b)++-- TODO: SubscribeResponse+instance HasProperties SubscribeResponse where+  properties = lens (\(SubscribeResponse _ _ ps) -> ps) (\(SubscribeResponse a b _) p -> SubscribeResponse a b p)+instance HasPktID SubscribeResponse where+  pktID = lens (\(SubscribeResponse i _ _) -> i) (\(SubscribeResponse _ a b) i -> SubscribeResponse i a b)++-- TODO: UnsubscribeRequest+instance HasProperties UnsubscribeRequest where+  properties = lens (\(UnsubscribeRequest _ _ ps) -> ps) (\(UnsubscribeRequest a b _) p -> UnsubscribeRequest a b p)+instance HasPktID UnsubscribeRequest where+  pktID = lens (\(UnsubscribeRequest i _ _) -> i) (\(UnsubscribeRequest _ a b) i -> UnsubscribeRequest i a b)++-- TODO: UnsubscribeResponse+instance HasProperties UnsubscribeResponse where+  properties = lens (\(UnsubscribeResponse _ ps _) -> ps) (\(UnsubscribeResponse a _ b) p -> UnsubscribeResponse a p b)+instance HasPktID UnsubscribeResponse where+  pktID = lens (\(UnsubscribeResponse i _ _) -> i) (\(UnsubscribeResponse _ a b) i -> UnsubscribeResponse i a b)
+ test/Spec.hs view
@@ -0,0 +1,11 @@+import           Test.Tasty+import           Test.Tasty.HUnit+import           Test.Tasty.QuickCheck as QC++tests :: [TestTree]+tests = [+    testProperty "a test property" (\x -> (x::Int) == id x)+    ]++main :: IO ()+main = defaultMain $ testGroup "All Tests" tests