git.iko.soy/semi-iso-optics
on master help sign in
Fixed ci (?) (#5)
commit74954e590be6241252531aa78a7a2e8159046e5c authoriko <ilyakooo0@gmail.com> dateSat 21 Sep 2019, 20:29 (7 years ago) parentc39adc7
5 files changed+24−9
src/Control/Category/Structures.hs+6−1 src/Control/Lens/Internal/SemiIso.hs+5−3 src/Control/Lens/SemiIso.hs+6 src/Control/Tuple/Morph.hs+1−1 src/Data/Profunctor/Exposed.hs+6−4
src/Control/Category/Structures.hs+6−1
@@ -15,7 +15,12 @@ way then "Control.Arrow".
1515
1616Unfortunately names in this module clash with "Control.Arrow".
1717-}
18−module Control.Category.Structures where
18+module Control.Category.Structures
19+ ( Products(..)
20+ , Coproducts(..)
21+ , CatPlus(..)
22+ , CatTrans(..)
23+ ) where
1924
2025import Control.Arrow (Kleisli(..))
2126import qualified Control.Arrow as BadArrow
src/Control/Lens/Internal/SemiIso.hs+5−3
@@ -9,7 +9,9 @@ License : MIT
99Maintainer : Paweł Nowak <pawel834@gmail.com>
1010Stability : experimental
1111-}
12−module Control.Lens.Internal.SemiIso where
12+module Control.Lens.Internal.SemiIso
13+ ( Retail(..)
14+ ) where
1315
1416import Control.Monad
1517import Data.Profunctor
@@ -25,9 +27,9 @@ instance Profunctor (Retail s t) where
2527 rmap f (Retail l r) = Retail l (fmap f . r)
2628
2729instance Choice (Retail s t) where
28− left' (Retail as st) = Retail
30+ left' (Retail as st) = Retail
2931 (either as (\_ -> Left "semi-iso failed")) (fmap Left . st)
30− right' (Retail as st) = Retail
32+ right' (Retail as st) = Retail
3133 (either (\_ -> Left "semi-iso failed") as) (fmap Right . st)
3234
3335-- Proof of 'Exposed' laws:
src/Control/Lens/SemiIso.hs+6
@@ -4,6 +4,8 @@
44{-# LANGUAGE ViewPatterns #-}
55{-# LANGUAGE PatternSynonyms #-}
66{-# LANGUAGE FlexibleContexts #-}
7+
8+{-# OPTIONS_GHC -Wno-incomplete-patterns #-}
79{- |
810Module : Control.Lens.SemiIso
911Description : Semi-isomorphisms.
@@ -133,6 +135,10 @@ type ASemiIso' s a = ASemiIso s s a a
133135
134136-- | A nice pattern synonym for SemiIso's. Gives you the two functions, just like
135137-- 'viewSemiIso' or 'fromSemiIso'.
138+pattern SemiIso
139+ :: (s -> Either String a)
140+ -> (b -> Either String t)
141+ -> ASemiIso s t a b
136142pattern SemiIso sa bt <- (viewSemiIso -> (sa, bt))
137143
138144-- | A semi-iso stored in a container.
src/Control/Tuple/Morph.hs+1−1
@@ -16,7 +16,7 @@
1616 FlexibleContexts
1717 #-}
1818
19−{-# OPTIONS_GHC -Wno-incomplete-patterns #-}
19+{-# OPTIONS_GHC -Wno-incomplete-patterns -Wno-redundant-constraints #-}
2020
2121module Control.Tuple.Morph
2222 ( morphTuples
src/Data/Profunctor/Exposed.hs+6−4
@@ -9,18 +9,20 @@ License : MIT
99Maintainer : Paweł Nowak <pawel834@gmail.com>
1010Stability : experimental
1111-}
12−module Data.Profunctor.Exposed where
12+module Data.Profunctor.Exposed
13+ ( Exposed(..)
14+ ) where
1315
1416import Data.Profunctor
1517
1618-- | Exposes structure of a Kleisli category beneath a profunctor.
17−--
19+--
1820-- Should obey laws:
19−--
21+--
2022-- prop> merge . rmap return = id
2123-- prop> lmap return . expose = id
2224-- prop> rmap (>>= f) = merge . rmap (fmap f)
2325-- prop> lmap (fmap f) . expose = expose . lmap f
2426class (Monad m, Profunctor p) => Exposed m p | p -> m where
2527 expose :: p a b -> p (m a) b
26− merge :: p a (m b) -> p a b
28+ merge :: p a (m b) -> p a b