typeparams 0.0.3.0 → 0.0.3.1
raw patch · 2 files changed
+51/−2 lines, 2 files
Files
- src/Data/Params/Functor.hs +49/−0
- typeparams.cabal +2/−2
+ src/Data/Params/Functor.hs view
@@ -0,0 +1,49 @@+{-# LANGUAGE TemplateHaskell #-}++module Data.Params.Functor+ where++import Control.Category+import Prelude hiding ((.), id, Functor(..), Applicative(..))++import Data.Maybe+import Data.Params++-------------------------------------------------------------------------------++class Functor lens tb where+ fmap' :: ( b ~ GetParam lens tb, ta ~ SetParam lens a tb ) + => TypeLens p lens + -> (a -> b) -> ta -> tb++fmap :: + ( Functor lens tb+ , b ~ GetParam lens tb+ , ta ~ SetParam lens a tb+ ) => TypeLens Base lens+ -> (a -> b) -> ta -> tb+fmap lens = fmap' (lens._base)++-------------------+-- Either++mkParams ''Either++instance Functor p b => Functor (Param_b p) (Either a b) where+ fmap' lens f (Left a) = Left a+ fmap' lens f (Right b) = Right $ fmap' (zoom lens) f b++instance Functor p a => Functor (Param_a p) (Either a b) where+ fmap' lens f (Left a) = Left $ fmap' (zoom lens) f a+ fmap' lens f (Right b) = Right b++instance Functor Base t where+ fmap' _ f a = f a++-------------------+-- Maybe++mkParams ''Maybe+instance Functor p a => Functor (Param_a p) (Maybe a) where+ fmap' lens f Nothing = Nothing+ fmap' lens f (Just a) = Just $ fmap' (zoom lens) f a
typeparams.cabal view
@@ -1,5 +1,5 @@ Name: typeparams-Version: 0.0.3.0+Version: 0.0.3.1 Synopsis: Lens-like interface for type level parameters; allows unboxed unboxed vectors and supercompilation Description: This library provides a lens-like interface for working with type parameters. In the code:@@ -46,7 +46,7 @@ Data.Params Data.Params.Frac Data.Params.PseudoPrim- -- Data.Params.Instances+ Data.Params.Functor Data.Params.Vector -- Data.Params.Vector.Storable -- Data.Params.Vector.StorableRaw