yall 0.2.0.1 → 0.2.1
raw patch · 3 files changed
+24/−46 lines, 3 filesdep ~categories
Dependency ranges changed: categories
Files
- Data/Yall/Iso.hs +11/−22
- Data/Yall/Lens.hs +7/−15
- yall.cabal +6/−9
Data/Yall/Iso.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE TypeOperators , MultiParamTypeClasses , FlexibleInstances, FlexibleContexts, GeneralizedNewtypeDeriving , TypeFamilies #-}+{-# LANGUAGE DefaultSignatures, TypeOperators , MultiParamTypeClasses , FlexibleInstances, FlexibleContexts, GeneralizedNewtypeDeriving , TypeFamilies #-} module Data.Yall.Iso ( {- | Iso is similar but more flexible than Lens in that they have no dependency on@@ -94,12 +94,10 @@ instance Associative IsoPure (,) where associate = IsoPure associate+ disassociate = IsoPure disassociate instance Associative IsoPure Either where associate = IsoPure associate-instance Disassociative IsoPure (,) where disassociate = IsoPure disassociate-instance Disassociative IsoPure Either where- disassociate = IsoPure disassociate instance Braided IsoPure (,) where braid = IsoPure braid@@ -108,11 +106,10 @@ instance Symmetric IsoPure Either where instance Symmetric IsoPure (,) where -type instance Id IsoPure (,) = () instance Monoidal IsoPure (,) where+ type Id IsoPure (,) = () idl = IsoPure idl idr = IsoPure idr-instance Comonoidal IsoPure (,) where coidl = IsoPure coidl coidr = IsoPure coidr @@ -140,11 +137,10 @@ -- Control.Categorical.Bifunctor-instance (Monad m, Monad w)=> PFunctor (,) (Iso w m) (Iso w m) where- first = firstDefault+instance (Monad m, Monad w)=> PFunctor (,) (Iso w m) (Iso w m) where+ first f = bimap f id instance (Monad m, Monad w)=> QFunctor (,) (Iso w m) (Iso w m) where- second = secondDefault-+ second = bimap id instance (Monad m, Monad w)=> Bifunctor (,) (Iso w m) (Iso w m) (Iso w m) where bimap (Iso f g) (Iso f' g') = Iso (bimapM f f') (bimapM' g g') -- WHY DOES TypeFamilies CAUSE PROBLEMS WITH THIS?:@@ -152,10 +148,9 @@ bimapM' x = fmap extractJoinT . bimap x instance (Monad m, Monad w)=> PFunctor Either (Iso w m) (Iso w m) where- first = firstDefault+ first f = bimap f id instance (Monad m, Monad w)=> QFunctor Either (Iso w m) (Iso w m) where- second = secondDefault-+ second = bimap id instance (Monad m, Monad w)=> Bifunctor Either (Iso w m) (Iso w m) (Iso w m) where bimap (Iso f g) (Iso f' g') = Iso (bimapM f f') (bimapM' g g') where bimapM x = fmap extractJoinE . bimap x@@ -174,15 +169,12 @@ -- Control.Category.Associative instance (Monad m, Monad w)=> Associative (Iso w m) (,) where associate = iso associate disassociate+ disassociate = iso disassociate associate instance (Monad m, Monad w)=> Associative (Iso w m) Either where associate = iso associate disassociate- -instance (Monad m, Monad w)=> Disassociative (Iso w m) (,) where disassociate = iso disassociate associate--instance (Monad m, Monad w)=> Disassociative (Iso w m) Either where- disassociate = iso disassociate associate+ -- Control.Category.Braided instance (Monad m, Monad w)=> Braided (Iso w m) (,) where@@ -201,13 +193,10 @@ factorI = iso factor distribute -- Control.Category.Monoidal-type instance Id (Iso w m) (,) = ()- instance (Monad m, Monad w)=> Monoidal (Iso w m) (,) where+ type Id (Iso w m) (,) = () idl = iso idl coidl idr = iso idr coidr--instance (Monad m, Monad w)=> Comonoidal (Iso w m) (,) where coidl = iso coidl idl coidr = iso coidr idr
Data/Yall/Lens.hs view
@@ -111,11 +111,11 @@ , (^$), (^>>=) ) where --- TODO--- - for GHC 7.2, EK has switched to using DefaultSignatures in e.g. Bifunctor. See:--- https://github.com/ekmett/categories/commit/81857ce79d6c24be08d827f115109f1c6b8971ea--- at some point we'll want to upgrade this, and make the appropriate changes+-- TODO (PROBS NOT GOING TO HAPPEN) -- - look at some of the looping combinators we use in pez and include here, e.g. untilL :: (a -> Bool) -> Lens a a -> Lens a a+-- - automatic lens deriving TH (included in module)+-- - generate von laarhoven lenses (compatible with 'lens')+-- - predefined lenses for Prelude types and State import Data.Yall.Iso@@ -140,10 +140,6 @@ import Data.Functor.Identity -{-- TODO initial release- template haskell library--} -- constrain these 'm's to Monad? newtype Lens w m a b = Lens { runLens :: a -> m (b -> w a, b) }@@ -238,10 +234,10 @@ -- BIFUNCTOR: -- instance (Monad w, Monad m)=> PFunctor (,) (Lens w m) (Lens w m) where --first :: Lens a b -> Lens (a,x) (b,x)- first = firstDefault+ first f = bimap f id instance (Monad w, Monad m)=> QFunctor (,) (Lens w m) (Lens w m) where- second = secondDefault+ second = bimap id instance (Monad w, Monad m)=> Bifunctor (,) (Lens w m) (Lens w m) (Lens w m) where bimap (Lens f) (Lens g) = @@ -276,8 +272,6 @@ instance (Monad w, Monad m)=> Associative (Lens w m) (,) where --associate :: Lens ((a,b),c) (a,(b,c)) associate = Lens $ \((a,b),c)-> return (\(a',(b',c'))-> return ((a',b'),c'), (a,(b,c)))--instance (Monad w, Monad m)=> Disassociative (Lens w m) (,) where --disassociate :: Lens (a,(b,c)) ((a,b),c) disassociate =Lens $ \(a,(b,c))-> return (\((a',b'),c') -> return (a',(b',c')), ((a,b),c)) @@ -289,15 +283,13 @@ -- (CO)MONOIDAL ---------------------------------------- -type instance Id (Lens w m) (,) = () -- THIS ABSTRACTS THE dropl/r FUNCTIONS FROM GArrow: instance (Monad w, Monad m)=> Monoidal (Lens w m) (,) where + type Id (Lens w m) (,) = () --idl :: Lens ((), a) a idl = Lens $ \((),a)-> return (\a'-> return ((),a'), a) idr = Lens $ \(a,())-> return (\a'-> return (a',()), a)--instance (Monad w, Monad m)=> Comonoidal (Lens w m) (,) where --coidl :: Lens a ((),a) coidl = Lens $ \a-> return (\((),a')-> return a', ((),a)) coidr = Lens $ \a-> return (\(a',())-> return a', (a,()))
yall.cabal view
@@ -1,6 +1,6 @@ Name: yall -Version: 0.2.0.1+Version: 0.2.1 Synopsis: Lenses with a southern twang @@ -30,6 +30,9 @@ and optionally "Data.Yall.Iso". "Data.Yall" is a simplified, but mostly-compatible, version of a subset of "Data.Yall.Lens". .+ /UPDATE/: I have stopped developing this package. Instead you+ should take a look at and contribute to <http://hackage.haskell.org/package/lens>+ . /TODOs/: . - a module providing template haskell deriving of Lenses@@ -38,13 +41,7 @@ . /CHANGES/: .- - remove 'setEmpty' variants only useful on lenses better expressed in Iso- .- - create a class for lens operations, supporting...- .- - use newtype wrappers for different monadic lifting schemes- .- - better ordering for set, allowing let-floating for partial application+ - depend on categories >= 1 Homepage: http://brandon.si/code/yall/@@ -71,6 +68,6 @@ Library Exposed-modules: Data.Yall, Data.Yall.Lens, Data.Yall.Iso - Build-depends: categories < 1.0+ Build-depends: categories >= 1.0 , transformers , base < 5 && >= 4