mvc 1.1.6 → 1.1.7
raw patch · 2 files changed
+18/−8 lines, 2 filesdep +semigroupsdep ~asyncdep ~contravariantdep ~foldl
Dependencies added: semigroups
Dependency ranges changed: async, contravariant, foldl, mmorph, transformers
Files
- mvc.cabal +7/−5
- src/MVC.hs +11/−3
mvc.cabal view
@@ -1,5 +1,5 @@ Name: mvc-Version: 1.1.6+Version: 1.1.7 Cabal-Version: >=1.8.0.2 Build-Type: Simple License: BSD3@@ -7,7 +7,7 @@ Copyright: 2014 Gabriel Gonzalez Author: Gabriel Gonzalez Maintainer: Gabriel439@gmail.com-Tested-With: GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.2+Tested-With: GHC == 8.0.2 Bug-Reports: https://github.com/Gabriel439/Haskell-MVC-Library/issues Synopsis: Model-view-controller Description: Use the @mvc@ library to distill concurrent programs into pure and@@ -28,14 +28,16 @@ Hs-Source-Dirs: src Build-Depends: base >= 4 && < 5 ,- async >= 2.0.0 && < 2.2,+ async >= 2.0.0 && < 2.3, contravariant < 1.5,- foldl >= 1.1 && < 1.4,+ foldl >= 1.4, managed < 1.1,- mmorph >= 1.0.2 && < 1.1,+ mmorph >= 1.0.2 && < 1.2, pipes >= 4.1.7 && < 4.4, pipes-concurrency >= 2.0.3 && < 2.1, transformers >= 0.2.0.0 && < 0.6+ if !impl(ghc >= 8.0)+ Build-depends: semigroups == 0.18.* Exposed-Modules: MVC, MVC.Prelude
src/MVC.hs view
@@ -115,6 +115,7 @@ import Data.Functor.Contravariant (Contravariant(contramap)) import Data.Monoid (Monoid(mempty, mappend, mconcat), (<>), First) import qualified Data.Monoid as M+import qualified Data.Semigroup as S import Pipes import Pipes.Concurrent import Pipes.Prelude (foldM, loop)@@ -161,9 +162,13 @@ instance Functor Controller where fmap f (AsInput i) = AsInput (fmap f i) +-- Deriving `Semigroup`+instance S.Semigroup (Controller a) where+ (AsInput i1) <> (AsInput i2) = AsInput (i1 S.<> i2)+ -- Deriving `Monoid` instance Monoid (Controller a) where- mappend (AsInput i1) (AsInput i2) = AsInput (mappend i1 i2)+ mappend = (<>) mempty = AsInput mempty @@ -254,12 +259,15 @@ -} newtype View a = AsFold (FoldM IO a ()) +instance S.Semigroup (View a) where+ (AsFold fold1) <> (AsFold fold2) = AsFold (fold1 S.<> fold2)+ instance Monoid (View a) where mempty = AsFold mempty- mappend (AsFold fold1) (AsFold fold2) = AsFold (mappend fold1 fold2)+ mappend = (<>) instance Contravariant View where- contramap f (AsFold fold) = AsFold (premapM f fold)+ contramap f (AsFold fold) = AsFold (premapM (return . f) fold) -- | Create a `View` from a sink asSink :: (a -> IO ()) -> View a