{-# LANGUAGE CPP #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# OPTIONS_GHC -fno-warn-deprecations #-}

#ifndef MIN_VERSION_base
#define MIN_VERSION_base(x,y,z) 0
#endif

module Data.Pointed where

import Control.Arrow
import Control.Applicative
import qualified Data.Monoid as Monoid
import Data.Default.Class
import GHC.Generics

#ifdef MIN_VERSION_comonad
import Control.Comonad
#endif

#ifdef MIN_VERSION_containers
import Data.Map (Map)
import qualified Data.Map as Map
import Data.Set (Set)
import qualified Data.Set as Set
import Data.Sequence (Seq, ViewL(..), ViewR(..))
import qualified Data.Sequence as Seq
import Data.Tree (Tree(..))
#endif

#ifdef MIN_VERSION_kan_extensions
import Data.Functor.Day.Curried
#endif

#if defined(MIN_VERSION_semigroups) || (MIN_VERSION_base(4,9,0))
import Data.Semigroup as Semigroup
import Data.List.NonEmpty (NonEmpty(..))
#endif

#ifdef MIN_VERSION_semigroupoids
import Data.Functor.Bind
import Data.Semigroupoid.Static
#endif

#ifdef MIN_VERSION_stm
import Control.Concurrent.STM
#endif

#if defined(MIN_VERSION_transformers) || (MIN_VERSION_base(4,8,0))
import Data.Functor.Identity
#endif

#if defined(MIN_VERSION_transformers) || (MIN_VERSION_base(4,9,0))
import Data.Functor.Compose
import qualified Data.Functor.Product as Functor
#endif

#ifdef MIN_VERSION_transformers
import Data.Functor.Constant
import Data.Functor.Reverse
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 Control.Applicative.Backwards
import Control.Applicative.Lift
import Control.Monad.Trans.Cont
import Control.Monad.Trans.Except
import Control.Monad.Trans.Maybe
import Control.Monad.Trans.Identity
import Control.Monad.Trans.Reader

# if !(MIN_VERSION_transformers(0,6,0))
import Control.Monad.Trans.Error
import Control.Monad.Trans.List
# endif
#endif

#if defined(MIN_VERSION_tagged) || (MIN_VERSION_base(4,7,0))
import Data.Proxy
#endif

#ifdef MIN_VERSION_tagged
import Data.Tagged
#endif

#if defined(MIN_VERSION_unordered_containers)
import Data.Hashable
import Data.HashMap.Lazy (HashMap)
import qualified Data.HashMap.Lazy as HashMap
#endif

class Pointed p where
  point :: a -> p a

instance Pointed [] where
  point :: a -> [a]
point a
a = [a
a]

instance Pointed Maybe where
  point :: a -> Maybe a
point = a -> Maybe a
forall a. a -> Maybe a
Just

instance Pointed (Either a) where
  point :: a -> Either a a
point = a -> Either a a
forall a a. a -> Either a a
Right

instance Pointed IO where
  point :: a -> IO a
point = a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return

instance Pointed ZipList where
  point :: a -> ZipList a
point = a -> ZipList a
forall (f :: * -> *) a. Applicative f => a -> f a
pure

#if MIN_VERSION_base(4,8,0) || defined(MIN_VERSION_transformers)
instance Pointed Identity where
  point :: a -> Identity a
point = a -> Identity a
forall a. a -> Identity a
Identity
#endif

instance Pointed ((->)e) where
  point :: a -> e -> a
point = a -> e -> a
forall a b. a -> b -> a
const

instance Default e => Pointed ((,)e) where
  point :: a -> (e, a)
point = (,) e
forall a. Default a => a
def

instance Default m => Pointed (Const m) where
  point :: a -> Const m a
point a
_ = m -> Const m a
forall k a (b :: k). a -> Const a b
Const m
forall a. Default a => a
def

instance Monad m => Pointed (WrappedMonad m) where
  point :: a -> WrappedMonad m a
point = m a -> WrappedMonad m a
forall (m :: * -> *) a. m a -> WrappedMonad m a
WrapMonad (m a -> WrappedMonad m a) -> (a -> m a) -> a -> WrappedMonad m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return

instance Arrow a => Pointed (WrappedArrow a b) where
  point :: a -> WrappedArrow a b a
point = a -> WrappedArrow a b a
forall (f :: * -> *) a. Applicative f => a -> f a
pure

instance Pointed Monoid.Dual where
  point :: a -> Dual a
point = a -> Dual a
forall a. a -> Dual a
Monoid.Dual

instance Pointed Monoid.Endo where
  point :: a -> Endo a
point = (a -> a) -> Endo a
forall a. (a -> a) -> Endo a
Monoid.Endo ((a -> a) -> Endo a) -> (a -> a -> a) -> a -> Endo a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> a -> a
forall a b. a -> b -> a
const

instance Pointed Monoid.Sum where
  point :: a -> Sum a
point = a -> Sum a
forall a. a -> Sum a
Monoid.Sum

instance Pointed Monoid.Product where
  point :: a -> Product a
point = a -> Product a
forall a. a -> Product a
Monoid.Product

instance Pointed Monoid.First where
  point :: a -> First a
point = Maybe a -> First a
forall a. Maybe a -> First a
Monoid.First (Maybe a -> First a) -> (a -> Maybe a) -> a -> First a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Maybe a
forall a. a -> Maybe a
Just

instance Pointed Monoid.Last where
  point :: a -> Last a
point = Maybe a -> Last a
forall a. Maybe a -> Last a
Monoid.Last (Maybe a -> Last a) -> (a -> Maybe a) -> a -> Last a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Maybe a
forall a. a -> Maybe a
Just

#ifdef MIN_VERSION_comonad
instance Pointed (Cokleisli w a) where
  point :: a -> Cokleisli w a a
point = (w a -> a) -> Cokleisli w a a
forall k (w :: k -> *) (a :: k) b. (w a -> b) -> Cokleisli w a b
Cokleisli ((w a -> a) -> Cokleisli w a a)
-> (a -> w a -> a) -> a -> Cokleisli w a a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> w a -> a
forall a b. a -> b -> a
const
#endif

#ifdef MIN_VERSION_containers
instance Pointed Tree where
  point :: a -> Tree a
point a
a = a -> Forest a -> Tree a
forall a. a -> Forest a -> Tree a
Node a
a []

instance Default k => Pointed (Map k) where
  point :: a -> Map k a
point = k -> a -> Map k a
forall k a. k -> a -> Map k a
Map.singleton k
forall a. Default a => a
def

instance Pointed Seq where
  point :: a -> Seq a
point = a -> Seq a
forall a. a -> Seq a
Seq.singleton

instance Pointed ViewL where
  point :: a -> ViewL a
point a
a = a
a a -> Seq a -> ViewL a
forall a. a -> Seq a -> ViewL a
:< Seq a
forall a. Seq a
Seq.empty

instance Pointed ViewR where
  point :: a -> ViewR a
point a
a = Seq a
forall a. Seq a
Seq.empty Seq a -> a -> ViewR a
forall a. Seq a -> a -> ViewR a
:> a
a

instance Pointed Set where
  point :: a -> Set a
point = a -> Set a
forall a. a -> Set a
Set.singleton
#endif

#ifdef MIN_VERSION_kan_extensions
instance (Functor g, g ~ h) => Pointed (Curried g h) where
  point :: a -> Curried g h a
point a
a = (forall r. g (a -> r) -> h r) -> Curried g h a
forall (g :: * -> *) (h :: * -> *) a.
(forall r. g (a -> r) -> h r) -> Curried g h a
Curried (((a -> r) -> r) -> h (a -> r) -> h r
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((a -> r) -> a -> r
forall a b. (a -> b) -> a -> b
$ a
a))
  {-# INLINE point #-}
#endif

#ifdef MIN_VERSION_semigroupoids
instance Pointed m => Pointed (Static m a) where
  point :: a -> Static m a a
point = m (a -> a) -> Static m a a
forall (f :: * -> *) a b. f (a -> b) -> Static f a b
Static (m (a -> a) -> Static m a a)
-> (a -> m (a -> a)) -> a -> Static m a a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> a) -> m (a -> a)
forall (p :: * -> *) a. Pointed p => a -> p a
point ((a -> a) -> m (a -> a)) -> (a -> a -> a) -> a -> m (a -> a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> a -> a
forall a b. a -> b -> a
const

instance Pointed f => Pointed (WrappedApplicative f) where
  point :: a -> WrappedApplicative f a
point = f a -> WrappedApplicative f a
forall (f :: * -> *) a. f a -> WrappedApplicative f a
WrapApplicative (f a -> WrappedApplicative f a)
-> (a -> f a) -> a -> WrappedApplicative f a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> f a
forall (p :: * -> *) a. Pointed p => a -> p a
point

instance Pointed (MaybeApply f) where
  point :: a -> MaybeApply f a
point = Either (f a) a -> MaybeApply f a
forall (f :: * -> *) a. Either (f a) a -> MaybeApply f a
MaybeApply (Either (f a) a -> MaybeApply f a)
-> (a -> Either (f a) a) -> a -> MaybeApply f a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Either (f a) a
forall a a. a -> Either a a
Right
#endif

#if defined(MIN_VERSION_semigroups) || (MIN_VERSION_base(4,9,0))
instance Pointed NonEmpty where
  point :: a -> NonEmpty a
point a
a = a
a a -> [a] -> NonEmpty a
forall a. a -> [a] -> NonEmpty a
:| []

instance Pointed Semigroup.First where
  point :: a -> First a
point = a -> First a
forall a. a -> First a
Semigroup.First

instance Pointed Semigroup.Last where
  point :: a -> Last a
point = a -> Last a
forall a. a -> Last a
Semigroup.Last

instance Pointed Semigroup.Max where
  point :: a -> Max a
point = a -> Max a
forall a. a -> Max a
Semigroup.Max

instance Pointed Semigroup.Min where
  point :: a -> Min a
point = a -> Min a
forall a. a -> Min a
Semigroup.Min

# if !(MIN_VERSION_base(4,16,0))
instance Pointed Option where
  point :: a -> Option a
point = Maybe a -> Option a
forall a. Maybe a -> Option a
Option (Maybe a -> Option a) -> (a -> Maybe a) -> a -> Option a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Maybe a
forall a. a -> Maybe a
Just
# endif

instance Pointed WrappedMonoid where
  point :: a -> WrappedMonoid a
point = a -> WrappedMonoid a
forall a. a -> WrappedMonoid a
WrapMonoid
#endif

#ifdef MIN_VERSION_semigroups
#if MIN_VERSION_semigroups(0,16,2)
#define HAVE_ARG 1
#endif
#elif MIN_VERSION_base(4,9,0)
#define HAVE_ARG 1
#endif

#ifdef HAVE_ARG
instance Default a => Pointed (Arg a) where
  point :: a -> Arg a a
point = a -> a -> Arg a a
forall a b. a -> b -> Arg a b
Arg a
forall a. Default a => a
def
#endif

#ifdef MIN_VERSION_stm
instance Pointed STM where
  point :: a -> STM a
point = a -> STM a
forall (m :: * -> *) a. Monad m => a -> m a
return
#endif

#if defined(MIN_VERSION_tagged) || (MIN_VERSION_base(4,7,0))
instance Pointed Proxy where
  point :: a -> Proxy a
point a
_ = Proxy a
forall k (t :: k). Proxy t
Proxy
#endif

#ifdef MIN_VERSION_tagged
instance Pointed (Tagged a) where
  point :: a -> Tagged a a
point = a -> Tagged a a
forall k (s :: k) b. b -> Tagged s b
Tagged
#endif

#if defined(MIN_VERSION_transformers) || (MIN_VERSION_base(4,9,0))
instance (Pointed p, Pointed q) => Pointed (Compose p q) where
  point :: a -> Compose p q a
point = p (q a) -> Compose p q a
forall k k1 (f :: k -> *) (g :: k1 -> k) (a :: k1).
f (g a) -> Compose f g a
Compose (p (q a) -> Compose p q a) -> (a -> p (q a)) -> a -> Compose p q a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. q a -> p (q a)
forall (p :: * -> *) a. Pointed p => a -> p a
point (q a -> p (q a)) -> (a -> q a) -> a -> p (q a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> q a
forall (p :: * -> *) a. Pointed p => a -> p a
point
#endif

#if defined(MIN_VERSION_transformers) || (MIN_VERSION_base(4,9,0))
instance (Pointed p, Pointed q) => Pointed (Functor.Product p q) where
  point :: a -> Product p q a
point a
a = p a -> q a -> Product p q a
forall k (f :: k -> *) (g :: k -> *) (a :: k).
f a -> g a -> Product f g a
Functor.Pair (a -> p a
forall (p :: * -> *) a. Pointed p => a -> p a
point a
a) (a -> q a
forall (p :: * -> *) a. Pointed p => a -> p a
point a
a)
#endif

#ifdef MIN_VERSION_transformers
instance Pointed (ContT r m) where
  point :: a -> ContT r m a
point a
a = ((a -> m r) -> m r) -> ContT r m a
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT ((a -> m r) -> a -> m r
forall a b. (a -> b) -> a -> b
$ a
a)

instance Pointed m => Pointed (ExceptT e m) where
  point :: a -> ExceptT e m a
point = m (Either e a) -> ExceptT e m a
forall e (m :: * -> *) a. m (Either e a) -> ExceptT e m a
ExceptT (m (Either e a) -> ExceptT e m a)
-> (a -> m (Either e a)) -> a -> ExceptT e m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Either e a -> m (Either e a)
forall (p :: * -> *) a. Pointed p => a -> p a
point (Either e a -> m (Either e a))
-> (a -> Either e a) -> a -> m (Either e a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Either e a
forall a a. a -> Either a a
Right

instance Pointed m => Pointed (IdentityT m) where
  point :: a -> IdentityT m a
point = m a -> IdentityT m a
forall k (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT (m a -> IdentityT m a) -> (a -> m a) -> a -> IdentityT m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> m a
forall (p :: * -> *) a. Pointed p => a -> p a
point

instance Pointed m => Pointed (MaybeT m) where
  point :: a -> MaybeT m a
point = m (Maybe a) -> MaybeT m a
forall (m :: * -> *) a. m (Maybe a) -> MaybeT m a
MaybeT (m (Maybe a) -> MaybeT m a)
-> (a -> m (Maybe a)) -> a -> MaybeT m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe a -> m (Maybe a)
forall (p :: * -> *) a. Pointed p => a -> p a
point (Maybe a -> m (Maybe a)) -> (a -> Maybe a) -> a -> m (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Maybe a
forall (p :: * -> *) a. Pointed p => a -> p a
point

instance Pointed m => Pointed (ReaderT r m) where
  point :: a -> ReaderT r m a
point = (r -> m a) -> ReaderT r m a
forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
ReaderT ((r -> m a) -> ReaderT r m a)
-> (a -> r -> m a) -> a -> ReaderT r m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. m a -> r -> m a
forall a b. a -> b -> a
const (m a -> r -> m a) -> (a -> m a) -> a -> r -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> m a
forall (p :: * -> *) a. Pointed p => a -> p a
point

instance Default m => Pointed (Constant m) where
  point :: a -> Constant m a
point a
_ = m -> Constant m a
forall k a (b :: k). a -> Constant a b
Constant m
forall a. Default a => a
def

instance Pointed m => Pointed (Lazy.StateT s m) where
  point :: a -> StateT s m a
point a
a = (s -> m (a, s)) -> StateT s m a
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
Lazy.StateT ((s -> m (a, s)) -> StateT s m a)
-> (s -> m (a, s)) -> StateT s m a
forall a b. (a -> b) -> a -> b
$ \s
s -> (a, s) -> m (a, s)
forall (p :: * -> *) a. Pointed p => a -> p a
point (a
a, s
s)

instance Pointed m => Pointed (Strict.StateT s m) where
  point :: a -> StateT s m a
point a
a = (s -> m (a, s)) -> StateT s m a
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
Strict.StateT ((s -> m (a, s)) -> StateT s m a)
-> (s -> m (a, s)) -> StateT s m a
forall a b. (a -> b) -> a -> b
$ \s
s -> (a, s) -> m (a, s)
forall (p :: * -> *) a. Pointed p => a -> p a
point (a
a, s
s)

instance (Default w, Pointed m) => Pointed (Lazy.RWST r w s m) where
  point :: a -> RWST r w s m a
point a
a = (r -> s -> m (a, s, w)) -> RWST r w s m a
forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
Lazy.RWST ((r -> s -> m (a, s, w)) -> RWST r w s m a)
-> (r -> s -> m (a, s, w)) -> RWST r w s m a
forall a b. (a -> b) -> a -> b
$ \r
_ s
s -> (a, s, w) -> m (a, s, w)
forall (p :: * -> *) a. Pointed p => a -> p a
point (a
a, s
s, w
forall a. Default a => a
def)

instance (Default w, Pointed m) => Pointed (Strict.RWST r w s m) where
  point :: a -> RWST r w s m a
point a
a = (r -> s -> m (a, s, w)) -> RWST r w s m a
forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
Strict.RWST ((r -> s -> m (a, s, w)) -> RWST r w s m a)
-> (r -> s -> m (a, s, w)) -> RWST r w s m a
forall a b. (a -> b) -> a -> b
$ \r
_ s
s -> (a, s, w) -> m (a, s, w)
forall (p :: * -> *) a. Pointed p => a -> p a
point (a
a, s
s, w
forall a. Default a => a
def)

instance (Default w, Pointed m) => Pointed (Lazy.WriterT w m) where
  point :: a -> WriterT w m a
point a
a = m (a, w) -> WriterT w m a
forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
Lazy.WriterT (m (a, w) -> WriterT w m a) -> m (a, w) -> WriterT w m a
forall a b. (a -> b) -> a -> b
$ (a, w) -> m (a, w)
forall (p :: * -> *) a. Pointed p => a -> p a
point (a
a, w
forall a. Default a => a
def)

instance (Default w, Pointed m) => Pointed (Strict.WriterT w m) where
  point :: a -> WriterT w m a
point a
a = m (a, w) -> WriterT w m a
forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
Strict.WriterT (m (a, w) -> WriterT w m a) -> m (a, w) -> WriterT w m a
forall a b. (a -> b) -> a -> b
$ (a, w) -> m (a, w)
forall (p :: * -> *) a. Pointed p => a -> p a
point (a
a, w
forall a. Default a => a
def)

instance Pointed f => Pointed (Reverse f) where
  point :: a -> Reverse f a
point = f a -> Reverse f a
forall k (f :: k -> *) (a :: k). f a -> Reverse f a
Reverse (f a -> Reverse f a) -> (a -> f a) -> a -> Reverse f a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> f a
forall (p :: * -> *) a. Pointed p => a -> p a
point

instance Pointed f => Pointed (Backwards f) where
  point :: a -> Backwards f a
point = f a -> Backwards f a
forall k (f :: k -> *) (a :: k). f a -> Backwards f a
Backwards (f a -> Backwards f a) -> (a -> f a) -> a -> Backwards f a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> f a
forall (p :: * -> *) a. Pointed p => a -> p a
point

instance Pointed (Lift f) where
  point :: a -> Lift f a
point = a -> Lift f a
forall (f :: * -> *) a. a -> Lift f a
Pure

# if !(MIN_VERSION_transformers(0,6,0))
instance Pointed m => Pointed (ErrorT e m) where
  point :: a -> ErrorT e m a
point = m (Either e a) -> ErrorT e m a
forall e (m :: * -> *) a. m (Either e a) -> ErrorT e m a
ErrorT (m (Either e a) -> ErrorT e m a)
-> (a -> m (Either e a)) -> a -> ErrorT e m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Either e a -> m (Either e a)
forall (p :: * -> *) a. Pointed p => a -> p a
point (Either e a -> m (Either e a))
-> (a -> Either e a) -> a -> m (Either e a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Either e a
forall a a. a -> Either a a
Right

instance Pointed m => Pointed (ListT m) where
  point :: a -> ListT m a
point = m [a] -> ListT m a
forall (m :: * -> *) a. m [a] -> ListT m a
ListT (m [a] -> ListT m a) -> (a -> m [a]) -> a -> ListT m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [a] -> m [a]
forall (p :: * -> *) a. Pointed p => a -> p a
point ([a] -> m [a]) -> (a -> [a]) -> a -> m [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> [a]
forall (p :: * -> *) a. Pointed p => a -> p a
point
# endif
#endif

#if defined(MIN_VERSION_unordered_containers)
instance (Default k, Hashable k) => Pointed (HashMap k) where
  point :: a -> HashMap k a
point = k -> a -> HashMap k a
forall k v. Hashable k => k -> v -> HashMap k v
HashMap.singleton k
forall a. Default a => a
def
#endif

instance Pointed U1 where
  point :: a -> U1 a
point a
_ = U1 a
forall k (p :: k). U1 p
U1

instance Pointed Par1 where
  point :: a -> Par1 a
point = a -> Par1 a
forall a. a -> Par1 a
Par1

instance Pointed f => Pointed (Rec1 f) where
  point :: a -> Rec1 f a
point = f a -> Rec1 f a
forall k (f :: k -> *) (p :: k). f p -> Rec1 f p
Rec1 (f a -> Rec1 f a) -> (a -> f a) -> a -> Rec1 f a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> f a
forall (p :: * -> *) a. Pointed p => a -> p a
point

instance Pointed f => Pointed (M1 i c f) where
  point :: a -> M1 i c f a
point = f a -> M1 i c f a
forall k i (c :: Meta) (f :: k -> *) (p :: k). f p -> M1 i c f p
M1 (f a -> M1 i c f a) -> (a -> f a) -> a -> M1 i c f a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> f a
forall (p :: * -> *) a. Pointed p => a -> p a
point

instance (Pointed f, Pointed g) => Pointed (f :*: g) where
  point :: a -> (:*:) f g a
point a
a = a -> f a
forall (p :: * -> *) a. Pointed p => a -> p a
point a
a f a -> g a -> (:*:) f g a
forall k (f :: k -> *) (g :: k -> *) (p :: k).
f p -> g p -> (:*:) f g p
:*: a -> g a
forall (p :: * -> *) a. Pointed p => a -> p a
point a
a

instance (Pointed f, Pointed g) => Pointed (f :.: g) where
  point :: a -> (:.:) f g a
point = f (g a) -> (:.:) f g a
forall k2 k1 (f :: k2 -> *) (g :: k1 -> k2) (p :: k1).
f (g p) -> (:.:) f g p
Comp1 (f (g a) -> (:.:) f g a) -> (a -> f (g a)) -> a -> (:.:) f g a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. g a -> f (g a)
forall (p :: * -> *) a. Pointed p => a -> p a
point (g a -> f (g a)) -> (a -> g a) -> a -> f (g a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> g a
forall (p :: * -> *) a. Pointed p => a -> p a
point