packages feed

coercible-subtypes-profunctor (empty) → 1

raw patch · 6 files changed

+136/−0 lines, 6 filesdep +basedep +coercible-subtypesdep +profunctorssetup-changed

Dependencies added: base, coercible-subtypes, profunctors

Files

+ CHANGELOG.md view
@@ -0,0 +1,5 @@+# Revision history for coercible-subtypes-profunctor++## 1 -- 2023-10-25++* Split from coercible-subtypes-0.3.0.0
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2020, Koji Miyazato++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 Koji Miyazato 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,5 @@+# coercible-subtypes-profunctors++This is an auxiliary package to use [Profunctor](https://hackage.haskell.org/package/profunctors) with [Sub](https://hackage.haskell.org/package/coercible-subtypes),+a type for witnessing one-way safe coercion between types.+
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ coercible-subtypes-profunctor.cabal view
@@ -0,0 +1,32 @@+cabal-version:       2.2+name:                coercible-subtypes-profunctor+version:             1+synopsis:    Combine profunctors with coercible-subtypes+description: Provides the means of mapping @Sub a b@ type over @Profunctor p@.+             The former comes from "coercible-subtypes" package and the latter is from "profunctors".++homepage:            https://github.com/viercc/coercible-subtypes+bug-reports:         https://github.com/viercc/coercible-subtypes/issues+license:             BSD-3-Clause+license-file:        LICENSE+author:              Koji Miyazato+maintainer:          viercc@gmail.com+copyright:           (c) 2020-2021 Koji Miyazato+category:            Data+build-type:          Simple+extra-source-files:  README.md+extra-doc-files:     CHANGELOG.md++source-repository HEAD+  type:     git+  location: https://github.com/viercc/coercible-subtypes+  branch:   master++library+  exposed-modules:     Data.Type.Coercion.Sub.Profunctor+  build-depends:       base >=4.12 && <4.22,+                       coercible-subtypes >= 0.3.0.0 && < 1.1,+                       profunctors >= 5 && < 6+  hs-source-dirs:      src+  default-language:    Haskell2010+  ghc-options:         -Wall -Wcompat
+ src/Data/Type/Coercion/Sub/Profunctor.hs view
@@ -0,0 +1,62 @@+{-# LANGUAGE PolyKinds #-}+{-# LANGUAGE GADTs #-}+{-# LANGUAGE QuantifiedConstraints #-}+{-# LANGUAGE RankNTypes #-}++module Data.Type.Coercion.Sub.Profunctor+  ( dimapR,+    lmapR,+    rmapR,+  )+where++import Data.Coerce (Coercible)+import Data.Profunctor (Profunctor ())+import Data.Type.Coercion (Coercion (..))+import Data.Type.Coercion.Sub.Internal++-- | Extend subtype relation over a 'Profunctor'.+--+-- @+-- 'Data.Type.Coercion.Sub.upcastWith' ('dimapR' f g) == 'Data.Profunctor.dimap' (upcastWith f) (upcastWith g)+-- @+dimapR ::+  ( forall x x' y y'.+    (Coercible x x', Coercible y y') =>+    Coercible (t x y) (t x' y'),+    Profunctor t+  ) =>+  Sub a a' ->+  Sub b b' ->+  Sub (t a' b) (t a b')+dimapR (Sub Coercion) (Sub Coercion) = Sub Coercion++-- | Extend subtype relation over a 'Profunctor' (, but only contravariant part.)+--+-- @+-- 'Data.Type.Coercion.Sub.upcastWith' ('lmapR' f) == 'Data.Profunctor.lmap' (upcastWith f)+-- @+lmapR ::+  ( forall x x' y.+    (Coercible x x') =>+    Coercible (t x y) (t x' y),+    Profunctor t+  ) =>+  Sub a a' ->+  Sub (t a' b) (t a b)+lmapR (Sub Coercion) = Sub Coercion++-- | Extend subtype relation over a 'Profunctor' (, but only covariant part.)+--+-- @+-- 'Data.Type.Coercion.Sub.upcastWith' ('rmapR' g) == 'Data.Profunctor.rmap' (upcastWith g)+-- @+rmapR ::+  ( forall x y y'.+    (Coercible y y') =>+    Coercible (t x y) (t x y'),+    Profunctor t+  ) =>+  Sub b b' ->+  Sub (t a b) (t a b')+rmapR (Sub Coercion) = Sub Coercion