pointed-4.2.0.2/0000755000000000000000000000000012526105156011510 5ustar0000000000000000pointed-4.2.0.2/.travis.yml0000644000000000000000000000033412526105156013621 0ustar0000000000000000language: haskell notifications: irc: channels: - "irc.freenode.org#haskell-lens" skip_join: true template: - "\x0313pointed\x03/\x0306%{branch}\x03 \x0314%{commit}\x03 %{build_url} %{message}" pointed-4.2.0.2/CHANGELOG.markdown0000644000000000000000000000125112526105156014542 0ustar00000000000000004.2.0.2 ------- * Added the `CHANGELOG.markdown` to `extra-source-files`, so that `hackage` can display it. 4.2.0.1 ------- * Allow `semigroupoids` 5. 4.2 --- * Add dependency on kan-extensions for instances 4.1.1 --- * Added transformers-compat dependency to loosen transformers dependency 4.1 --- * Added missing instances for `transformers` 0.4 types 4.0 --- * Updated to use the 4.0 versions of `comonad` and `semigroupoids` packages * Updated to use just `data-default-class`. Beware of orphans. 3.1 --- * Added `Tagged` and `Proxy` instances. 3.0.3 ----- * Claim to be Trustworthy 3.0.2 ----- * Removed upper bounds on my other packages * Refactored directory layout pointed-4.2.0.2/LICENSE0000644000000000000000000000236412526105156012522 0ustar0000000000000000Copyright 2008-2011 Edward Kmett All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. 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. THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS 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. pointed-4.2.0.2/pointed.cabal0000644000000000000000000000253212526105156014140 0ustar0000000000000000name: pointed category: Data version: 4.2.0.2 license: BSD3 cabal-version: >= 1.6 license-file: LICENSE author: Edward A. Kmett maintainer: Edward A. Kmett stability: provisional homepage: http://github.com/ekmett/pointed/ bug-reports: http://github.com/ekmett/pointed/issues copyright: Copyright (C) 2008-2013 Edward A. Kmett synopsis: Pointed and copointed data description: Pointed and copointed data build-type: Simple extra-source-files: .travis.yml README.markdown CHANGELOG.markdown source-repository head type: git location: git://github.com/ekmett/pointed.git library build-depends: base >= 4 && < 5, transformers >= 0.2 && < 0.5, transformers-compat >= 0.3 && < 1, containers >= 0.4 && < 0.6, comonad >= 4 && < 5, data-default-class >= 0.0.1 && < 0.1, hashable >= 1.1 && < 1.3, kan-extensions >= 4.2 && < 5, semigroups >= 0.8.3.1 && < 1, semigroupoids >= 4 && < 6, stm >= 2.1.2.1 && < 2.5, tagged >= 0.5 && < 1, unordered-containers >= 0.2 && < 0.3 exposed-modules: Data.Pointed Data.Copointed ghc-options: -Wall hs-source-dirs: src pointed-4.2.0.2/README.markdown0000644000000000000000000000057412526105156014217 0ustar0000000000000000pointed ======= [![Build Status](https://secure.travis-ci.org/ekmett/pointed.png?branch=master)](http://travis-ci.org/ekmett/pointed) Haskell 98 pointed and copointed data types. Contact Information ------------------- Contributions and bug reports are welcome! Please feel free to contact me through github or on the #haskell IRC channel on irc.freenode.net. -Edward Kmett pointed-4.2.0.2/Setup.lhs0000644000000000000000000000016512526105156013322 0ustar0000000000000000#!/usr/bin/runhaskell > module Main (main) where > import Distribution.Simple > main :: IO () > main = defaultMain pointed-4.2.0.2/src/0000755000000000000000000000000012526105156012277 5ustar0000000000000000pointed-4.2.0.2/src/Data/0000755000000000000000000000000012526105156013150 5ustar0000000000000000pointed-4.2.0.2/src/Data/Copointed.hs0000644000000000000000000000732712526105156015441 0ustar0000000000000000{-# LANGUAGE CPP #-} {-# LANGUAGE TypeFamilies #-} #if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 702 {-# LANGUAGE Safe #-} #endif module Data.Copointed where import Data.Default.Class import Data.Functor.Bind import Data.Functor.Identity import Data.Functor.Compose import Data.Functor.Coproduct import Data.Functor.Reverse import Data.Functor.Kan.Lift as Kan import qualified Data.Functor.Sum as F import Data.Tree import Data.Semigroup as Semigroup import Control.Applicative import Control.Applicative.Backwards import Control.Applicative.Lift as Applicative import Control.Monad.Trans.Identity import qualified Control.Monad.Trans.Writer.Lazy as Lazy import qualified Control.Monad.Trans.Writer.Strict as Strict import Control.Comonad.Trans.Env import Control.Comonad.Trans.Store import Control.Comonad.Trans.Traced import Data.List.NonEmpty (NonEmpty(..)) import Data.Tagged -- | 'Copointed' does not require a 'Functor', as the only relationship -- between 'copoint' and 'fmap' is given by a free theorem. class Copointed p where copoint :: p a -> a instance (Copointed f, Copointed g) => Copointed (F.Sum f g) where copoint (F.InL m) = copoint m copoint (F.InR m) = copoint m instance Copointed (Tagged a) where copoint = unTagged instance Copointed Identity where copoint = runIdentity instance Default m => Copointed ((->)m) where copoint f = f def instance (Default m, Copointed w) => Copointed (TracedT m w) where copoint (TracedT w) = copoint w def instance Copointed ((,) a) where copoint = snd instance Copointed ((,,) a b) where copoint (_,_,a) = a instance Copointed ((,,,) a b c) where copoint (_,_,_,a) = a instance Copointed Tree where copoint = rootLabel instance Copointed f => Copointed (Backwards f) where copoint = copoint . forwards instance (Copointed p, Copointed q) => Copointed (Compose p q) where copoint = copoint . copoint . getCompose instance (Copointed p, Copointed q) => Copointed (Coproduct p q) where copoint = coproduct copoint copoint instance Copointed f => Copointed (Applicative.Lift f) where copoint (Pure a) = a copoint (Other fa) = copoint fa instance Copointed f => Copointed (Reverse f) where copoint = copoint . getReverse instance (Functor g, g ~ h) => Copointed (Kan.Lift g h) where copoint x = runIdentity (runLift x (fmap Identity)) {-# INLINE copoint #-} instance Copointed m => Copointed (IdentityT m) where copoint = copoint . runIdentityT instance Copointed m => Copointed (Lazy.WriterT w m) where copoint = fst . copoint . Lazy.runWriterT instance Copointed m => Copointed (Strict.WriterT w m) where copoint = fst . copoint . Strict.runWriterT instance Copointed Dual where copoint = getDual instance Copointed Sum where copoint = getSum instance Copointed NonEmpty where copoint ~(a :| _) = a instance Copointed Semigroup.First where copoint = Semigroup.getFirst instance Copointed Semigroup.Last where copoint = Semigroup.getLast instance Copointed Semigroup.Max where copoint = Semigroup.getMax instance Copointed Semigroup.Min where copoint = Semigroup.getMin instance Copointed WrappedMonoid where copoint = unwrapMonoid #if MIN_VERSION_semigroups(0,16,2) instance Copointed (Arg a) where copoint (Arg _ b) = b #endif instance Copointed w => Copointed (EnvT e w) where copoint = copoint . lowerEnvT instance Copointed w => Copointed (StoreT s w) where copoint (StoreT wf s) = copoint wf s instance Copointed f => Copointed (WrappedApplicative f) where copoint = copoint . unwrapApplicative instance Copointed m => Copointed (WrappedMonad m) where copoint = copoint . unwrapMonad instance Copointed f => Copointed (MaybeApply f) where copoint (MaybeApply (Left fa)) = copoint fa copoint (MaybeApply (Right a)) = apointed-4.2.0.2/src/Data/Pointed.hs0000644000000000000000000001346212526105156015114 0ustar0000000000000000{-# LANGUAGE CPP #-} {-# LANGUAGE TypeFamilies #-} #if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 702 {-# LANGUAGE Safe #-} #endif {-# OPTIONS_GHC -fno-warn-deprecations #-} module Data.Pointed where import Control.Arrow import Control.Applicative import Control.Comonad import Control.Concurrent.STM import Data.Default.Class import qualified Data.Monoid as Monoid import Data.Semigroup as Semigroup import Data.Functor.Identity import Data.Sequence (Seq, ViewL(..), ViewR(..)) import qualified Data.Sequence as Seq import Data.Tree (Tree(..)) import Data.Hashable import Data.HashMap.Lazy (HashMap) import qualified Data.HashMap.Lazy as HashMap import Data.Map (Map) import qualified Data.Map as Map import Data.Set (Set) import qualified Data.Set as Set import Data.Functor.Bind import Data.Functor.Constant import Data.Functor.Kan.Rift import qualified Data.Functor.Product as Functor import Data.Functor.Compose import Data.Functor.Reverse import Control.Applicative.Backwards import Control.Applicative.Lift import Control.Monad.Trans.Cont import Control.Monad.Trans.Error import Control.Monad.Trans.Except import Control.Monad.Trans.List import Control.Monad.Trans.Maybe import Control.Monad.Trans.Identity import Control.Monad.Trans.Reader import Data.List.NonEmpty import qualified Control.Monad.Trans.RWS.Lazy as Lazy import qualified Control.Monad.Trans.RWS.Strict as Strict import qualified Control.Monad.Trans.Writer.Lazy as Lazy import qualified Control.Monad.Trans.Writer.Strict as Strict import qualified Control.Monad.Trans.State.Lazy as Lazy import qualified Control.Monad.Trans.State.Strict as Strict import Data.Semigroupoid.Static import Data.Tagged import Data.Proxy class Pointed p where point :: a -> p a instance Pointed Proxy where point _ = Proxy instance Pointed (Tagged a) where point = Tagged instance Pointed [] where point a = [a] instance Pointed Maybe where point = Just instance Pointed (Either a) where point = Right instance Pointed IO where point = return instance Pointed STM where point = return instance Pointed Tree where point a = Node a [] instance Pointed NonEmpty where point a = a :| [] instance Pointed ZipList where point = pure instance Pointed Identity where point = Identity instance Pointed ((->)e) where point = const instance Default e => Pointed ((,)e) where point = (,) def instance Monad m => Pointed (WrappedMonad m) where point = WrapMonad . return instance Default m => Pointed (Const m) where point _ = Const def instance Arrow a => Pointed (WrappedArrow a b) where point = pure instance Pointed Dual where point = Dual instance Pointed Endo where point = Endo . const instance Pointed Sum where point = Sum instance Pointed Monoid.Product where point = Monoid.Product instance Pointed Monoid.First where point = Monoid.First . Just instance Pointed Monoid.Last where point = Monoid.Last . Just instance Pointed Semigroup.First where point = Semigroup.First instance Pointed Semigroup.Last where point = Semigroup.Last instance Pointed Semigroup.Max where point = Semigroup.Max instance Pointed Semigroup.Min where point = Semigroup.Min instance Pointed Option where point = Option . Just instance Pointed WrappedMonoid where point = WrapMonoid #if MIN_VERSION_semigroups(0,16,2) instance Default a => Pointed (Arg a) where point = Arg def #endif instance (Default k, Hashable k) => Pointed (HashMap k) where point = HashMap.singleton def instance Default k => Pointed (Map k) where point = Map.singleton def instance Pointed Seq where point = Seq.singleton instance Pointed ViewL where point a = a :< Seq.empty instance Pointed ViewR where point a = Seq.empty :> a instance Pointed Set where point = Set.singleton instance (Pointed p, Pointed q) => Pointed (Compose p q) where point = Compose . point . point instance Pointed f => Pointed (Reverse f) where point = Reverse . point instance Pointed f => Pointed (Backwards f) where point = Backwards . point instance Pointed (Lift f) where point = Pure instance (Functor g, g ~ h) => Pointed (Rift g h) where point a = Rift (fmap ($a)) {-# INLINE point #-} instance (Pointed p, Pointed q) => Pointed (Functor.Product p q) where point a = Functor.Pair (point a) (point a) instance Default m => Pointed (Constant m) where point _ = Constant def instance Pointed (ContT r m) where point a = ContT ($ a) instance Pointed m => Pointed (ErrorT e m) where point = ErrorT . point . Right instance Pointed m => Pointed (ExceptT e m) where point = ExceptT . point . Right instance Pointed m => Pointed (IdentityT m) where point = IdentityT . point instance Pointed m => Pointed (ListT m) where point = ListT . point . point instance Pointed m => Pointed (MaybeT m) where point = MaybeT . point . point instance Pointed m => Pointed (ReaderT r m) where point = ReaderT . const . point instance (Default w, Pointed m) => Pointed (Lazy.RWST r w s m) where point a = Lazy.RWST $ \_ s -> point (a, s, def) instance (Default w, Pointed m) => Pointed (Strict.RWST r w s m) where point a = Strict.RWST $ \_ s -> point (a, s, def) instance (Default w, Pointed m) => Pointed (Lazy.WriterT w m) where point a = Lazy.WriterT $ point (a, def) instance (Default w, Pointed m) => Pointed (Strict.WriterT w m) where point a = Strict.WriterT $ point (a, def) instance Pointed m => Pointed (Lazy.StateT s m) where point a = Lazy.StateT $ \s -> point (a, s) instance Pointed m => Pointed (Strict.StateT s m) where point a = Strict.StateT $ \s -> point (a, s) instance Pointed m => Pointed (Static m a) where point = Static . point . const instance Pointed (Cokleisli w a) where point = Cokleisli . const instance Pointed f => Pointed (WrappedApplicative f) where point = WrapApplicative . point instance Pointed (MaybeApply f) where point = MaybeApply . Right