on master help sign in
IsList is now a VL Iso (#46)
commitc783c4c767e8e39b7ee1e61bb241ffeda87aaf4b authorCsongor Kiss <kiss.csongor.kiss@gmail.com> dateThu 11 Oct 2018, 16:21 (8 years ago) parent49b8b54
2 files changed+10−2
src/Data/Generics/Internal/Profunctor/Iso.hs+7 src/Data/Generics/Product/HList.hs+3−2
src/Data/Generics/Internal/Profunctor/Iso.hs+7
@@ -1,3 +1,4 @@
1+{-# LANGUAGE TupleSections #-}
12{-# LANGUAGE GADTs #-}
23{-# LANGUAGE NoMonomorphismRestriction #-}
34{-# LANGUAGE Rank2Types #-}
@@ -26,6 +27,8 @@ import GHC.Generics ((:*:)(..), (:+:)(..), Generic(..), M1(..), K1(..)
2627import Data.Coerce
2728import Data.Generics.Internal.GenericN (Rec (..))
2829
30+import qualified Data.Generics.Internal.VL.Iso as VL
31+
2932type Iso s t a b
3033 = forall p. (Profunctor p) => p a b -> p s t
3134
@@ -74,6 +77,10 @@ iso :: (s -> a) -> (b -> t) -> Iso s t a b
7477iso = dimap
7578{-# INLINE iso #-}
7679
80+iso2isovl :: Iso s t a b -> VL.Iso s t a b
81+iso2isovl _iso = withIso _iso VL.iso
82+{-# INLINE iso2isovl #-}
83+
7784withIso :: Iso s t a b -> ((s -> a) -> (b -> t) -> r) -> r
7885withIso ai k = case ai (Exchange id id) of
7986 Exchange sa bt -> k sa bt
src/Data/Generics/Product/HList.hs+3−2
@@ -27,7 +27,8 @@ module Data.Generics.Product.HList
2727import Data.Generics.Product.Internal.HList
2828import Data.Kind
2929import GHC.Generics
30−import Data.Generics.Internal.Profunctor.Iso
30+import Data.Generics.Internal.VL.Iso (Iso)
31+import Data.Generics.Internal.Profunctor.Iso (repIso, iso2isovl)
3132
3233class IsList
3334 (f :: Type)
@@ -41,5 +42,5 @@ instance
4142 , Generic g
4243 , GIsList (Rep f) (Rep g) as bs
4344 ) => IsList f g as bs where
44− list = repIso . glist
45+ list = iso2isovl (repIso . glist)
4546 {-# INLINE list #-}