polysemy-vinyl (empty) → 0.1.0.0
raw patch · 5 files changed
+131/−0 lines, 5 filesdep +basedep +polysemydep +polysemy-extra
Dependencies added: base, polysemy, polysemy-extra, vinyl
Files
- ChangeLog.md +5/−0
- LICENSE +19/−0
- README.md +3/−0
- polysemy-vinyl.cabal +38/−0
- src/Polysemy/Vinyl.hs +66/−0
+ ChangeLog.md view
@@ -0,0 +1,5 @@+# Changelog for polysemy-vinyl++## v0.1.0.0++* Add `rmapOutput`, `rmapOutput'` `rContramapInput`, `rContramapInput'`.
+ LICENSE view
@@ -0,0 +1,19 @@+Copyright (c) 2020 Daniel Firth++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:++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.md view
@@ -0,0 +1,3 @@+# polysemy-vinyl++Extra functions for using vinyl records with polysemy.
+ polysemy-vinyl.cabal view
@@ -0,0 +1,38 @@+cabal-version: 1.12++-- This file has been generated from package.yaml by hpack version 0.34.2.+--+-- see: https://github.com/sol/hpack++name: polysemy-vinyl+version: 0.1.0.0+synopsis: Functions for mapping vinyl records in polysemy.+description: Extra functions for using vinyl records in polysemy.+category: Polysemy Vinyl+author: Daniel Firth+maintainer: dan.firth@homotopic.tech+copyright: dan.firth@homotopic.tech+license: MIT+license-file: LICENSE+build-type: Simple+extra-source-files:+ README.md+ ChangeLog.md++source-repository head+ type: git+ location: https://gitlab.com/homotopic-tech/polysemy-vinyl++library+ exposed-modules:+ Polysemy.Vinyl+ other-modules:+ Paths_polysemy_vinyl+ hs-source-dirs:+ src+ build-depends:+ base >=4.7 && <5+ , polysemy+ , polysemy-extra+ , vinyl+ default-language: Haskell2010
+ src/Polysemy/Vinyl.hs view
@@ -0,0 +1,66 @@+{-|+Module : Polysemy.Vinyl+License : MIT+Maintainer : dan.firth@homotopic.tech+Stability : experimental++Extra functions for using vinyl records with polysemy.+-}+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE RankNTypes #-}+{-# LANGUAGE TypeOperators #-}+module Polysemy.Vinyl (+ rContramapInput+, rContramapInput'+, rMapOutput+, rMapOutput'+) where++import Control.Arrow+import Data.Vinyl+import Polysemy+import Polysemy.Extra+import Polysemy.Input+import Polysemy.Output++-- | Map an `Input` containing a `Rec` contravariantly via a natural transformation.+-- Uses `rmap`.+--+-- @since 0.1.0.0+rContramapInput :: (RMap xs, Members '[Input (Rec f xs)] r)+ => (forall y. f y -> g y)+ -- ^ A natural transformation from f to g.+ -> Sem (Input (Rec g xs) ': r) a+ -> Sem r a+rContramapInput k = contramapInput (rmap k)++-- | Reinterpreting version of `rContramapInput`.+--+-- @since 0.1.0.0+rContramapInput' :: RMap xs+ => (forall y. f y -> g y)+ -- ^ A natural transformation from f to g.+ -> Sem (Input (Rec g xs) ': r) a+ -> Sem (Input (Rec f xs) ': r) a+rContramapInput' k = raiseUnder >>> rContramapInput k++-- | Map an `Output` containing a `Rec` covariantly via a natural transformation.+-- Uses `rmap`.+--+-- @since 0.1.0.0+rMapOutput :: (RMap xs, Members '[Output (Rec g xs)] r)+ => (forall y. f y -> g y)+ -- ^ A natural transformation from f to g.+ -> Sem (Output (Rec f xs) ': r) a+ -> Sem r a+rMapOutput k = mapOutput (rmap k)++-- | Reinterpreting version of `rMapOutput`.+--+-- @since 0.1.0.0+rMapOutput' :: RMap xs+ => (forall y. f y -> g y)+ -- ^ A natural transformation from f to g.+ -> Sem (Output (Rec f xs) ': r) a+ -> Sem (Output (Rec g xs) ': r) a+rMapOutput' k = raiseUnder >>> rMapOutput k