-- |
-- Module      : Control.Applicative.ListF
-- Copyright   : (c) Justin Le 2019
-- License     : BSD3
--
-- Maintainer  : justin@jle.im
-- Stability   : experimental
-- Portability : non-portable
--
-- This module provides functor combinators that are wrappers over lists or
-- maybes of @f a@s, especially for their
-- 'Data.HFunctor.Interpret.Interpret' instances.
--
-- Each one transforms a functor into some product of itself.  For example,
-- @'NonEmptyF' f@ represents @f ':*:' f@, or @f :*: f :*: f@, or @f :*:
-- f :*: f :*: f@, etc.
module Control.Applicative.ListF (
  -- * 'ListF'
    ListF(..), mapListF
  -- * 'NonEmptyF'
  , NonEmptyF(.., ProdNonEmpty, nonEmptyProd), mapNonEmptyF
  , toListF, fromListF
  -- * 'MaybeF'
  , MaybeF(..), mapMaybeF
  , listToMaybeF, maybeToListF
  -- * 'MapF'
  , MapF(..)
  , NEMapF(..)
  ) where

import           Control.Applicative
import           Control.Natural
import           Data.Coerce
import           Data.Data
import           Data.Deriving
import           Data.Foldable
import           Data.Functor.Bind
import           Data.Functor.Classes
import           Data.Functor.Contravariant
import           Data.Functor.Contravariant.Conclude
import           Data.Functor.Contravariant.Decide
import           Data.Functor.Contravariant.Divise
import           Data.Functor.Contravariant.Divisible
import           Data.Functor.Invariant
import           Data.Functor.Plus
import           Data.List.NonEmpty                   (NonEmpty(..))
import           Data.Maybe
import           Data.Pointed
import           Data.Semigroup.Foldable
import           Data.Semigroup.Traversable
import           GHC.Generics
import qualified Data.Map                             as M
import qualified Data.Map.NonEmpty                    as NEM

-- | A list of @f a@s.  Can be used to describe a product of many different
-- values of type @f a@.
--
-- This is the Free 'Plus'.
--
-- Incidentally, if used with a 'Contravariant' @f@, this is instead the
-- free 'Divisible'.
newtype ListF f a = ListF { forall {k} (f :: k -> *) (a :: k). ListF f a -> [f a]
runListF :: [f a] }
  deriving (Int -> ListF f a -> ShowS
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall k (f :: k -> *) (a :: k).
Show (f a) =>
Int -> ListF f a -> ShowS
forall k (f :: k -> *) (a :: k). Show (f a) => [ListF f a] -> ShowS
forall k (f :: k -> *) (a :: k). Show (f a) => ListF f a -> String
showList :: [ListF f a] -> ShowS
$cshowList :: forall k (f :: k -> *) (a :: k). Show (f a) => [ListF f a] -> ShowS
show :: ListF f a -> String
$cshow :: forall k (f :: k -> *) (a :: k). Show (f a) => ListF f a -> String
showsPrec :: Int -> ListF f a -> ShowS
$cshowsPrec :: forall k (f :: k -> *) (a :: k).
Show (f a) =>
Int -> ListF f a -> ShowS
Show, ReadPrec [ListF f a]
ReadPrec (ListF f a)
ReadS [ListF f a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
forall k (f :: k -> *) (a :: k). Read (f a) => ReadPrec [ListF f a]
forall k (f :: k -> *) (a :: k). Read (f a) => ReadPrec (ListF f a)
forall k (f :: k -> *) (a :: k).
Read (f a) =>
Int -> ReadS (ListF f a)
forall k (f :: k -> *) (a :: k). Read (f a) => ReadS [ListF f a]
readListPrec :: ReadPrec [ListF f a]
$creadListPrec :: forall k (f :: k -> *) (a :: k). Read (f a) => ReadPrec [ListF f a]
readPrec :: ReadPrec (ListF f a)
$creadPrec :: forall k (f :: k -> *) (a :: k). Read (f a) => ReadPrec (ListF f a)
readList :: ReadS [ListF f a]
$creadList :: forall k (f :: k -> *) (a :: k). Read (f a) => ReadS [ListF f a]
readsPrec :: Int -> ReadS (ListF f a)
$creadsPrec :: forall k (f :: k -> *) (a :: k).
Read (f a) =>
Int -> ReadS (ListF f a)
Read, ListF f a -> ListF f a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall k (f :: k -> *) (a :: k).
Eq (f a) =>
ListF f a -> ListF f a -> Bool
/= :: ListF f a -> ListF f a -> Bool
$c/= :: forall k (f :: k -> *) (a :: k).
Eq (f a) =>
ListF f a -> ListF f a -> Bool
== :: ListF f a -> ListF f a -> Bool
$c== :: forall k (f :: k -> *) (a :: k).
Eq (f a) =>
ListF f a -> ListF f a -> Bool
Eq, ListF f a -> ListF f a -> Bool
ListF f a -> ListF f a -> Ordering
ListF f a -> ListF f a -> ListF f a
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall {k} {f :: k -> *} {a :: k}. Ord (f a) => Eq (ListF f a)
forall k (f :: k -> *) (a :: k).
Ord (f a) =>
ListF f a -> ListF f a -> Bool
forall k (f :: k -> *) (a :: k).
Ord (f a) =>
ListF f a -> ListF f a -> Ordering
forall k (f :: k -> *) (a :: k).
Ord (f a) =>
ListF f a -> ListF f a -> ListF f a
min :: ListF f a -> ListF f a -> ListF f a
$cmin :: forall k (f :: k -> *) (a :: k).
Ord (f a) =>
ListF f a -> ListF f a -> ListF f a
max :: ListF f a -> ListF f a -> ListF f a
$cmax :: forall k (f :: k -> *) (a :: k).
Ord (f a) =>
ListF f a -> ListF f a -> ListF f a
>= :: ListF f a -> ListF f a -> Bool
$c>= :: forall k (f :: k -> *) (a :: k).
Ord (f a) =>
ListF f a -> ListF f a -> Bool
> :: ListF f a -> ListF f a -> Bool
$c> :: forall k (f :: k -> *) (a :: k).
Ord (f a) =>
ListF f a -> ListF f a -> Bool
<= :: ListF f a -> ListF f a -> Bool
$c<= :: forall k (f :: k -> *) (a :: k).
Ord (f a) =>
ListF f a -> ListF f a -> Bool
< :: ListF f a -> ListF f a -> Bool
$c< :: forall k (f :: k -> *) (a :: k).
Ord (f a) =>
ListF f a -> ListF f a -> Bool
compare :: ListF f a -> ListF f a -> Ordering
$ccompare :: forall k (f :: k -> *) (a :: k).
Ord (f a) =>
ListF f a -> ListF f a -> Ordering
Ord, forall a b. a -> ListF f b -> ListF f a
forall a b. (a -> b) -> ListF f a -> ListF f b
forall (f :: * -> *) a b. Functor f => a -> ListF f b -> ListF f a
forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> ListF f a -> ListF f b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> ListF f b -> ListF f a
$c<$ :: forall (f :: * -> *) a b. Functor f => a -> ListF f b -> ListF f a
fmap :: forall a b. (a -> b) -> ListF f a -> ListF f b
$cfmap :: forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> ListF f a -> ListF f b
Functor, forall a. ListF f a -> Bool
forall m a. Monoid m => (a -> m) -> ListF f a -> m
forall a b. (a -> b -> b) -> b -> ListF f a -> b
forall (f :: * -> *) a.
(Foldable f, Eq a) =>
a -> ListF f a -> Bool
forall (f :: * -> *) a. (Foldable f, Num a) => ListF f a -> a
forall (f :: * -> *) a. (Foldable f, Ord a) => ListF f a -> a
forall (f :: * -> *) m. (Foldable f, Monoid m) => ListF f m -> m
forall (f :: * -> *) a. Foldable f => ListF f a -> Bool
forall (f :: * -> *) a. Foldable f => ListF f a -> Int
forall (f :: * -> *) a. Foldable f => ListF f a -> [a]
forall (f :: * -> *) a.
Foldable f =>
(a -> a -> a) -> ListF f a -> a
forall (f :: * -> *) m a.
(Foldable f, Monoid m) =>
(a -> m) -> ListF f a -> m
forall (f :: * -> *) b a.
Foldable f =>
(b -> a -> b) -> b -> ListF f a -> b
forall (f :: * -> *) a b.
Foldable f =>
(a -> b -> b) -> b -> ListF f a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: forall a. Num a => ListF f a -> a
$cproduct :: forall (f :: * -> *) a. (Foldable f, Num a) => ListF f a -> a
sum :: forall a. Num a => ListF f a -> a
$csum :: forall (f :: * -> *) a. (Foldable f, Num a) => ListF f a -> a
minimum :: forall a. Ord a => ListF f a -> a
$cminimum :: forall (f :: * -> *) a. (Foldable f, Ord a) => ListF f a -> a
maximum :: forall a. Ord a => ListF f a -> a
$cmaximum :: forall (f :: * -> *) a. (Foldable f, Ord a) => ListF f a -> a
elem :: forall a. Eq a => a -> ListF f a -> Bool
$celem :: forall (f :: * -> *) a.
(Foldable f, Eq a) =>
a -> ListF f a -> Bool
length :: forall a. ListF f a -> Int
$clength :: forall (f :: * -> *) a. Foldable f => ListF f a -> Int
null :: forall a. ListF f a -> Bool
$cnull :: forall (f :: * -> *) a. Foldable f => ListF f a -> Bool
toList :: forall a. ListF f a -> [a]
$ctoList :: forall (f :: * -> *) a. Foldable f => ListF f a -> [a]
foldl1 :: forall a. (a -> a -> a) -> ListF f a -> a
$cfoldl1 :: forall (f :: * -> *) a.
Foldable f =>
(a -> a -> a) -> ListF f a -> a
foldr1 :: forall a. (a -> a -> a) -> ListF f a -> a
$cfoldr1 :: forall (f :: * -> *) a.
Foldable f =>
(a -> a -> a) -> ListF f a -> a
foldl' :: forall b a. (b -> a -> b) -> b -> ListF f a -> b
$cfoldl' :: forall (f :: * -> *) b a.
Foldable f =>
(b -> a -> b) -> b -> ListF f a -> b
foldl :: forall b a. (b -> a -> b) -> b -> ListF f a -> b
$cfoldl :: forall (f :: * -> *) b a.
Foldable f =>
(b -> a -> b) -> b -> ListF f a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> ListF f a -> b
$cfoldr' :: forall (f :: * -> *) a b.
Foldable f =>
(a -> b -> b) -> b -> ListF f a -> b
foldr :: forall a b. (a -> b -> b) -> b -> ListF f a -> b
$cfoldr :: forall (f :: * -> *) a b.
Foldable f =>
(a -> b -> b) -> b -> ListF f a -> b
foldMap' :: forall m a. Monoid m => (a -> m) -> ListF f a -> m
$cfoldMap' :: forall (f :: * -> *) m a.
(Foldable f, Monoid m) =>
(a -> m) -> ListF f a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> ListF f a -> m
$cfoldMap :: forall (f :: * -> *) m a.
(Foldable f, Monoid m) =>
(a -> m) -> ListF f a -> m
fold :: forall m. Monoid m => ListF f m -> m
$cfold :: forall (f :: * -> *) m. (Foldable f, Monoid m) => ListF f m -> m
Foldable, forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall {f :: * -> *}. Traversable f => Functor (ListF f)
forall {f :: * -> *}. Traversable f => Foldable (ListF f)
forall (f :: * -> *) (m :: * -> *) a.
(Traversable f, Monad m) =>
ListF f (m a) -> m (ListF f a)
forall (f :: * -> *) (f :: * -> *) a.
(Traversable f, Applicative f) =>
ListF f (f a) -> f (ListF f a)
forall (f :: * -> *) (m :: * -> *) a b.
(Traversable f, Monad m) =>
(a -> m b) -> ListF f a -> m (ListF f b)
forall (f :: * -> *) (f :: * -> *) a b.
(Traversable f, Applicative f) =>
(a -> f b) -> ListF f a -> f (ListF f b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> ListF f a -> f (ListF f b)
sequence :: forall (m :: * -> *) a. Monad m => ListF f (m a) -> m (ListF f a)
$csequence :: forall (f :: * -> *) (m :: * -> *) a.
(Traversable f, Monad m) =>
ListF f (m a) -> m (ListF f a)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> ListF f a -> m (ListF f b)
$cmapM :: forall (f :: * -> *) (m :: * -> *) a b.
(Traversable f, Monad m) =>
(a -> m b) -> ListF f a -> m (ListF f b)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
ListF f (f a) -> f (ListF f a)
$csequenceA :: forall (f :: * -> *) (f :: * -> *) a.
(Traversable f, Applicative f) =>
ListF f (f a) -> f (ListF f a)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> ListF f a -> f (ListF f b)
$ctraverse :: forall (f :: * -> *) (f :: * -> *) a b.
(Traversable f, Applicative f) =>
(a -> f b) -> ListF f a -> f (ListF f b)
Traversable, Typeable, forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall k (f :: k -> *) (a :: k) x. Rep (ListF f a) x -> ListF f a
forall k (f :: k -> *) (a :: k) x. ListF f a -> Rep (ListF f a) x
$cto :: forall k (f :: k -> *) (a :: k) x. Rep (ListF f a) x -> ListF f a
$cfrom :: forall k (f :: k -> *) (a :: k) x. ListF f a -> Rep (ListF f a) x
Generic, ListF f a -> DataType
ListF f a -> Constr
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall {k} {f :: k -> *} {a :: k}.
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
Typeable (ListF f a)
forall k (f :: k -> *) (a :: k).
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
ListF f a -> DataType
forall k (f :: k -> *) (a :: k).
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
ListF f a -> Constr
forall k (f :: k -> *) (a :: k).
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
(forall b. Data b => b -> b) -> ListF f a -> ListF f a
forall k (f :: k -> *) (a :: k) u.
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
Int -> (forall d. Data d => d -> u) -> ListF f a -> u
forall k (f :: k -> *) (a :: k) u.
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
(forall d. Data d => d -> u) -> ListF f a -> [u]
forall k (f :: k -> *) (a :: k) r r'.
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ListF f a -> r
forall k (f :: k -> *) (a :: k) r r'.
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ListF f a -> r
forall k (f :: k -> *) (a :: k) (m :: * -> *).
(Typeable a, Typeable f, Typeable k, Data (f a), Monad m) =>
(forall d. Data d => d -> m d) -> ListF f a -> m (ListF f a)
forall k (f :: k -> *) (a :: k) (m :: * -> *).
(Typeable a, Typeable f, Typeable k, Data (f a), MonadPlus m) =>
(forall d. Data d => d -> m d) -> ListF f a -> m (ListF f a)
forall k (f :: k -> *) (a :: k) (c :: * -> *).
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (ListF f a)
forall k (f :: k -> *) (a :: k) (c :: * -> *).
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ListF f a -> c (ListF f a)
forall k (f :: k -> *) (a :: k) (t :: * -> *) (c :: * -> *).
(Typeable a, Typeable f, Typeable k, Data (f a), Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (ListF f a))
forall k (f :: k -> *) (a :: k) (t :: * -> * -> *) (c :: * -> *).
(Typeable a, Typeable f, Typeable k, Data (f a), Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (ListF f a))
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (ListF f a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ListF f a -> c (ListF f a)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ListF f a -> m (ListF f a)
$cgmapMo :: forall k (f :: k -> *) (a :: k) (m :: * -> *).
(Typeable a, Typeable f, Typeable k, Data (f a), MonadPlus m) =>
(forall d. Data d => d -> m d) -> ListF f a -> m (ListF f a)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ListF f a -> m (ListF f a)
$cgmapMp :: forall k (f :: k -> *) (a :: k) (m :: * -> *).
(Typeable a, Typeable f, Typeable k, Data (f a), MonadPlus m) =>
(forall d. Data d => d -> m d) -> ListF f a -> m (ListF f a)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ListF f a -> m (ListF f a)
$cgmapM :: forall k (f :: k -> *) (a :: k) (m :: * -> *).
(Typeable a, Typeable f, Typeable k, Data (f a), Monad m) =>
(forall d. Data d => d -> m d) -> ListF f a -> m (ListF f a)
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ListF f a -> u
$cgmapQi :: forall k (f :: k -> *) (a :: k) u.
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
Int -> (forall d. Data d => d -> u) -> ListF f a -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> ListF f a -> [u]
$cgmapQ :: forall k (f :: k -> *) (a :: k) u.
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
(forall d. Data d => d -> u) -> ListF f a -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ListF f a -> r
$cgmapQr :: forall k (f :: k -> *) (a :: k) r r'.
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ListF f a -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ListF f a -> r
$cgmapQl :: forall k (f :: k -> *) (a :: k) r r'.
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ListF f a -> r
gmapT :: (forall b. Data b => b -> b) -> ListF f a -> ListF f a
$cgmapT :: forall k (f :: k -> *) (a :: k).
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
(forall b. Data b => b -> b) -> ListF f a -> ListF f a
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (ListF f a))
$cdataCast2 :: forall k (f :: k -> *) (a :: k) (t :: * -> * -> *) (c :: * -> *).
(Typeable a, Typeable f, Typeable k, Data (f a), Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (ListF f a))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (ListF f a))
$cdataCast1 :: forall k (f :: k -> *) (a :: k) (t :: * -> *) (c :: * -> *).
(Typeable a, Typeable f, Typeable k, Data (f a), Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (ListF f a))
dataTypeOf :: ListF f a -> DataType
$cdataTypeOf :: forall k (f :: k -> *) (a :: k).
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
ListF f a -> DataType
toConstr :: ListF f a -> Constr
$ctoConstr :: forall k (f :: k -> *) (a :: k).
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
ListF f a -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (ListF f a)
$cgunfold :: forall k (f :: k -> *) (a :: k) (c :: * -> *).
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (ListF f a)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ListF f a -> c (ListF f a)
$cgfoldl :: forall k (f :: k -> *) (a :: k) (c :: * -> *).
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ListF f a -> c (ListF f a)
Data)

deriveShow1 ''ListF
deriveRead1 ''ListF
deriveEq1 ''ListF
deriveOrd1 ''ListF

instance Apply f => Apply (ListF f) where
    ListF [f (a -> b)]
fs <.> :: forall a b. ListF f (a -> b) -> ListF f a -> ListF f b
<.> ListF [f a]
xs = forall {k} (f :: k -> *) (a :: k). [f a] -> ListF f a
ListF forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a b c.
Apply f =>
(a -> b -> c) -> f a -> f b -> f c
liftF2 forall (f :: * -> *) a b. Apply f => f (a -> b) -> f a -> f b
(<.>) [f (a -> b)]
fs [f a]
xs
instance Applicative f => Applicative (ListF f) where
    pure :: forall a. a -> ListF f a
pure  = forall {k} (f :: k -> *) (a :: k). [f a] -> ListF f a
ListF forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall a. a -> [a] -> [a]
:[]) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a. Applicative f => a -> f a
pure
    ListF [f (a -> b)]
fs <*> :: forall a b. ListF f (a -> b) -> ListF f a -> ListF f b
<*> ListF [f a]
xs = forall {k} (f :: k -> *) (a :: k). [f a] -> ListF f a
ListF forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
(<*>) [f (a -> b)]
fs [f a]
xs

instance Functor f => Alt (ListF f) where
    <!> :: forall a. ListF f a -> ListF f a -> ListF f a
(<!>) = forall a. Semigroup a => a -> a -> a
(<>)

instance Functor f => Plus (ListF f) where
    zero :: forall a. ListF f a
zero = forall a. Monoid a => a
mempty

instance Applicative f => Alternative (ListF f) where
    empty :: forall a. ListF f a
empty = forall (f :: * -> *) a. Plus f => f a
zero
    <|> :: forall a. ListF f a -> ListF f a -> ListF f a
(<|>) = forall (f :: * -> *) a. Alt f => f a -> f a -> f a
(<!>)

instance Semigroup (ListF f a) where
    ListF [f a]
xs <> :: ListF f a -> ListF f a -> ListF f a
<> ListF [f a]
ys = forall {k} (f :: k -> *) (a :: k). [f a] -> ListF f a
ListF ([f a]
xs forall a. [a] -> [a] -> [a]
++ [f a]
ys)

instance Monoid (ListF f a) where
    mempty :: ListF f a
mempty = forall {k} (f :: k -> *) (a :: k). [f a] -> ListF f a
ListF []

instance Pointed f => Pointed (ListF f) where
    point :: forall a. a -> ListF f a
point = forall {k} (f :: k -> *) (a :: k). [f a] -> ListF f a
ListF forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall a. a -> [a] -> [a]
: []) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> *) a. Pointed p => a -> p a
point

-- | @since 0.3.0.0
instance Contravariant f => Contravariant (ListF f) where
    contramap :: forall a' a. (a' -> a) -> ListF f a -> ListF f a'
contramap a' -> a
f (ListF [f a]
xs) = forall {k} (f :: k -> *) (a :: k). [f a] -> ListF f a
ListF ((forall a b. (a -> b) -> [a] -> [b]
map forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a' a.
Contravariant f =>
(a' -> a) -> f a -> f a'
contramap) a' -> a
f [f a]
xs)

-- | @since 0.3.0.0
instance Invariant f => Invariant (ListF f) where
    invmap :: forall a b. (a -> b) -> (b -> a) -> ListF f a -> ListF f b
invmap a -> b
f b -> a
g (ListF [f a]
xs) = forall {k} (f :: k -> *) (a :: k). [f a] -> ListF f a
ListF (forall a b. (a -> b) -> [a] -> [b]
map (forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap a -> b
f b -> a
g) [f a]
xs)

-- | @since 0.3.0.0
instance Contravariant f => Divise (ListF f) where
    divise :: forall a b c. (a -> (b, c)) -> ListF f b -> ListF f c -> ListF f a
divise a -> (b, c)
f (ListF [f b]
xs) (ListF [f c]
ys) = forall {k} (f :: k -> *) (a :: k). [f a] -> ListF f a
ListF forall a b. (a -> b) -> a -> b
$
         (forall a b. (a -> b) -> [a] -> [b]
map forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a' a.
Contravariant f =>
(a' -> a) -> f a -> f a'
contramap) (forall a b. (a, b) -> a
fst forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> (b, c)
f) [f b]
xs
      forall a. Semigroup a => a -> a -> a
<> (forall a b. (a -> b) -> [a] -> [b]
map forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a' a.
Contravariant f =>
(a' -> a) -> f a -> f a'
contramap) (forall a b. (a, b) -> b
snd forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> (b, c)
f) [f c]
ys

-- | @since 0.3.0.0
instance Contravariant f => Divisible (ListF f) where
    divide :: forall a b c. (a -> (b, c)) -> ListF f b -> ListF f c -> ListF f a
divide  = forall (f :: * -> *) a b c.
Divise f =>
(a -> (b, c)) -> f b -> f c -> f a
divise
    conquer :: forall a. ListF f a
conquer = forall {k} (f :: k -> *) (a :: k). [f a] -> ListF f a
ListF []

-- | @since 0.3.0.0
instance Decide f => Decide (ListF f) where
    decide :: forall a b c.
(a -> Either b c) -> ListF f b -> ListF f c -> ListF f a
decide a -> Either b c
f (ListF [f b]
xs) (ListF [f c]
ys) = forall {k} (f :: k -> *) (a :: k). [f a] -> ListF f a
ListF forall a b. (a -> b) -> a -> b
$
        forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 (forall (f :: * -> *) a b c.
Decide f =>
(a -> Either b c) -> f b -> f c -> f a
decide a -> Either b c
f) [f b]
xs [f c]
ys

-- | @since 0.3.0.0
instance Conclude f => Conclude (ListF f) where
    conclude :: forall a. (a -> Void) -> ListF f a
conclude a -> Void
f = forall {k} (f :: k -> *) (a :: k). [f a] -> ListF f a
ListF [forall (f :: * -> *) a. Conclude f => (a -> Void) -> f a
conclude a -> Void
f]

-- | @since 0.3.0.0
instance Decidable f => Decidable (ListF f) where
    lose :: forall a. (a -> Void) -> ListF f a
lose a -> Void
f = forall {k} (f :: k -> *) (a :: k). [f a] -> ListF f a
ListF [forall (f :: * -> *) a. Decidable f => (a -> Void) -> f a
lose a -> Void
f]
    choose :: forall a b c.
(a -> Either b c) -> ListF f b -> ListF f c -> ListF f a
choose a -> Either b c
f (ListF [f b]
xs) (ListF [f c]
ys) = forall {k} (f :: k -> *) (a :: k). [f a] -> ListF f a
ListF forall a b. (a -> b) -> a -> b
$
        forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 (forall (f :: * -> *) a b c.
Decidable f =>
(a -> Either b c) -> f b -> f c -> f a
choose a -> Either b c
f) [f b]
xs [f c]
ys

-- | Map a function over the inside of a 'ListF'.
mapListF
    :: ([f a] -> [g b])
    -> ListF f a
    -> ListF g b
mapListF :: forall {k} {k} (f :: k -> *) (a :: k) (g :: k -> *) (b :: k).
([f a] -> [g b]) -> ListF f a -> ListF g b
mapListF = coerce :: forall a b. Coercible a b => a -> b
coerce

-- | A non-empty list of @f a@s.  Can be used to describe a product between
-- many different possible values of type @f a@.
--
-- Essentially:
--
-- @
-- 'NonEmptyF' f
--     ~ f                          -- one f
--   ':+:' (f ':*:' f)              -- two f's
--   :+: (f :*: f :*: f)            -- three f's
--   :+: (f :*: f :*: f :*: f)      -- four f's
--   :+: ...                        -- etc.
-- @
--
-- This is the Free 'Plus' on any 'Functor' @f@.
--
-- Incidentally, if used with a 'Contravariant' @f@, this is instead the
-- free 'Divise'.
newtype NonEmptyF f a = NonEmptyF { forall {k} (f :: k -> *) (a :: k). NonEmptyF f a -> NonEmpty (f a)
runNonEmptyF :: NonEmpty (f a) }
  deriving (Int -> NonEmptyF f a -> ShowS
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall k (f :: k -> *) (a :: k).
Show (f a) =>
Int -> NonEmptyF f a -> ShowS
forall k (f :: k -> *) (a :: k).
Show (f a) =>
[NonEmptyF f a] -> ShowS
forall k (f :: k -> *) (a :: k).
Show (f a) =>
NonEmptyF f a -> String
showList :: [NonEmptyF f a] -> ShowS
$cshowList :: forall k (f :: k -> *) (a :: k).
Show (f a) =>
[NonEmptyF f a] -> ShowS
show :: NonEmptyF f a -> String
$cshow :: forall k (f :: k -> *) (a :: k).
Show (f a) =>
NonEmptyF f a -> String
showsPrec :: Int -> NonEmptyF f a -> ShowS
$cshowsPrec :: forall k (f :: k -> *) (a :: k).
Show (f a) =>
Int -> NonEmptyF f a -> ShowS
Show, ReadPrec [NonEmptyF f a]
ReadPrec (NonEmptyF f a)
ReadS [NonEmptyF f a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
forall k (f :: k -> *) (a :: k).
Read (f a) =>
ReadPrec [NonEmptyF f a]
forall k (f :: k -> *) (a :: k).
Read (f a) =>
ReadPrec (NonEmptyF f a)
forall k (f :: k -> *) (a :: k).
Read (f a) =>
Int -> ReadS (NonEmptyF f a)
forall k (f :: k -> *) (a :: k).
Read (f a) =>
ReadS [NonEmptyF f a]
readListPrec :: ReadPrec [NonEmptyF f a]
$creadListPrec :: forall k (f :: k -> *) (a :: k).
Read (f a) =>
ReadPrec [NonEmptyF f a]
readPrec :: ReadPrec (NonEmptyF f a)
$creadPrec :: forall k (f :: k -> *) (a :: k).
Read (f a) =>
ReadPrec (NonEmptyF f a)
readList :: ReadS [NonEmptyF f a]
$creadList :: forall k (f :: k -> *) (a :: k).
Read (f a) =>
ReadS [NonEmptyF f a]
readsPrec :: Int -> ReadS (NonEmptyF f a)
$creadsPrec :: forall k (f :: k -> *) (a :: k).
Read (f a) =>
Int -> ReadS (NonEmptyF f a)
Read, NonEmptyF f a -> NonEmptyF f a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall k (f :: k -> *) (a :: k).
Eq (f a) =>
NonEmptyF f a -> NonEmptyF f a -> Bool
/= :: NonEmptyF f a -> NonEmptyF f a -> Bool
$c/= :: forall k (f :: k -> *) (a :: k).
Eq (f a) =>
NonEmptyF f a -> NonEmptyF f a -> Bool
== :: NonEmptyF f a -> NonEmptyF f a -> Bool
$c== :: forall k (f :: k -> *) (a :: k).
Eq (f a) =>
NonEmptyF f a -> NonEmptyF f a -> Bool
Eq, NonEmptyF f a -> NonEmptyF f a -> Bool
NonEmptyF f a -> NonEmptyF f a -> Ordering
NonEmptyF f a -> NonEmptyF f a -> NonEmptyF f a
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall {k} {f :: k -> *} {a :: k}. Ord (f a) => Eq (NonEmptyF f a)
forall k (f :: k -> *) (a :: k).
Ord (f a) =>
NonEmptyF f a -> NonEmptyF f a -> Bool
forall k (f :: k -> *) (a :: k).
Ord (f a) =>
NonEmptyF f a -> NonEmptyF f a -> Ordering
forall k (f :: k -> *) (a :: k).
Ord (f a) =>
NonEmptyF f a -> NonEmptyF f a -> NonEmptyF f a
min :: NonEmptyF f a -> NonEmptyF f a -> NonEmptyF f a
$cmin :: forall k (f :: k -> *) (a :: k).
Ord (f a) =>
NonEmptyF f a -> NonEmptyF f a -> NonEmptyF f a
max :: NonEmptyF f a -> NonEmptyF f a -> NonEmptyF f a
$cmax :: forall k (f :: k -> *) (a :: k).
Ord (f a) =>
NonEmptyF f a -> NonEmptyF f a -> NonEmptyF f a
>= :: NonEmptyF f a -> NonEmptyF f a -> Bool
$c>= :: forall k (f :: k -> *) (a :: k).
Ord (f a) =>
NonEmptyF f a -> NonEmptyF f a -> Bool
> :: NonEmptyF f a -> NonEmptyF f a -> Bool
$c> :: forall k (f :: k -> *) (a :: k).
Ord (f a) =>
NonEmptyF f a -> NonEmptyF f a -> Bool
<= :: NonEmptyF f a -> NonEmptyF f a -> Bool
$c<= :: forall k (f :: k -> *) (a :: k).
Ord (f a) =>
NonEmptyF f a -> NonEmptyF f a -> Bool
< :: NonEmptyF f a -> NonEmptyF f a -> Bool
$c< :: forall k (f :: k -> *) (a :: k).
Ord (f a) =>
NonEmptyF f a -> NonEmptyF f a -> Bool
compare :: NonEmptyF f a -> NonEmptyF f a -> Ordering
$ccompare :: forall k (f :: k -> *) (a :: k).
Ord (f a) =>
NonEmptyF f a -> NonEmptyF f a -> Ordering
Ord, forall a b. a -> NonEmptyF f b -> NonEmptyF f a
forall a b. (a -> b) -> NonEmptyF f a -> NonEmptyF f b
forall (f :: * -> *) a b.
Functor f =>
a -> NonEmptyF f b -> NonEmptyF f a
forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> NonEmptyF f a -> NonEmptyF f b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> NonEmptyF f b -> NonEmptyF f a
$c<$ :: forall (f :: * -> *) a b.
Functor f =>
a -> NonEmptyF f b -> NonEmptyF f a
fmap :: forall a b. (a -> b) -> NonEmptyF f a -> NonEmptyF f b
$cfmap :: forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> NonEmptyF f a -> NonEmptyF f b
Functor, forall a. NonEmptyF f a -> Bool
forall m a. Monoid m => (a -> m) -> NonEmptyF f a -> m
forall a b. (a -> b -> b) -> b -> NonEmptyF f a -> b
forall (f :: * -> *) a.
(Foldable f, Eq a) =>
a -> NonEmptyF f a -> Bool
forall (f :: * -> *) a. (Foldable f, Num a) => NonEmptyF f a -> a
forall (f :: * -> *) a. (Foldable f, Ord a) => NonEmptyF f a -> a
forall (f :: * -> *) m.
(Foldable f, Monoid m) =>
NonEmptyF f m -> m
forall (f :: * -> *) a. Foldable f => NonEmptyF f a -> Bool
forall (f :: * -> *) a. Foldable f => NonEmptyF f a -> Int
forall (f :: * -> *) a. Foldable f => NonEmptyF f a -> [a]
forall (f :: * -> *) a.
Foldable f =>
(a -> a -> a) -> NonEmptyF f a -> a
forall (f :: * -> *) m a.
(Foldable f, Monoid m) =>
(a -> m) -> NonEmptyF f a -> m
forall (f :: * -> *) b a.
Foldable f =>
(b -> a -> b) -> b -> NonEmptyF f a -> b
forall (f :: * -> *) a b.
Foldable f =>
(a -> b -> b) -> b -> NonEmptyF f a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: forall a. Num a => NonEmptyF f a -> a
$cproduct :: forall (f :: * -> *) a. (Foldable f, Num a) => NonEmptyF f a -> a
sum :: forall a. Num a => NonEmptyF f a -> a
$csum :: forall (f :: * -> *) a. (Foldable f, Num a) => NonEmptyF f a -> a
minimum :: forall a. Ord a => NonEmptyF f a -> a
$cminimum :: forall (f :: * -> *) a. (Foldable f, Ord a) => NonEmptyF f a -> a
maximum :: forall a. Ord a => NonEmptyF f a -> a
$cmaximum :: forall (f :: * -> *) a. (Foldable f, Ord a) => NonEmptyF f a -> a
elem :: forall a. Eq a => a -> NonEmptyF f a -> Bool
$celem :: forall (f :: * -> *) a.
(Foldable f, Eq a) =>
a -> NonEmptyF f a -> Bool
length :: forall a. NonEmptyF f a -> Int
$clength :: forall (f :: * -> *) a. Foldable f => NonEmptyF f a -> Int
null :: forall a. NonEmptyF f a -> Bool
$cnull :: forall (f :: * -> *) a. Foldable f => NonEmptyF f a -> Bool
toList :: forall a. NonEmptyF f a -> [a]
$ctoList :: forall (f :: * -> *) a. Foldable f => NonEmptyF f a -> [a]
foldl1 :: forall a. (a -> a -> a) -> NonEmptyF f a -> a
$cfoldl1 :: forall (f :: * -> *) a.
Foldable f =>
(a -> a -> a) -> NonEmptyF f a -> a
foldr1 :: forall a. (a -> a -> a) -> NonEmptyF f a -> a
$cfoldr1 :: forall (f :: * -> *) a.
Foldable f =>
(a -> a -> a) -> NonEmptyF f a -> a
foldl' :: forall b a. (b -> a -> b) -> b -> NonEmptyF f a -> b
$cfoldl' :: forall (f :: * -> *) b a.
Foldable f =>
(b -> a -> b) -> b -> NonEmptyF f a -> b
foldl :: forall b a. (b -> a -> b) -> b -> NonEmptyF f a -> b
$cfoldl :: forall (f :: * -> *) b a.
Foldable f =>
(b -> a -> b) -> b -> NonEmptyF f a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> NonEmptyF f a -> b
$cfoldr' :: forall (f :: * -> *) a b.
Foldable f =>
(a -> b -> b) -> b -> NonEmptyF f a -> b
foldr :: forall a b. (a -> b -> b) -> b -> NonEmptyF f a -> b
$cfoldr :: forall (f :: * -> *) a b.
Foldable f =>
(a -> b -> b) -> b -> NonEmptyF f a -> b
foldMap' :: forall m a. Monoid m => (a -> m) -> NonEmptyF f a -> m
$cfoldMap' :: forall (f :: * -> *) m a.
(Foldable f, Monoid m) =>
(a -> m) -> NonEmptyF f a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> NonEmptyF f a -> m
$cfoldMap :: forall (f :: * -> *) m a.
(Foldable f, Monoid m) =>
(a -> m) -> NonEmptyF f a -> m
fold :: forall m. Monoid m => NonEmptyF f m -> m
$cfold :: forall (f :: * -> *) m.
(Foldable f, Monoid m) =>
NonEmptyF f m -> m
Foldable, forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall {f :: * -> *}. Traversable f => Functor (NonEmptyF f)
forall {f :: * -> *}. Traversable f => Foldable (NonEmptyF f)
forall (f :: * -> *) (m :: * -> *) a.
(Traversable f, Monad m) =>
NonEmptyF f (m a) -> m (NonEmptyF f a)
forall (f :: * -> *) (f :: * -> *) a.
(Traversable f, Applicative f) =>
NonEmptyF f (f a) -> f (NonEmptyF f a)
forall (f :: * -> *) (m :: * -> *) a b.
(Traversable f, Monad m) =>
(a -> m b) -> NonEmptyF f a -> m (NonEmptyF f b)
forall (f :: * -> *) (f :: * -> *) a b.
(Traversable f, Applicative f) =>
(a -> f b) -> NonEmptyF f a -> f (NonEmptyF f b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> NonEmptyF f a -> f (NonEmptyF f b)
sequence :: forall (m :: * -> *) a.
Monad m =>
NonEmptyF f (m a) -> m (NonEmptyF f a)
$csequence :: forall (f :: * -> *) (m :: * -> *) a.
(Traversable f, Monad m) =>
NonEmptyF f (m a) -> m (NonEmptyF f a)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> NonEmptyF f a -> m (NonEmptyF f b)
$cmapM :: forall (f :: * -> *) (m :: * -> *) a b.
(Traversable f, Monad m) =>
(a -> m b) -> NonEmptyF f a -> m (NonEmptyF f b)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
NonEmptyF f (f a) -> f (NonEmptyF f a)
$csequenceA :: forall (f :: * -> *) (f :: * -> *) a.
(Traversable f, Applicative f) =>
NonEmptyF f (f a) -> f (NonEmptyF f a)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> NonEmptyF f a -> f (NonEmptyF f b)
$ctraverse :: forall (f :: * -> *) (f :: * -> *) a b.
(Traversable f, Applicative f) =>
(a -> f b) -> NonEmptyF f a -> f (NonEmptyF f b)
Traversable, Typeable, forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall k (f :: k -> *) (a :: k) x.
Rep (NonEmptyF f a) x -> NonEmptyF f a
forall k (f :: k -> *) (a :: k) x.
NonEmptyF f a -> Rep (NonEmptyF f a) x
$cto :: forall k (f :: k -> *) (a :: k) x.
Rep (NonEmptyF f a) x -> NonEmptyF f a
$cfrom :: forall k (f :: k -> *) (a :: k) x.
NonEmptyF f a -> Rep (NonEmptyF f a) x
Generic, NonEmptyF f a -> DataType
NonEmptyF f a -> Constr
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall {k} {f :: k -> *} {a :: k}.
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
Typeable (NonEmptyF f a)
forall k (f :: k -> *) (a :: k).
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
NonEmptyF f a -> DataType
forall k (f :: k -> *) (a :: k).
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
NonEmptyF f a -> Constr
forall k (f :: k -> *) (a :: k).
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
(forall b. Data b => b -> b) -> NonEmptyF f a -> NonEmptyF f a
forall k (f :: k -> *) (a :: k) u.
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
Int -> (forall d. Data d => d -> u) -> NonEmptyF f a -> u
forall k (f :: k -> *) (a :: k) u.
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
(forall d. Data d => d -> u) -> NonEmptyF f a -> [u]
forall k (f :: k -> *) (a :: k) r r'.
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NonEmptyF f a -> r
forall k (f :: k -> *) (a :: k) r r'.
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NonEmptyF f a -> r
forall k (f :: k -> *) (a :: k) (m :: * -> *).
(Typeable a, Typeable f, Typeable k, Data (f a), Monad m) =>
(forall d. Data d => d -> m d)
-> NonEmptyF f a -> m (NonEmptyF f a)
forall k (f :: k -> *) (a :: k) (m :: * -> *).
(Typeable a, Typeable f, Typeable k, Data (f a), MonadPlus m) =>
(forall d. Data d => d -> m d)
-> NonEmptyF f a -> m (NonEmptyF f a)
forall k (f :: k -> *) (a :: k) (c :: * -> *).
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (NonEmptyF f a)
forall k (f :: k -> *) (a :: k) (c :: * -> *).
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NonEmptyF f a -> c (NonEmptyF f a)
forall k (f :: k -> *) (a :: k) (t :: * -> *) (c :: * -> *).
(Typeable a, Typeable f, Typeable k, Data (f a), Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (NonEmptyF f a))
forall k (f :: k -> *) (a :: k) (t :: * -> * -> *) (c :: * -> *).
(Typeable a, Typeable f, Typeable k, Data (f a), Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (NonEmptyF f a))
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (NonEmptyF f a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NonEmptyF f a -> c (NonEmptyF f a)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> NonEmptyF f a -> m (NonEmptyF f a)
$cgmapMo :: forall k (f :: k -> *) (a :: k) (m :: * -> *).
(Typeable a, Typeable f, Typeable k, Data (f a), MonadPlus m) =>
(forall d. Data d => d -> m d)
-> NonEmptyF f a -> m (NonEmptyF f a)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> NonEmptyF f a -> m (NonEmptyF f a)
$cgmapMp :: forall k (f :: k -> *) (a :: k) (m :: * -> *).
(Typeable a, Typeable f, Typeable k, Data (f a), MonadPlus m) =>
(forall d. Data d => d -> m d)
-> NonEmptyF f a -> m (NonEmptyF f a)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> NonEmptyF f a -> m (NonEmptyF f a)
$cgmapM :: forall k (f :: k -> *) (a :: k) (m :: * -> *).
(Typeable a, Typeable f, Typeable k, Data (f a), Monad m) =>
(forall d. Data d => d -> m d)
-> NonEmptyF f a -> m (NonEmptyF f a)
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> NonEmptyF f a -> u
$cgmapQi :: forall k (f :: k -> *) (a :: k) u.
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
Int -> (forall d. Data d => d -> u) -> NonEmptyF f a -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> NonEmptyF f a -> [u]
$cgmapQ :: forall k (f :: k -> *) (a :: k) u.
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
(forall d. Data d => d -> u) -> NonEmptyF f a -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NonEmptyF f a -> r
$cgmapQr :: forall k (f :: k -> *) (a :: k) r r'.
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NonEmptyF f a -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NonEmptyF f a -> r
$cgmapQl :: forall k (f :: k -> *) (a :: k) r r'.
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NonEmptyF f a -> r
gmapT :: (forall b. Data b => b -> b) -> NonEmptyF f a -> NonEmptyF f a
$cgmapT :: forall k (f :: k -> *) (a :: k).
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
(forall b. Data b => b -> b) -> NonEmptyF f a -> NonEmptyF f a
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (NonEmptyF f a))
$cdataCast2 :: forall k (f :: k -> *) (a :: k) (t :: * -> * -> *) (c :: * -> *).
(Typeable a, Typeable f, Typeable k, Data (f a), Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (NonEmptyF f a))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (NonEmptyF f a))
$cdataCast1 :: forall k (f :: k -> *) (a :: k) (t :: * -> *) (c :: * -> *).
(Typeable a, Typeable f, Typeable k, Data (f a), Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (NonEmptyF f a))
dataTypeOf :: NonEmptyF f a -> DataType
$cdataTypeOf :: forall k (f :: k -> *) (a :: k).
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
NonEmptyF f a -> DataType
toConstr :: NonEmptyF f a -> Constr
$ctoConstr :: forall k (f :: k -> *) (a :: k).
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
NonEmptyF f a -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (NonEmptyF f a)
$cgunfold :: forall k (f :: k -> *) (a :: k) (c :: * -> *).
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (NonEmptyF f a)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NonEmptyF f a -> c (NonEmptyF f a)
$cgfoldl :: forall k (f :: k -> *) (a :: k) (c :: * -> *).
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NonEmptyF f a -> c (NonEmptyF f a)
Data)

deriveShow1 ''NonEmptyF
deriveRead1 ''NonEmptyF
deriveEq1 ''NonEmptyF
deriveOrd1 ''NonEmptyF

instance Applicative f => Applicative (NonEmptyF f) where
    pure :: forall a. a -> NonEmptyF f a
pure  = forall {k} (f :: k -> *) (a :: k). NonEmpty (f a) -> NonEmptyF f a
NonEmptyF forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall a. a -> [a] -> NonEmpty a
:| []) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a. Applicative f => a -> f a
pure
    NonEmptyF NonEmpty (f (a -> b))
fs <*> :: forall a b. NonEmptyF f (a -> b) -> NonEmptyF f a -> NonEmptyF f b
<*> NonEmptyF NonEmpty (f a)
xs = forall {k} (f :: k -> *) (a :: k). NonEmpty (f a) -> NonEmptyF f a
NonEmptyF forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
(<*>) NonEmpty (f (a -> b))
fs NonEmpty (f a)
xs

instance Functor f => Alt (NonEmptyF f) where
    <!> :: forall a. NonEmptyF f a -> NonEmptyF f a -> NonEmptyF f a
(<!>) = forall a. Semigroup a => a -> a -> a
(<>)

-- | @since 0.3.0.0
instance Contravariant f => Contravariant (NonEmptyF f) where
    contramap :: forall a' a. (a' -> a) -> NonEmptyF f a -> NonEmptyF f a'
contramap a' -> a
f (NonEmptyF NonEmpty (f a)
xs) = forall {k} (f :: k -> *) (a :: k). NonEmpty (f a) -> NonEmptyF f a
NonEmptyF (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall (f :: * -> *) a' a.
Contravariant f =>
(a' -> a) -> f a -> f a'
contramap a' -> a
f) NonEmpty (f a)
xs)
-- | @since 0.3.0.0
instance Invariant f => Invariant (NonEmptyF f) where
    invmap :: forall a b. (a -> b) -> (b -> a) -> NonEmptyF f a -> NonEmptyF f b
invmap a -> b
f b -> a
g (NonEmptyF NonEmpty (f a)
xs) = forall {k} (f :: k -> *) (a :: k). NonEmpty (f a) -> NonEmptyF f a
NonEmptyF (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap a -> b
f b -> a
g) NonEmpty (f a)
xs)
-- | @since 0.3.0.0
instance Contravariant f => Divise (NonEmptyF f) where
    divise :: forall a b c.
(a -> (b, c)) -> NonEmptyF f b -> NonEmptyF f c -> NonEmptyF f a
divise a -> (b, c)
f (NonEmptyF NonEmpty (f b)
xs) (NonEmptyF NonEmpty (f c)
ys) = forall {k} (f :: k -> *) (a :: k). NonEmpty (f a) -> NonEmptyF f a
NonEmptyF forall a b. (a -> b) -> a -> b
$
         (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a' a.
Contravariant f =>
(a' -> a) -> f a -> f a'
contramap) (forall a b. (a, b) -> a
fst forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> (b, c)
f) NonEmpty (f b)
xs
      forall a. Semigroup a => a -> a -> a
<> (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a' a.
Contravariant f =>
(a' -> a) -> f a -> f a'
contramap) (forall a b. (a, b) -> b
snd forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> (b, c)
f) NonEmpty (f c)
ys
-- | @since 0.3.0.0
instance Decide f => Decide (NonEmptyF f) where
    decide :: forall a b c.
(a -> Either b c)
-> NonEmptyF f b -> NonEmptyF f c -> NonEmptyF f a
decide a -> Either b c
f (NonEmptyF NonEmpty (f b)
xs) (NonEmptyF NonEmpty (f c)
ys) = forall {k} (f :: k -> *) (a :: k). NonEmpty (f a) -> NonEmptyF f a
NonEmptyF forall a b. (a -> b) -> a -> b
$
      forall (f :: * -> *) a b c.
Decide f =>
(a -> Either b c) -> f b -> f c -> f a
decide a -> Either b c
f forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> NonEmpty (f b)
xs forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> NonEmpty (f c)
ys

instance Semigroup (NonEmptyF f a) where
    NonEmptyF NonEmpty (f a)
xs <> :: NonEmptyF f a -> NonEmptyF f a -> NonEmptyF f a
<> NonEmptyF NonEmpty (f a)
ys = forall {k} (f :: k -> *) (a :: k). NonEmpty (f a) -> NonEmptyF f a
NonEmptyF (NonEmpty (f a)
xs forall a. Semigroup a => a -> a -> a
<> NonEmpty (f a)
ys)

instance Pointed f => Pointed (NonEmptyF f) where
    point :: forall a. a -> NonEmptyF f a
point = forall {k} (f :: k -> *) (a :: k). NonEmpty (f a) -> NonEmptyF f a
NonEmptyF forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall a. a -> [a] -> NonEmpty a
:| []) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> *) a. Pointed p => a -> p a
point

-- | Map a function over the inside of a 'NonEmptyF'.
mapNonEmptyF
    :: (NonEmpty (f a) -> NonEmpty (g b))
    -> NonEmptyF f a
    -> NonEmptyF g b
mapNonEmptyF :: forall {k} {k} (f :: k -> *) (a :: k) (g :: k -> *) (b :: k).
(NonEmpty (f a) -> NonEmpty (g b))
-> NonEmptyF f a -> NonEmptyF g b
mapNonEmptyF = coerce :: forall a b. Coercible a b => a -> b
coerce

-- | Convert a 'NonEmptyF' into a 'ListF' with at least one item.
toListF :: NonEmptyF f ~> ListF f
toListF :: forall {k} (f :: k -> *). NonEmptyF f ~> ListF f
toListF (NonEmptyF NonEmpty (f x)
xs) = forall {k} (f :: k -> *) (a :: k). [f a] -> ListF f a
ListF (forall (t :: * -> *) a. Foldable t => t a -> [a]
toList NonEmpty (f x)
xs)

-- | Convert a 'ListF' either a 'NonEmptyF', or a 'Proxy' in the case that
-- the list was empty.
fromListF :: ListF f ~> (Proxy :+: NonEmptyF f)
fromListF :: forall {k} (f :: k -> *). ListF f ~> (Proxy :+: NonEmptyF f)
fromListF (ListF [f x]
xs) = case [f x]
xs of
    []   -> forall k (f :: k -> *) (g :: k -> *) (p :: k). f p -> (:+:) f g p
L1 forall {k} (t :: k). Proxy t
Proxy
    f x
y:[f x]
ys -> forall k (f :: k -> *) (g :: k -> *) (p :: k). g p -> (:+:) f g p
R1 forall a b. (a -> b) -> a -> b
$ forall {k} (f :: k -> *) (a :: k). NonEmpty (f a) -> NonEmptyF f a
NonEmptyF (f x
y forall a. a -> [a] -> NonEmpty a
:| [f x]
ys)

-- | Treat a @'NonEmptyF' f@ as a product between an @f@ and a @'ListF' f@.
--
-- 'nonEmptyProd' is the record accessor.
pattern ProdNonEmpty :: (f :*: ListF f) a -> NonEmptyF f a
pattern $bProdNonEmpty :: forall {k} (f :: k -> *) (a :: k).
(:*:) f (ListF f) a -> NonEmptyF f a
$mProdNonEmpty :: forall {r} {k} {f :: k -> *} {a :: k}.
NonEmptyF f a -> ((:*:) f (ListF f) a -> r) -> ((# #) -> r) -> r
ProdNonEmpty { forall {k} (f :: k -> *) (a :: k).
NonEmptyF f a -> (:*:) f (ListF f) a
nonEmptyProd
                     }
            <- ((\case NonEmptyF (f a
x :| [f a]
xs) -> f a
x forall k (f :: k -> *) (g :: k -> *) (p :: k).
f p -> g p -> (:*:) f g p
:*: forall {k} (f :: k -> *) (a :: k). [f a] -> ListF f a
ListF [f a]
xs) -> nonEmptyProd)
  where
    ProdNonEmpty (f a
x :*: ListF [f a]
xs) = forall {k} (f :: k -> *) (a :: k). NonEmpty (f a) -> NonEmptyF f a
NonEmptyF (f a
x forall a. a -> [a] -> NonEmpty a
:| [f a]
xs)
{-# COMPLETE ProdNonEmpty #-}

-- | A maybe @f a@.
--
-- Can be useful for describing a "an @f a@ that may or may not be there".
--
-- This is the free structure for a "fail"-like typeclass that would only
-- have @zero :: f a@.
newtype MaybeF f a = MaybeF { forall {k} (f :: k -> *) (a :: k). MaybeF f a -> Maybe (f a)
runMaybeF :: Maybe (f a) }
  deriving (Int -> MaybeF f a -> ShowS
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall k (f :: k -> *) (a :: k).
Show (f a) =>
Int -> MaybeF f a -> ShowS
forall k (f :: k -> *) (a :: k).
Show (f a) =>
[MaybeF f a] -> ShowS
forall k (f :: k -> *) (a :: k). Show (f a) => MaybeF f a -> String
showList :: [MaybeF f a] -> ShowS
$cshowList :: forall k (f :: k -> *) (a :: k).
Show (f a) =>
[MaybeF f a] -> ShowS
show :: MaybeF f a -> String
$cshow :: forall k (f :: k -> *) (a :: k). Show (f a) => MaybeF f a -> String
showsPrec :: Int -> MaybeF f a -> ShowS
$cshowsPrec :: forall k (f :: k -> *) (a :: k).
Show (f a) =>
Int -> MaybeF f a -> ShowS
Show, ReadPrec [MaybeF f a]
ReadPrec (MaybeF f a)
ReadS [MaybeF f a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
forall k (f :: k -> *) (a :: k).
Read (f a) =>
ReadPrec [MaybeF f a]
forall k (f :: k -> *) (a :: k).
Read (f a) =>
ReadPrec (MaybeF f a)
forall k (f :: k -> *) (a :: k).
Read (f a) =>
Int -> ReadS (MaybeF f a)
forall k (f :: k -> *) (a :: k). Read (f a) => ReadS [MaybeF f a]
readListPrec :: ReadPrec [MaybeF f a]
$creadListPrec :: forall k (f :: k -> *) (a :: k).
Read (f a) =>
ReadPrec [MaybeF f a]
readPrec :: ReadPrec (MaybeF f a)
$creadPrec :: forall k (f :: k -> *) (a :: k).
Read (f a) =>
ReadPrec (MaybeF f a)
readList :: ReadS [MaybeF f a]
$creadList :: forall k (f :: k -> *) (a :: k). Read (f a) => ReadS [MaybeF f a]
readsPrec :: Int -> ReadS (MaybeF f a)
$creadsPrec :: forall k (f :: k -> *) (a :: k).
Read (f a) =>
Int -> ReadS (MaybeF f a)
Read, MaybeF f a -> MaybeF f a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall k (f :: k -> *) (a :: k).
Eq (f a) =>
MaybeF f a -> MaybeF f a -> Bool
/= :: MaybeF f a -> MaybeF f a -> Bool
$c/= :: forall k (f :: k -> *) (a :: k).
Eq (f a) =>
MaybeF f a -> MaybeF f a -> Bool
== :: MaybeF f a -> MaybeF f a -> Bool
$c== :: forall k (f :: k -> *) (a :: k).
Eq (f a) =>
MaybeF f a -> MaybeF f a -> Bool
Eq, MaybeF f a -> MaybeF f a -> Bool
MaybeF f a -> MaybeF f a -> Ordering
MaybeF f a -> MaybeF f a -> MaybeF f a
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall {k} {f :: k -> *} {a :: k}. Ord (f a) => Eq (MaybeF f a)
forall k (f :: k -> *) (a :: k).
Ord (f a) =>
MaybeF f a -> MaybeF f a -> Bool
forall k (f :: k -> *) (a :: k).
Ord (f a) =>
MaybeF f a -> MaybeF f a -> Ordering
forall k (f :: k -> *) (a :: k).
Ord (f a) =>
MaybeF f a -> MaybeF f a -> MaybeF f a
min :: MaybeF f a -> MaybeF f a -> MaybeF f a
$cmin :: forall k (f :: k -> *) (a :: k).
Ord (f a) =>
MaybeF f a -> MaybeF f a -> MaybeF f a
max :: MaybeF f a -> MaybeF f a -> MaybeF f a
$cmax :: forall k (f :: k -> *) (a :: k).
Ord (f a) =>
MaybeF f a -> MaybeF f a -> MaybeF f a
>= :: MaybeF f a -> MaybeF f a -> Bool
$c>= :: forall k (f :: k -> *) (a :: k).
Ord (f a) =>
MaybeF f a -> MaybeF f a -> Bool
> :: MaybeF f a -> MaybeF f a -> Bool
$c> :: forall k (f :: k -> *) (a :: k).
Ord (f a) =>
MaybeF f a -> MaybeF f a -> Bool
<= :: MaybeF f a -> MaybeF f a -> Bool
$c<= :: forall k (f :: k -> *) (a :: k).
Ord (f a) =>
MaybeF f a -> MaybeF f a -> Bool
< :: MaybeF f a -> MaybeF f a -> Bool
$c< :: forall k (f :: k -> *) (a :: k).
Ord (f a) =>
MaybeF f a -> MaybeF f a -> Bool
compare :: MaybeF f a -> MaybeF f a -> Ordering
$ccompare :: forall k (f :: k -> *) (a :: k).
Ord (f a) =>
MaybeF f a -> MaybeF f a -> Ordering
Ord, forall a b. a -> MaybeF f b -> MaybeF f a
forall a b. (a -> b) -> MaybeF f a -> MaybeF f b
forall (f :: * -> *) a b.
Functor f =>
a -> MaybeF f b -> MaybeF f a
forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> MaybeF f a -> MaybeF f b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> MaybeF f b -> MaybeF f a
$c<$ :: forall (f :: * -> *) a b.
Functor f =>
a -> MaybeF f b -> MaybeF f a
fmap :: forall a b. (a -> b) -> MaybeF f a -> MaybeF f b
$cfmap :: forall (f :: * -> *) a b.
Functor f =>
(a -> b) -> MaybeF f a -> MaybeF f b
Functor, forall a. MaybeF f a -> Bool
forall m a. Monoid m => (a -> m) -> MaybeF f a -> m
forall a b. (a -> b -> b) -> b -> MaybeF f a -> b
forall (f :: * -> *) a.
(Foldable f, Eq a) =>
a -> MaybeF f a -> Bool
forall (f :: * -> *) a. (Foldable f, Num a) => MaybeF f a -> a
forall (f :: * -> *) a. (Foldable f, Ord a) => MaybeF f a -> a
forall (f :: * -> *) m. (Foldable f, Monoid m) => MaybeF f m -> m
forall (f :: * -> *) a. Foldable f => MaybeF f a -> Bool
forall (f :: * -> *) a. Foldable f => MaybeF f a -> Int
forall (f :: * -> *) a. Foldable f => MaybeF f a -> [a]
forall (f :: * -> *) a.
Foldable f =>
(a -> a -> a) -> MaybeF f a -> a
forall (f :: * -> *) m a.
(Foldable f, Monoid m) =>
(a -> m) -> MaybeF f a -> m
forall (f :: * -> *) b a.
Foldable f =>
(b -> a -> b) -> b -> MaybeF f a -> b
forall (f :: * -> *) a b.
Foldable f =>
(a -> b -> b) -> b -> MaybeF f a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: forall a. Num a => MaybeF f a -> a
$cproduct :: forall (f :: * -> *) a. (Foldable f, Num a) => MaybeF f a -> a
sum :: forall a. Num a => MaybeF f a -> a
$csum :: forall (f :: * -> *) a. (Foldable f, Num a) => MaybeF f a -> a
minimum :: forall a. Ord a => MaybeF f a -> a
$cminimum :: forall (f :: * -> *) a. (Foldable f, Ord a) => MaybeF f a -> a
maximum :: forall a. Ord a => MaybeF f a -> a
$cmaximum :: forall (f :: * -> *) a. (Foldable f, Ord a) => MaybeF f a -> a
elem :: forall a. Eq a => a -> MaybeF f a -> Bool
$celem :: forall (f :: * -> *) a.
(Foldable f, Eq a) =>
a -> MaybeF f a -> Bool
length :: forall a. MaybeF f a -> Int
$clength :: forall (f :: * -> *) a. Foldable f => MaybeF f a -> Int
null :: forall a. MaybeF f a -> Bool
$cnull :: forall (f :: * -> *) a. Foldable f => MaybeF f a -> Bool
toList :: forall a. MaybeF f a -> [a]
$ctoList :: forall (f :: * -> *) a. Foldable f => MaybeF f a -> [a]
foldl1 :: forall a. (a -> a -> a) -> MaybeF f a -> a
$cfoldl1 :: forall (f :: * -> *) a.
Foldable f =>
(a -> a -> a) -> MaybeF f a -> a
foldr1 :: forall a. (a -> a -> a) -> MaybeF f a -> a
$cfoldr1 :: forall (f :: * -> *) a.
Foldable f =>
(a -> a -> a) -> MaybeF f a -> a
foldl' :: forall b a. (b -> a -> b) -> b -> MaybeF f a -> b
$cfoldl' :: forall (f :: * -> *) b a.
Foldable f =>
(b -> a -> b) -> b -> MaybeF f a -> b
foldl :: forall b a. (b -> a -> b) -> b -> MaybeF f a -> b
$cfoldl :: forall (f :: * -> *) b a.
Foldable f =>
(b -> a -> b) -> b -> MaybeF f a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> MaybeF f a -> b
$cfoldr' :: forall (f :: * -> *) a b.
Foldable f =>
(a -> b -> b) -> b -> MaybeF f a -> b
foldr :: forall a b. (a -> b -> b) -> b -> MaybeF f a -> b
$cfoldr :: forall (f :: * -> *) a b.
Foldable f =>
(a -> b -> b) -> b -> MaybeF f a -> b
foldMap' :: forall m a. Monoid m => (a -> m) -> MaybeF f a -> m
$cfoldMap' :: forall (f :: * -> *) m a.
(Foldable f, Monoid m) =>
(a -> m) -> MaybeF f a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> MaybeF f a -> m
$cfoldMap :: forall (f :: * -> *) m a.
(Foldable f, Monoid m) =>
(a -> m) -> MaybeF f a -> m
fold :: forall m. Monoid m => MaybeF f m -> m
$cfold :: forall (f :: * -> *) m. (Foldable f, Monoid m) => MaybeF f m -> m
Foldable, forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall {f :: * -> *}. Traversable f => Functor (MaybeF f)
forall {f :: * -> *}. Traversable f => Foldable (MaybeF f)
forall (f :: * -> *) (m :: * -> *) a.
(Traversable f, Monad m) =>
MaybeF f (m a) -> m (MaybeF f a)
forall (f :: * -> *) (f :: * -> *) a.
(Traversable f, Applicative f) =>
MaybeF f (f a) -> f (MaybeF f a)
forall (f :: * -> *) (m :: * -> *) a b.
(Traversable f, Monad m) =>
(a -> m b) -> MaybeF f a -> m (MaybeF f b)
forall (f :: * -> *) (f :: * -> *) a b.
(Traversable f, Applicative f) =>
(a -> f b) -> MaybeF f a -> f (MaybeF f b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> MaybeF f a -> f (MaybeF f b)
sequence :: forall (m :: * -> *) a. Monad m => MaybeF f (m a) -> m (MaybeF f a)
$csequence :: forall (f :: * -> *) (m :: * -> *) a.
(Traversable f, Monad m) =>
MaybeF f (m a) -> m (MaybeF f a)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> MaybeF f a -> m (MaybeF f b)
$cmapM :: forall (f :: * -> *) (m :: * -> *) a b.
(Traversable f, Monad m) =>
(a -> m b) -> MaybeF f a -> m (MaybeF f b)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
MaybeF f (f a) -> f (MaybeF f a)
$csequenceA :: forall (f :: * -> *) (f :: * -> *) a.
(Traversable f, Applicative f) =>
MaybeF f (f a) -> f (MaybeF f a)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> MaybeF f a -> f (MaybeF f b)
$ctraverse :: forall (f :: * -> *) (f :: * -> *) a b.
(Traversable f, Applicative f) =>
(a -> f b) -> MaybeF f a -> f (MaybeF f b)
Traversable, Typeable, forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall k (f :: k -> *) (a :: k) x. Rep (MaybeF f a) x -> MaybeF f a
forall k (f :: k -> *) (a :: k) x. MaybeF f a -> Rep (MaybeF f a) x
$cto :: forall k (f :: k -> *) (a :: k) x. Rep (MaybeF f a) x -> MaybeF f a
$cfrom :: forall k (f :: k -> *) (a :: k) x. MaybeF f a -> Rep (MaybeF f a) x
Generic, MaybeF f a -> DataType
MaybeF f a -> Constr
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall {k} {f :: k -> *} {a :: k}.
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
Typeable (MaybeF f a)
forall k (f :: k -> *) (a :: k).
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
MaybeF f a -> DataType
forall k (f :: k -> *) (a :: k).
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
MaybeF f a -> Constr
forall k (f :: k -> *) (a :: k).
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
(forall b. Data b => b -> b) -> MaybeF f a -> MaybeF f a
forall k (f :: k -> *) (a :: k) u.
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
Int -> (forall d. Data d => d -> u) -> MaybeF f a -> u
forall k (f :: k -> *) (a :: k) u.
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
(forall d. Data d => d -> u) -> MaybeF f a -> [u]
forall k (f :: k -> *) (a :: k) r r'.
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> MaybeF f a -> r
forall k (f :: k -> *) (a :: k) r r'.
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> MaybeF f a -> r
forall k (f :: k -> *) (a :: k) (m :: * -> *).
(Typeable a, Typeable f, Typeable k, Data (f a), Monad m) =>
(forall d. Data d => d -> m d) -> MaybeF f a -> m (MaybeF f a)
forall k (f :: k -> *) (a :: k) (m :: * -> *).
(Typeable a, Typeable f, Typeable k, Data (f a), MonadPlus m) =>
(forall d. Data d => d -> m d) -> MaybeF f a -> m (MaybeF f a)
forall k (f :: k -> *) (a :: k) (c :: * -> *).
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (MaybeF f a)
forall k (f :: k -> *) (a :: k) (c :: * -> *).
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> MaybeF f a -> c (MaybeF f a)
forall k (f :: k -> *) (a :: k) (t :: * -> *) (c :: * -> *).
(Typeable a, Typeable f, Typeable k, Data (f a), Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (MaybeF f a))
forall k (f :: k -> *) (a :: k) (t :: * -> * -> *) (c :: * -> *).
(Typeable a, Typeable f, Typeable k, Data (f a), Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (MaybeF f a))
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (MaybeF f a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> MaybeF f a -> c (MaybeF f a)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> MaybeF f a -> m (MaybeF f a)
$cgmapMo :: forall k (f :: k -> *) (a :: k) (m :: * -> *).
(Typeable a, Typeable f, Typeable k, Data (f a), MonadPlus m) =>
(forall d. Data d => d -> m d) -> MaybeF f a -> m (MaybeF f a)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> MaybeF f a -> m (MaybeF f a)
$cgmapMp :: forall k (f :: k -> *) (a :: k) (m :: * -> *).
(Typeable a, Typeable f, Typeable k, Data (f a), MonadPlus m) =>
(forall d. Data d => d -> m d) -> MaybeF f a -> m (MaybeF f a)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> MaybeF f a -> m (MaybeF f a)
$cgmapM :: forall k (f :: k -> *) (a :: k) (m :: * -> *).
(Typeable a, Typeable f, Typeable k, Data (f a), Monad m) =>
(forall d. Data d => d -> m d) -> MaybeF f a -> m (MaybeF f a)
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> MaybeF f a -> u
$cgmapQi :: forall k (f :: k -> *) (a :: k) u.
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
Int -> (forall d. Data d => d -> u) -> MaybeF f a -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> MaybeF f a -> [u]
$cgmapQ :: forall k (f :: k -> *) (a :: k) u.
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
(forall d. Data d => d -> u) -> MaybeF f a -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> MaybeF f a -> r
$cgmapQr :: forall k (f :: k -> *) (a :: k) r r'.
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> MaybeF f a -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> MaybeF f a -> r
$cgmapQl :: forall k (f :: k -> *) (a :: k) r r'.
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> MaybeF f a -> r
gmapT :: (forall b. Data b => b -> b) -> MaybeF f a -> MaybeF f a
$cgmapT :: forall k (f :: k -> *) (a :: k).
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
(forall b. Data b => b -> b) -> MaybeF f a -> MaybeF f a
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (MaybeF f a))
$cdataCast2 :: forall k (f :: k -> *) (a :: k) (t :: * -> * -> *) (c :: * -> *).
(Typeable a, Typeable f, Typeable k, Data (f a), Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (MaybeF f a))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (MaybeF f a))
$cdataCast1 :: forall k (f :: k -> *) (a :: k) (t :: * -> *) (c :: * -> *).
(Typeable a, Typeable f, Typeable k, Data (f a), Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (MaybeF f a))
dataTypeOf :: MaybeF f a -> DataType
$cdataTypeOf :: forall k (f :: k -> *) (a :: k).
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
MaybeF f a -> DataType
toConstr :: MaybeF f a -> Constr
$ctoConstr :: forall k (f :: k -> *) (a :: k).
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
MaybeF f a -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (MaybeF f a)
$cgunfold :: forall k (f :: k -> *) (a :: k) (c :: * -> *).
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (MaybeF f a)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> MaybeF f a -> c (MaybeF f a)
$cgfoldl :: forall k (f :: k -> *) (a :: k) (c :: * -> *).
(Typeable a, Typeable f, Typeable k, Data (f a)) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> MaybeF f a -> c (MaybeF f a)
Data)

deriveShow1 ''MaybeF
deriveRead1 ''MaybeF
deriveEq1 ''MaybeF
deriveOrd1 ''MaybeF

instance Applicative f => Applicative (MaybeF f) where
    pure :: forall a. a -> MaybeF f a
pure = forall {k} (f :: k -> *) (a :: k). Maybe (f a) -> MaybeF f a
MaybeF forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. a -> Maybe a
Just forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a. Applicative f => a -> f a
pure
    MaybeF Maybe (f (a -> b))
f <*> :: forall a b. MaybeF f (a -> b) -> MaybeF f a -> MaybeF f b
<*> MaybeF Maybe (f a)
x = forall {k} (f :: k -> *) (a :: k). Maybe (f a) -> MaybeF f a
MaybeF forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
(<*>) Maybe (f (a -> b))
f Maybe (f a)
x

instance Functor f => Alt (MaybeF f) where
    <!> :: forall a. MaybeF f a -> MaybeF f a -> MaybeF f a
(<!>) = forall a. Semigroup a => a -> a -> a
(<>)

instance Functor f => Plus (MaybeF f) where
    zero :: forall a. MaybeF f a
zero = forall a. Monoid a => a
mempty

instance Applicative f => Alternative (MaybeF f) where
    empty :: forall a. MaybeF f a
empty = forall (f :: * -> *) a. Plus f => f a
zero
    <|> :: forall a. MaybeF f a -> MaybeF f a -> MaybeF f a
(<|>) = forall (f :: * -> *) a. Alt f => f a -> f a -> f a
(<!>)

-- | @since 0.3.3.0
instance Contravariant f => Contravariant (MaybeF f) where
    contramap :: forall a' a. (a' -> a) -> MaybeF f a -> MaybeF f a'
contramap a' -> a
f (MaybeF Maybe (f a)
x) = forall {k} (f :: k -> *) (a :: k). Maybe (f a) -> MaybeF f a
MaybeF forall a b. (a -> b) -> a -> b
$ (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a' a.
Contravariant f =>
(a' -> a) -> f a -> f a'
contramap) a' -> a
f Maybe (f a)
x

-- | @since 0.3.3.0
instance Invariant f => Invariant (MaybeF f) where
    invmap :: forall a b. (a -> b) -> (b -> a) -> MaybeF f a -> MaybeF f b
invmap a -> b
f b -> a
g (MaybeF Maybe (f a)
x) = forall {k} (f :: k -> *) (a :: k). Maybe (f a) -> MaybeF f a
MaybeF forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall (f :: * -> *) a b.
Invariant f =>
(a -> b) -> (b -> a) -> f a -> f b
invmap a -> b
f b -> a
g) Maybe (f a)
x

-- | @since 0.3.3.0
instance Contravariant f => Divise (MaybeF f) where
    divise :: forall a b c.
(a -> (b, c)) -> MaybeF f b -> MaybeF f c -> MaybeF f a
divise a -> (b, c)
f (MaybeF Maybe (f b)
x) (MaybeF Maybe (f c)
y) = forall {k} (f :: k -> *) (a :: k). Maybe (f a) -> MaybeF f a
MaybeF forall a b. (a -> b) -> a -> b
$
          (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a' a.
Contravariant f =>
(a' -> a) -> f a -> f a'
contramap) (forall a b. (a, b) -> a
fst forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> (b, c)
f) Maybe (f b)
x
      forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a' a.
Contravariant f =>
(a' -> a) -> f a -> f a'
contramap) (forall a b. (a, b) -> b
snd forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> (b, c)
f) Maybe (f c)
y

-- | @since 0.3.3.0
instance Contravariant f => Divisible (MaybeF f) where
    divide :: forall a b c.
(a -> (b, c)) -> MaybeF f b -> MaybeF f c -> MaybeF f a
divide  = forall (f :: * -> *) a b c.
Divise f =>
(a -> (b, c)) -> f b -> f c -> f a
divise
    conquer :: forall a. MaybeF f a
conquer = forall {k} (f :: k -> *) (a :: k). Maybe (f a) -> MaybeF f a
MaybeF forall a. Maybe a
Nothing

-- | @since 0.3.3.0
instance Decide f => Decide (MaybeF f) where
    decide :: forall a b c.
(a -> Either b c) -> MaybeF f b -> MaybeF f c -> MaybeF f a
decide a -> Either b c
f (MaybeF Maybe (f b)
x) (MaybeF Maybe (f c)
y) = forall {k} (f :: k -> *) (a :: k). Maybe (f a) -> MaybeF f a
MaybeF forall a b. (a -> b) -> a -> b
$
        forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 (forall (f :: * -> *) a b c.
Decide f =>
(a -> Either b c) -> f b -> f c -> f a
decide a -> Either b c
f) Maybe (f b)
x Maybe (f c)
y

-- | @since 0.3.3.0
instance Conclude f => Conclude (MaybeF f) where
    conclude :: forall a. (a -> Void) -> MaybeF f a
conclude a -> Void
f = forall {k} (f :: k -> *) (a :: k). Maybe (f a) -> MaybeF f a
MaybeF (forall a. a -> Maybe a
Just (forall (f :: * -> *) a. Conclude f => (a -> Void) -> f a
conclude a -> Void
f))

-- | @since 0.3.3.0
instance Decidable f => Decidable (MaybeF f) where
    choose :: forall a b c.
(a -> Either b c) -> MaybeF f b -> MaybeF f c -> MaybeF f a
choose a -> Either b c
f (MaybeF Maybe (f b)
x) (MaybeF Maybe (f c)
y) = forall {k} (f :: k -> *) (a :: k). Maybe (f a) -> MaybeF f a
MaybeF forall a b. (a -> b) -> a -> b
$
        forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 (forall (f :: * -> *) a b c.
Decidable f =>
(a -> Either b c) -> f b -> f c -> f a
choose a -> Either b c
f) Maybe (f b)
x Maybe (f c)
y
    lose :: forall a. (a -> Void) -> MaybeF f a
lose a -> Void
f = forall {k} (f :: k -> *) (a :: k). Maybe (f a) -> MaybeF f a
MaybeF (forall a. a -> Maybe a
Just (forall (f :: * -> *) a. Decidable f => (a -> Void) -> f a
lose a -> Void
f))

-- | Picks the first 'Just'.
instance Semigroup (MaybeF f a) where
    MaybeF Maybe (f a)
xs <> :: MaybeF f a -> MaybeF f a -> MaybeF f a
<> MaybeF Maybe (f a)
ys = forall {k} (f :: k -> *) (a :: k). Maybe (f a) -> MaybeF f a
MaybeF (Maybe (f a)
xs forall (f :: * -> *) a. Alt f => f a -> f a -> f a
<!> Maybe (f a)
ys)

instance Monoid (MaybeF f a) where
    mempty :: MaybeF f a
mempty = forall {k} (f :: k -> *) (a :: k). Maybe (f a) -> MaybeF f a
MaybeF forall a. Maybe a
Nothing

instance Pointed f => Pointed (MaybeF f) where
    point :: forall a. a -> MaybeF f a
point = forall {k} (f :: k -> *) (a :: k). Maybe (f a) -> MaybeF f a
MaybeF forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. a -> Maybe a
Just forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> *) a. Pointed p => a -> p a
point

-- | Map a function over the inside of a 'MaybeF'.
mapMaybeF
    :: (Maybe (f a) -> Maybe (g b))
    -> MaybeF f a
    -> MaybeF g b
mapMaybeF :: forall {k} {k} (f :: k -> *) (a :: k) (g :: k -> *) (b :: k).
(Maybe (f a) -> Maybe (g b)) -> MaybeF f a -> MaybeF g b
mapMaybeF = coerce :: forall a b. Coercible a b => a -> b
coerce

-- | Convert a 'MaybeF' into a 'ListF' with zero or one items.
maybeToListF :: MaybeF f ~> ListF f
maybeToListF :: forall {k} (f :: k -> *). MaybeF f ~> ListF f
maybeToListF (MaybeF Maybe (f x)
x) = forall {k} (f :: k -> *) (a :: k). [f a] -> ListF f a
ListF (forall a. Maybe a -> [a]
maybeToList Maybe (f x)
x)

-- | Convert a 'ListF' into a 'MaybeF' containing the first @f a@ in the
-- list, if it exists.
listToMaybeF :: ListF f ~> MaybeF f
listToMaybeF :: forall {k} (f :: k -> *). ListF f ~> MaybeF f
listToMaybeF (ListF [f x]
xs) = forall {k} (f :: k -> *) (a :: k). Maybe (f a) -> MaybeF f a
MaybeF (forall a. [a] -> Maybe a
listToMaybe [f x]
xs)

-- | A map of @f a@s, indexed by keys of type @k@.  It can be useful for
-- represeting a product of many different values of type @f a@, each "at"
-- a different @k@ location.
--
-- Can be considered a combination of 'Control.Comonad.Trans.Env.EnvT' and
-- 'ListF', in a way --- a @'MapF' k f a@ is like a @'ListF'
-- ('Control.Comonad.Trans.Env.EnvT' k f) a@ with unique (and ordered)
-- keys.
--
-- One use case might be to extend a schema with many "options", indexed by
-- some string.
--
-- For example, if you had a command line argument parser for a single
-- command
--
-- @
-- data Command a
-- @
--
-- Then you can represent a command line argument parser for /multiple/
-- named commands with
--
-- @
-- type Commands = 'MapF' 'String' Command
-- @
--
-- See 'NEMapF' for a non-empty variant, if you want to enforce that your
-- bag has at least one @f a@.
newtype MapF k f a = MapF { forall {k} k (f :: k -> *) (a :: k). MapF k f a -> Map k (f a)
runMapF :: M.Map k (f a) }
  deriving (Int -> MapF k f a -> ShowS
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall k k (f :: k -> *) (a :: k).
(Show k, Show (f a)) =>
Int -> MapF k f a -> ShowS
forall k k (f :: k -> *) (a :: k).
(Show k, Show (f a)) =>
[MapF k f a] -> ShowS
forall k k (f :: k -> *) (a :: k).
(Show k, Show (f a)) =>
MapF k f a -> String
showList :: [MapF k f a] -> ShowS
$cshowList :: forall k k (f :: k -> *) (a :: k).
(Show k, Show (f a)) =>
[MapF k f a] -> ShowS
show :: MapF k f a -> String
$cshow :: forall k k (f :: k -> *) (a :: k).
(Show k, Show (f a)) =>
MapF k f a -> String
showsPrec :: Int -> MapF k f a -> ShowS
$cshowsPrec :: forall k k (f :: k -> *) (a :: k).
(Show k, Show (f a)) =>
Int -> MapF k f a -> ShowS
Show, ReadPrec [MapF k f a]
ReadPrec (MapF k f a)
ReadS [MapF k f a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
forall k k (f :: k -> *) (a :: k).
(Ord k, Read k, Read (f a)) =>
ReadPrec [MapF k f a]
forall k k (f :: k -> *) (a :: k).
(Ord k, Read k, Read (f a)) =>
ReadPrec (MapF k f a)
forall k k (f :: k -> *) (a :: k).
(Ord k, Read k, Read (f a)) =>
Int -> ReadS (MapF k f a)
forall k k (f :: k -> *) (a :: k).
(Ord k, Read k, Read (f a)) =>
ReadS [MapF k f a]
readListPrec :: ReadPrec [MapF k f a]
$creadListPrec :: forall k k (f :: k -> *) (a :: k).
(Ord k, Read k, Read (f a)) =>
ReadPrec [MapF k f a]
readPrec :: ReadPrec (MapF k f a)
$creadPrec :: forall k k (f :: k -> *) (a :: k).
(Ord k, Read k, Read (f a)) =>
ReadPrec (MapF k f a)
readList :: ReadS [MapF k f a]
$creadList :: forall k k (f :: k -> *) (a :: k).
(Ord k, Read k, Read (f a)) =>
ReadS [MapF k f a]
readsPrec :: Int -> ReadS (MapF k f a)
$creadsPrec :: forall k k (f :: k -> *) (a :: k).
(Ord k, Read k, Read (f a)) =>
Int -> ReadS (MapF k f a)
Read, MapF k f a -> MapF k f a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall k k (f :: k -> *) (a :: k).
(Eq k, Eq (f a)) =>
MapF k f a -> MapF k f a -> Bool
/= :: MapF k f a -> MapF k f a -> Bool
$c/= :: forall k k (f :: k -> *) (a :: k).
(Eq k, Eq (f a)) =>
MapF k f a -> MapF k f a -> Bool
== :: MapF k f a -> MapF k f a -> Bool
$c== :: forall k k (f :: k -> *) (a :: k).
(Eq k, Eq (f a)) =>
MapF k f a -> MapF k f a -> Bool
Eq, MapF k f a -> MapF k f a -> Bool
MapF k f a -> MapF k f a -> Ordering
MapF k f a -> MapF k f a -> MapF k f a
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall {k} {k} {f :: k -> *} {a :: k}.
(Ord k, Ord (f a)) =>
Eq (MapF k f a)
forall k k (f :: k -> *) (a :: k).
(Ord k, Ord (f a)) =>
MapF k f a -> MapF k f a -> Bool
forall k k (f :: k -> *) (a :: k).
(Ord k, Ord (f a)) =>
MapF k f a -> MapF k f a -> Ordering
forall k k (f :: k -> *) (a :: k).
(Ord k, Ord (f a)) =>
MapF k f a -> MapF k f a -> MapF k f a
min :: MapF k f a -> MapF k f a -> MapF k f a
$cmin :: forall k k (f :: k -> *) (a :: k).
(Ord k, Ord (f a)) =>
MapF k f a -> MapF k f a -> MapF k f a
max :: MapF k f a -> MapF k f a -> MapF k f a
$cmax :: forall k k (f :: k -> *) (a :: k).
(Ord k, Ord (f a)) =>
MapF k f a -> MapF k f a -> MapF k f a
>= :: MapF k f a -> MapF k f a -> Bool
$c>= :: forall k k (f :: k -> *) (a :: k).
(Ord k, Ord (f a)) =>
MapF k f a -> MapF k f a -> Bool
> :: MapF k f a -> MapF k f a -> Bool
$c> :: forall k k (f :: k -> *) (a :: k).
(Ord k, Ord (f a)) =>
MapF k f a -> MapF k f a -> Bool
<= :: MapF k f a -> MapF k f a -> Bool
$c<= :: forall k k (f :: k -> *) (a :: k).
(Ord k, Ord (f a)) =>
MapF k f a -> MapF k f a -> Bool
< :: MapF k f a -> MapF k f a -> Bool
$c< :: forall k k (f :: k -> *) (a :: k).
(Ord k, Ord (f a)) =>
MapF k f a -> MapF k f a -> Bool
compare :: MapF k f a -> MapF k f a -> Ordering
$ccompare :: forall k k (f :: k -> *) (a :: k).
(Ord k, Ord (f a)) =>
MapF k f a -> MapF k f a -> Ordering
Ord, forall a b. a -> MapF k f b -> MapF k f a
forall a b. (a -> b) -> MapF k f a -> MapF k f b
forall k (f :: * -> *) a b.
Functor f =>
a -> MapF k f b -> MapF k f a
forall k (f :: * -> *) a b.
Functor f =>
(a -> b) -> MapF k f a -> MapF k f b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> MapF k f b -> MapF k f a
$c<$ :: forall k (f :: * -> *) a b.
Functor f =>
a -> MapF k f b -> MapF k f a
fmap :: forall a b. (a -> b) -> MapF k f a -> MapF k f b
$cfmap :: forall k (f :: * -> *) a b.
Functor f =>
(a -> b) -> MapF k f a -> MapF k f b
Functor, forall a. MapF k f a -> Bool
forall m a. Monoid m => (a -> m) -> MapF k f a -> m
forall a b. (a -> b -> b) -> b -> MapF k f a -> b
forall k (f :: * -> *) a.
(Foldable f, Eq a) =>
a -> MapF k f a -> Bool
forall k (f :: * -> *) a. (Foldable f, Num a) => MapF k f a -> a
forall k (f :: * -> *) a. (Foldable f, Ord a) => MapF k f a -> a
forall k (f :: * -> *) m. (Foldable f, Monoid m) => MapF k f m -> m
forall k (f :: * -> *) a. Foldable f => MapF k f a -> Bool
forall k (f :: * -> *) a. Foldable f => MapF k f a -> Int
forall k (f :: * -> *) a. Foldable f => MapF k f a -> [a]
forall k (f :: * -> *) a.
Foldable f =>
(a -> a -> a) -> MapF k f a -> a
forall k (f :: * -> *) m a.
(Foldable f, Monoid m) =>
(a -> m) -> MapF k f a -> m
forall k (f :: * -> *) b a.
Foldable f =>
(b -> a -> b) -> b -> MapF k f a -> b
forall k (f :: * -> *) a b.
Foldable f =>
(a -> b -> b) -> b -> MapF k f a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: forall a. Num a => MapF k f a -> a
$cproduct :: forall k (f :: * -> *) a. (Foldable f, Num a) => MapF k f a -> a
sum :: forall a. Num a => MapF k f a -> a
$csum :: forall k (f :: * -> *) a. (Foldable f, Num a) => MapF k f a -> a
minimum :: forall a. Ord a => MapF k f a -> a
$cminimum :: forall k (f :: * -> *) a. (Foldable f, Ord a) => MapF k f a -> a
maximum :: forall a. Ord a => MapF k f a -> a
$cmaximum :: forall k (f :: * -> *) a. (Foldable f, Ord a) => MapF k f a -> a
elem :: forall a. Eq a => a -> MapF k f a -> Bool
$celem :: forall k (f :: * -> *) a.
(Foldable f, Eq a) =>
a -> MapF k f a -> Bool
length :: forall a. MapF k f a -> Int
$clength :: forall k (f :: * -> *) a. Foldable f => MapF k f a -> Int
null :: forall a. MapF k f a -> Bool
$cnull :: forall k (f :: * -> *) a. Foldable f => MapF k f a -> Bool
toList :: forall a. MapF k f a -> [a]
$ctoList :: forall k (f :: * -> *) a. Foldable f => MapF k f a -> [a]
foldl1 :: forall a. (a -> a -> a) -> MapF k f a -> a
$cfoldl1 :: forall k (f :: * -> *) a.
Foldable f =>
(a -> a -> a) -> MapF k f a -> a
foldr1 :: forall a. (a -> a -> a) -> MapF k f a -> a
$cfoldr1 :: forall k (f :: * -> *) a.
Foldable f =>
(a -> a -> a) -> MapF k f a -> a
foldl' :: forall b a. (b -> a -> b) -> b -> MapF k f a -> b
$cfoldl' :: forall k (f :: * -> *) b a.
Foldable f =>
(b -> a -> b) -> b -> MapF k f a -> b
foldl :: forall b a. (b -> a -> b) -> b -> MapF k f a -> b
$cfoldl :: forall k (f :: * -> *) b a.
Foldable f =>
(b -> a -> b) -> b -> MapF k f a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> MapF k f a -> b
$cfoldr' :: forall k (f :: * -> *) a b.
Foldable f =>
(a -> b -> b) -> b -> MapF k f a -> b
foldr :: forall a b. (a -> b -> b) -> b -> MapF k f a -> b
$cfoldr :: forall k (f :: * -> *) a b.
Foldable f =>
(a -> b -> b) -> b -> MapF k f a -> b
foldMap' :: forall m a. Monoid m => (a -> m) -> MapF k f a -> m
$cfoldMap' :: forall k (f :: * -> *) m a.
(Foldable f, Monoid m) =>
(a -> m) -> MapF k f a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> MapF k f a -> m
$cfoldMap :: forall k (f :: * -> *) m a.
(Foldable f, Monoid m) =>
(a -> m) -> MapF k f a -> m
fold :: forall m. Monoid m => MapF k f m -> m
$cfold :: forall k (f :: * -> *) m. (Foldable f, Monoid m) => MapF k f m -> m
Foldable, forall {k} {f :: * -> *}. Traversable f => Functor (MapF k f)
forall {k} {f :: * -> *}. Traversable f => Foldable (MapF k f)
forall k (f :: * -> *) (m :: * -> *) a.
(Traversable f, Monad m) =>
MapF k f (m a) -> m (MapF k f a)
forall k (f :: * -> *) (f :: * -> *) a.
(Traversable f, Applicative f) =>
MapF k f (f a) -> f (MapF k f a)
forall k (f :: * -> *) (m :: * -> *) a b.
(Traversable f, Monad m) =>
(a -> m b) -> MapF k f a -> m (MapF k f b)
forall k (f :: * -> *) (f :: * -> *) a b.
(Traversable f, Applicative f) =>
(a -> f b) -> MapF k f a -> f (MapF k f b)
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> MapF k f a -> f (MapF k f b)
sequence :: forall (m :: * -> *) a. Monad m => MapF k f (m a) -> m (MapF k f a)
$csequence :: forall k (f :: * -> *) (m :: * -> *) a.
(Traversable f, Monad m) =>
MapF k f (m a) -> m (MapF k f a)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> MapF k f a -> m (MapF k f b)
$cmapM :: forall k (f :: * -> *) (m :: * -> *) a b.
(Traversable f, Monad m) =>
(a -> m b) -> MapF k f a -> m (MapF k f b)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
MapF k f (f a) -> f (MapF k f a)
$csequenceA :: forall k (f :: * -> *) (f :: * -> *) a.
(Traversable f, Applicative f) =>
MapF k f (f a) -> f (MapF k f a)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> MapF k f a -> f (MapF k f b)
$ctraverse :: forall k (f :: * -> *) (f :: * -> *) a b.
(Traversable f, Applicative f) =>
(a -> f b) -> MapF k f a -> f (MapF k f b)
Traversable, Typeable, forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall k k (f :: k -> *) (a :: k) x.
Rep (MapF k f a) x -> MapF k f a
forall k k (f :: k -> *) (a :: k) x.
MapF k f a -> Rep (MapF k f a) x
$cto :: forall k k (f :: k -> *) (a :: k) x.
Rep (MapF k f a) x -> MapF k f a
$cfrom :: forall k k (f :: k -> *) (a :: k) x.
MapF k f a -> Rep (MapF k f a) x
Generic, MapF k f a -> DataType
MapF k f a -> Constr
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall {k} {k} {f :: k -> *} {a :: k}.
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k) =>
Typeable (MapF k f a)
forall k k (f :: k -> *) (a :: k).
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k) =>
MapF k f a -> DataType
forall k k (f :: k -> *) (a :: k).
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k) =>
MapF k f a -> Constr
forall k k (f :: k -> *) (a :: k).
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k) =>
(forall b. Data b => b -> b) -> MapF k f a -> MapF k f a
forall k k (f :: k -> *) (a :: k) u.
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k) =>
Int -> (forall d. Data d => d -> u) -> MapF k f a -> u
forall k k (f :: k -> *) (a :: k) u.
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k) =>
(forall d. Data d => d -> u) -> MapF k f a -> [u]
forall k k (f :: k -> *) (a :: k) r r'.
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> MapF k f a -> r
forall k k (f :: k -> *) (a :: k) r r'.
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> MapF k f a -> r
forall k k (f :: k -> *) (a :: k) (m :: * -> *).
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k,
 Monad m) =>
(forall d. Data d => d -> m d) -> MapF k f a -> m (MapF k f a)
forall k k (f :: k -> *) (a :: k) (m :: * -> *).
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k,
 MonadPlus m) =>
(forall d. Data d => d -> m d) -> MapF k f a -> m (MapF k f a)
forall k k (f :: k -> *) (a :: k) (c :: * -> *).
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (MapF k f a)
forall k k (f :: k -> *) (a :: k) (c :: * -> *).
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> MapF k f a -> c (MapF k f a)
forall k k (f :: k -> *) (a :: k) (t :: * -> *) (c :: * -> *).
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k,
 Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (MapF k f a))
forall k k (f :: k -> *) (a :: k) (t :: * -> * -> *) (c :: * -> *).
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k,
 Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (MapF k f a))
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (MapF k f a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> MapF k f a -> c (MapF k f a)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> MapF k f a -> m (MapF k f a)
$cgmapMo :: forall k k (f :: k -> *) (a :: k) (m :: * -> *).
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k,
 MonadPlus m) =>
(forall d. Data d => d -> m d) -> MapF k f a -> m (MapF k f a)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> MapF k f a -> m (MapF k f a)
$cgmapMp :: forall k k (f :: k -> *) (a :: k) (m :: * -> *).
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k,
 MonadPlus m) =>
(forall d. Data d => d -> m d) -> MapF k f a -> m (MapF k f a)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> MapF k f a -> m (MapF k f a)
$cgmapM :: forall k k (f :: k -> *) (a :: k) (m :: * -> *).
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k,
 Monad m) =>
(forall d. Data d => d -> m d) -> MapF k f a -> m (MapF k f a)
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> MapF k f a -> u
$cgmapQi :: forall k k (f :: k -> *) (a :: k) u.
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k) =>
Int -> (forall d. Data d => d -> u) -> MapF k f a -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> MapF k f a -> [u]
$cgmapQ :: forall k k (f :: k -> *) (a :: k) u.
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k) =>
(forall d. Data d => d -> u) -> MapF k f a -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> MapF k f a -> r
$cgmapQr :: forall k k (f :: k -> *) (a :: k) r r'.
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> MapF k f a -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> MapF k f a -> r
$cgmapQl :: forall k k (f :: k -> *) (a :: k) r r'.
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> MapF k f a -> r
gmapT :: (forall b. Data b => b -> b) -> MapF k f a -> MapF k f a
$cgmapT :: forall k k (f :: k -> *) (a :: k).
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k) =>
(forall b. Data b => b -> b) -> MapF k f a -> MapF k f a
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (MapF k f a))
$cdataCast2 :: forall k k (f :: k -> *) (a :: k) (t :: * -> * -> *) (c :: * -> *).
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k,
 Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (MapF k f a))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (MapF k f a))
$cdataCast1 :: forall k k (f :: k -> *) (a :: k) (t :: * -> *) (c :: * -> *).
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k,
 Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (MapF k f a))
dataTypeOf :: MapF k f a -> DataType
$cdataTypeOf :: forall k k (f :: k -> *) (a :: k).
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k) =>
MapF k f a -> DataType
toConstr :: MapF k f a -> Constr
$ctoConstr :: forall k k (f :: k -> *) (a :: k).
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k) =>
MapF k f a -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (MapF k f a)
$cgunfold :: forall k k (f :: k -> *) (a :: k) (c :: * -> *).
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (MapF k f a)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> MapF k f a -> c (MapF k f a)
$cgfoldl :: forall k k (f :: k -> *) (a :: k) (c :: * -> *).
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> MapF k f a -> c (MapF k f a)
Data)

deriveShow1 ''MapF
deriveEq1 ''MapF
deriveOrd1 ''MapF

instance (Ord k, Read k, Read1 f) => Read1 (MapF k f) where
    liftReadsPrec :: forall a.
(Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (MapF k f a)
liftReadsPrec = $(makeLiftReadsPrec ''MapF)

-- | A union, combining matching keys with '<!>'.
instance (Ord k, Alt f) => Semigroup (MapF k f a) where
    MapF Map k (f a)
xs <> :: MapF k f a -> MapF k f a -> MapF k f a
<> MapF Map k (f a)
ys = forall {k} k (f :: k -> *) (a :: k). Map k (f a) -> MapF k f a
MapF forall a b. (a -> b) -> a -> b
$ forall k a. Ord k => (a -> a -> a) -> Map k a -> Map k a -> Map k a
M.unionWith forall (f :: * -> *) a. Alt f => f a -> f a -> f a
(<!>) Map k (f a)
xs Map k (f a)
ys

instance (Ord k, Alt f) => Monoid (MapF k f a) where
    mempty :: MapF k f a
mempty = forall {k} k (f :: k -> *) (a :: k). Map k (f a) -> MapF k f a
MapF forall k a. Map k a
M.empty

-- | Left-biased union
instance (Functor f, Ord k) => Alt (MapF k f) where
    MapF Map k (f a)
xs <!> :: forall a. MapF k f a -> MapF k f a -> MapF k f a
<!> MapF Map k (f a)
ys = forall {k} k (f :: k -> *) (a :: k). Map k (f a) -> MapF k f a
MapF forall a b. (a -> b) -> a -> b
$ forall k a. Ord k => Map k a -> Map k a -> Map k a
M.union Map k (f a)
xs Map k (f a)
ys

instance (Functor f, Ord k) => Plus (MapF k f) where
    zero :: forall a. MapF k f a
zero = forall {k} k (f :: k -> *) (a :: k). Map k (f a) -> MapF k f a
MapF forall k a. Map k a
M.empty

instance (Monoid k, Pointed f) => Pointed (MapF k f) where
    point :: forall a. a -> MapF k f a
point = forall {k} k (f :: k -> *) (a :: k). Map k (f a) -> MapF k f a
MapF forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. k -> a -> Map k a
M.singleton forall a. Monoid a => a
mempty forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> *) a. Pointed p => a -> p a
point

-- | A non-empty map of @f a@s, indexed by keys of type @k@.  It can be
-- useful for represeting a product of many different values of type @f a@,
-- each "at" a different @k@ location, where you need to have at least one
-- @f a@ at all times.
--
-- Can be considered a combination of 'Control.Comonad.Trans.Env.EnvT' and
-- 'NonEmptyF', in a way --- an @'NEMapF' k f a@ is like a @'NonEmptyF'
-- ('Control.Comonad.Trans.Env.EnvT' k f) a@ with unique (and ordered)
-- keys.
--
-- See 'MapF' for some use cases.
newtype NEMapF k f a = NEMapF { forall {k} k (f :: k -> *) (a :: k). NEMapF k f a -> NEMap k (f a)
runNEMapF :: NEM.NEMap k (f a) }
  deriving (Int -> NEMapF k f a -> ShowS
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall k k (f :: k -> *) (a :: k).
(Show k, Show (f a)) =>
Int -> NEMapF k f a -> ShowS
forall k k (f :: k -> *) (a :: k).
(Show k, Show (f a)) =>
[NEMapF k f a] -> ShowS
forall k k (f :: k -> *) (a :: k).
(Show k, Show (f a)) =>
NEMapF k f a -> String
showList :: [NEMapF k f a] -> ShowS
$cshowList :: forall k k (f :: k -> *) (a :: k).
(Show k, Show (f a)) =>
[NEMapF k f a] -> ShowS
show :: NEMapF k f a -> String
$cshow :: forall k k (f :: k -> *) (a :: k).
(Show k, Show (f a)) =>
NEMapF k f a -> String
showsPrec :: Int -> NEMapF k f a -> ShowS
$cshowsPrec :: forall k k (f :: k -> *) (a :: k).
(Show k, Show (f a)) =>
Int -> NEMapF k f a -> ShowS
Show, ReadPrec [NEMapF k f a]
ReadPrec (NEMapF k f a)
ReadS [NEMapF k f a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
forall k k (f :: k -> *) (a :: k).
(Ord k, Read k, Read (f a)) =>
ReadPrec [NEMapF k f a]
forall k k (f :: k -> *) (a :: k).
(Ord k, Read k, Read (f a)) =>
ReadPrec (NEMapF k f a)
forall k k (f :: k -> *) (a :: k).
(Ord k, Read k, Read (f a)) =>
Int -> ReadS (NEMapF k f a)
forall k k (f :: k -> *) (a :: k).
(Ord k, Read k, Read (f a)) =>
ReadS [NEMapF k f a]
readListPrec :: ReadPrec [NEMapF k f a]
$creadListPrec :: forall k k (f :: k -> *) (a :: k).
(Ord k, Read k, Read (f a)) =>
ReadPrec [NEMapF k f a]
readPrec :: ReadPrec (NEMapF k f a)
$creadPrec :: forall k k (f :: k -> *) (a :: k).
(Ord k, Read k, Read (f a)) =>
ReadPrec (NEMapF k f a)
readList :: ReadS [NEMapF k f a]
$creadList :: forall k k (f :: k -> *) (a :: k).
(Ord k, Read k, Read (f a)) =>
ReadS [NEMapF k f a]
readsPrec :: Int -> ReadS (NEMapF k f a)
$creadsPrec :: forall k k (f :: k -> *) (a :: k).
(Ord k, Read k, Read (f a)) =>
Int -> ReadS (NEMapF k f a)
Read, NEMapF k f a -> NEMapF k f a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall k k (f :: k -> *) (a :: k).
(Eq k, Eq (f a)) =>
NEMapF k f a -> NEMapF k f a -> Bool
/= :: NEMapF k f a -> NEMapF k f a -> Bool
$c/= :: forall k k (f :: k -> *) (a :: k).
(Eq k, Eq (f a)) =>
NEMapF k f a -> NEMapF k f a -> Bool
== :: NEMapF k f a -> NEMapF k f a -> Bool
$c== :: forall k k (f :: k -> *) (a :: k).
(Eq k, Eq (f a)) =>
NEMapF k f a -> NEMapF k f a -> Bool
Eq, NEMapF k f a -> NEMapF k f a -> Bool
NEMapF k f a -> NEMapF k f a -> Ordering
NEMapF k f a -> NEMapF k f a -> NEMapF k f a
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall {k} {k} {f :: k -> *} {a :: k}.
(Ord k, Ord (f a)) =>
Eq (NEMapF k f a)
forall k k (f :: k -> *) (a :: k).
(Ord k, Ord (f a)) =>
NEMapF k f a -> NEMapF k f a -> Bool
forall k k (f :: k -> *) (a :: k).
(Ord k, Ord (f a)) =>
NEMapF k f a -> NEMapF k f a -> Ordering
forall k k (f :: k -> *) (a :: k).
(Ord k, Ord (f a)) =>
NEMapF k f a -> NEMapF k f a -> NEMapF k f a
min :: NEMapF k f a -> NEMapF k f a -> NEMapF k f a
$cmin :: forall k k (f :: k -> *) (a :: k).
(Ord k, Ord (f a)) =>
NEMapF k f a -> NEMapF k f a -> NEMapF k f a
max :: NEMapF k f a -> NEMapF k f a -> NEMapF k f a
$cmax :: forall k k (f :: k -> *) (a :: k).
(Ord k, Ord (f a)) =>
NEMapF k f a -> NEMapF k f a -> NEMapF k f a
>= :: NEMapF k f a -> NEMapF k f a -> Bool
$c>= :: forall k k (f :: k -> *) (a :: k).
(Ord k, Ord (f a)) =>
NEMapF k f a -> NEMapF k f a -> Bool
> :: NEMapF k f a -> NEMapF k f a -> Bool
$c> :: forall k k (f :: k -> *) (a :: k).
(Ord k, Ord (f a)) =>
NEMapF k f a -> NEMapF k f a -> Bool
<= :: NEMapF k f a -> NEMapF k f a -> Bool
$c<= :: forall k k (f :: k -> *) (a :: k).
(Ord k, Ord (f a)) =>
NEMapF k f a -> NEMapF k f a -> Bool
< :: NEMapF k f a -> NEMapF k f a -> Bool
$c< :: forall k k (f :: k -> *) (a :: k).
(Ord k, Ord (f a)) =>
NEMapF k f a -> NEMapF k f a -> Bool
compare :: NEMapF k f a -> NEMapF k f a -> Ordering
$ccompare :: forall k k (f :: k -> *) (a :: k).
(Ord k, Ord (f a)) =>
NEMapF k f a -> NEMapF k f a -> Ordering
Ord, forall a b. a -> NEMapF k f b -> NEMapF k f a
forall a b. (a -> b) -> NEMapF k f a -> NEMapF k f b
forall k (f :: * -> *) a b.
Functor f =>
a -> NEMapF k f b -> NEMapF k f a
forall k (f :: * -> *) a b.
Functor f =>
(a -> b) -> NEMapF k f a -> NEMapF k f b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> NEMapF k f b -> NEMapF k f a
$c<$ :: forall k (f :: * -> *) a b.
Functor f =>
a -> NEMapF k f b -> NEMapF k f a
fmap :: forall a b. (a -> b) -> NEMapF k f a -> NEMapF k f b
$cfmap :: forall k (f :: * -> *) a b.
Functor f =>
(a -> b) -> NEMapF k f a -> NEMapF k f b
Functor, forall a. NEMapF k f a -> Bool
forall m a. Monoid m => (a -> m) -> NEMapF k f a -> m
forall a b. (a -> b -> b) -> b -> NEMapF k f a -> b
forall k (f :: * -> *) a.
(Foldable f, Eq a) =>
a -> NEMapF k f a -> Bool
forall k (f :: * -> *) a. (Foldable f, Num a) => NEMapF k f a -> a
forall k (f :: * -> *) a. (Foldable f, Ord a) => NEMapF k f a -> a
forall k (f :: * -> *) m.
(Foldable f, Monoid m) =>
NEMapF k f m -> m
forall k (f :: * -> *) a. Foldable f => NEMapF k f a -> Bool
forall k (f :: * -> *) a. Foldable f => NEMapF k f a -> Int
forall k (f :: * -> *) a. Foldable f => NEMapF k f a -> [a]
forall k (f :: * -> *) a.
Foldable f =>
(a -> a -> a) -> NEMapF k f a -> a
forall k (f :: * -> *) m a.
(Foldable f, Monoid m) =>
(a -> m) -> NEMapF k f a -> m
forall k (f :: * -> *) b a.
Foldable f =>
(b -> a -> b) -> b -> NEMapF k f a -> b
forall k (f :: * -> *) a b.
Foldable f =>
(a -> b -> b) -> b -> NEMapF k f a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: forall a. Num a => NEMapF k f a -> a
$cproduct :: forall k (f :: * -> *) a. (Foldable f, Num a) => NEMapF k f a -> a
sum :: forall a. Num a => NEMapF k f a -> a
$csum :: forall k (f :: * -> *) a. (Foldable f, Num a) => NEMapF k f a -> a
minimum :: forall a. Ord a => NEMapF k f a -> a
$cminimum :: forall k (f :: * -> *) a. (Foldable f, Ord a) => NEMapF k f a -> a
maximum :: forall a. Ord a => NEMapF k f a -> a
$cmaximum :: forall k (f :: * -> *) a. (Foldable f, Ord a) => NEMapF k f a -> a
elem :: forall a. Eq a => a -> NEMapF k f a -> Bool
$celem :: forall k (f :: * -> *) a.
(Foldable f, Eq a) =>
a -> NEMapF k f a -> Bool
length :: forall a. NEMapF k f a -> Int
$clength :: forall k (f :: * -> *) a. Foldable f => NEMapF k f a -> Int
null :: forall a. NEMapF k f a -> Bool
$cnull :: forall k (f :: * -> *) a. Foldable f => NEMapF k f a -> Bool
toList :: forall a. NEMapF k f a -> [a]
$ctoList :: forall k (f :: * -> *) a. Foldable f => NEMapF k f a -> [a]
foldl1 :: forall a. (a -> a -> a) -> NEMapF k f a -> a
$cfoldl1 :: forall k (f :: * -> *) a.
Foldable f =>
(a -> a -> a) -> NEMapF k f a -> a
foldr1 :: forall a. (a -> a -> a) -> NEMapF k f a -> a
$cfoldr1 :: forall k (f :: * -> *) a.
Foldable f =>
(a -> a -> a) -> NEMapF k f a -> a
foldl' :: forall b a. (b -> a -> b) -> b -> NEMapF k f a -> b
$cfoldl' :: forall k (f :: * -> *) b a.
Foldable f =>
(b -> a -> b) -> b -> NEMapF k f a -> b
foldl :: forall b a. (b -> a -> b) -> b -> NEMapF k f a -> b
$cfoldl :: forall k (f :: * -> *) b a.
Foldable f =>
(b -> a -> b) -> b -> NEMapF k f a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> NEMapF k f a -> b
$cfoldr' :: forall k (f :: * -> *) a b.
Foldable f =>
(a -> b -> b) -> b -> NEMapF k f a -> b
foldr :: forall a b. (a -> b -> b) -> b -> NEMapF k f a -> b
$cfoldr :: forall k (f :: * -> *) a b.
Foldable f =>
(a -> b -> b) -> b -> NEMapF k f a -> b
foldMap' :: forall m a. Monoid m => (a -> m) -> NEMapF k f a -> m
$cfoldMap' :: forall k (f :: * -> *) m a.
(Foldable f, Monoid m) =>
(a -> m) -> NEMapF k f a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> NEMapF k f a -> m
$cfoldMap :: forall k (f :: * -> *) m a.
(Foldable f, Monoid m) =>
(a -> m) -> NEMapF k f a -> m
fold :: forall m. Monoid m => NEMapF k f m -> m
$cfold :: forall k (f :: * -> *) m.
(Foldable f, Monoid m) =>
NEMapF k f m -> m
Foldable, forall {k} {f :: * -> *}. Traversable f => Functor (NEMapF k f)
forall {k} {f :: * -> *}. Traversable f => Foldable (NEMapF k f)
forall k (f :: * -> *) (m :: * -> *) a.
(Traversable f, Monad m) =>
NEMapF k f (m a) -> m (NEMapF k f a)
forall k (f :: * -> *) (f :: * -> *) a.
(Traversable f, Applicative f) =>
NEMapF k f (f a) -> f (NEMapF k f a)
forall k (f :: * -> *) (m :: * -> *) a b.
(Traversable f, Monad m) =>
(a -> m b) -> NEMapF k f a -> m (NEMapF k f b)
forall k (f :: * -> *) (f :: * -> *) a b.
(Traversable f, Applicative f) =>
(a -> f b) -> NEMapF k f a -> f (NEMapF k f b)
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> NEMapF k f a -> f (NEMapF k f b)
sequence :: forall (m :: * -> *) a.
Monad m =>
NEMapF k f (m a) -> m (NEMapF k f a)
$csequence :: forall k (f :: * -> *) (m :: * -> *) a.
(Traversable f, Monad m) =>
NEMapF k f (m a) -> m (NEMapF k f a)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> NEMapF k f a -> m (NEMapF k f b)
$cmapM :: forall k (f :: * -> *) (m :: * -> *) a b.
(Traversable f, Monad m) =>
(a -> m b) -> NEMapF k f a -> m (NEMapF k f b)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
NEMapF k f (f a) -> f (NEMapF k f a)
$csequenceA :: forall k (f :: * -> *) (f :: * -> *) a.
(Traversable f, Applicative f) =>
NEMapF k f (f a) -> f (NEMapF k f a)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> NEMapF k f a -> f (NEMapF k f b)
$ctraverse :: forall k (f :: * -> *) (f :: * -> *) a b.
(Traversable f, Applicative f) =>
(a -> f b) -> NEMapF k f a -> f (NEMapF k f b)
Traversable, Typeable, forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall k k (f :: k -> *) (a :: k) x.
Rep (NEMapF k f a) x -> NEMapF k f a
forall k k (f :: k -> *) (a :: k) x.
NEMapF k f a -> Rep (NEMapF k f a) x
$cto :: forall k k (f :: k -> *) (a :: k) x.
Rep (NEMapF k f a) x -> NEMapF k f a
$cfrom :: forall k k (f :: k -> *) (a :: k) x.
NEMapF k f a -> Rep (NEMapF k f a) x
Generic, NEMapF k f a -> DataType
NEMapF k f a -> Constr
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall {k} {k} {f :: k -> *} {a :: k}.
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k) =>
Typeable (NEMapF k f a)
forall k k (f :: k -> *) (a :: k).
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k) =>
NEMapF k f a -> DataType
forall k k (f :: k -> *) (a :: k).
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k) =>
NEMapF k f a -> Constr
forall k k (f :: k -> *) (a :: k).
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k) =>
(forall b. Data b => b -> b) -> NEMapF k f a -> NEMapF k f a
forall k k (f :: k -> *) (a :: k) u.
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k) =>
Int -> (forall d. Data d => d -> u) -> NEMapF k f a -> u
forall k k (f :: k -> *) (a :: k) u.
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k) =>
(forall d. Data d => d -> u) -> NEMapF k f a -> [u]
forall k k (f :: k -> *) (a :: k) r r'.
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NEMapF k f a -> r
forall k k (f :: k -> *) (a :: k) r r'.
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NEMapF k f a -> r
forall k k (f :: k -> *) (a :: k) (m :: * -> *).
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k,
 Monad m) =>
(forall d. Data d => d -> m d) -> NEMapF k f a -> m (NEMapF k f a)
forall k k (f :: k -> *) (a :: k) (m :: * -> *).
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k,
 MonadPlus m) =>
(forall d. Data d => d -> m d) -> NEMapF k f a -> m (NEMapF k f a)
forall k k (f :: k -> *) (a :: k) (c :: * -> *).
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (NEMapF k f a)
forall k k (f :: k -> *) (a :: k) (c :: * -> *).
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NEMapF k f a -> c (NEMapF k f a)
forall k k (f :: k -> *) (a :: k) (t :: * -> *) (c :: * -> *).
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k,
 Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (NEMapF k f a))
forall k k (f :: k -> *) (a :: k) (t :: * -> * -> *) (c :: * -> *).
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k,
 Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (NEMapF k f a))
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (NEMapF k f a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NEMapF k f a -> c (NEMapF k f a)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NEMapF k f a -> m (NEMapF k f a)
$cgmapMo :: forall k k (f :: k -> *) (a :: k) (m :: * -> *).
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k,
 MonadPlus m) =>
(forall d. Data d => d -> m d) -> NEMapF k f a -> m (NEMapF k f a)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NEMapF k f a -> m (NEMapF k f a)
$cgmapMp :: forall k k (f :: k -> *) (a :: k) (m :: * -> *).
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k,
 MonadPlus m) =>
(forall d. Data d => d -> m d) -> NEMapF k f a -> m (NEMapF k f a)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> NEMapF k f a -> m (NEMapF k f a)
$cgmapM :: forall k k (f :: k -> *) (a :: k) (m :: * -> *).
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k,
 Monad m) =>
(forall d. Data d => d -> m d) -> NEMapF k f a -> m (NEMapF k f a)
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> NEMapF k f a -> u
$cgmapQi :: forall k k (f :: k -> *) (a :: k) u.
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k) =>
Int -> (forall d. Data d => d -> u) -> NEMapF k f a -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> NEMapF k f a -> [u]
$cgmapQ :: forall k k (f :: k -> *) (a :: k) u.
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k) =>
(forall d. Data d => d -> u) -> NEMapF k f a -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NEMapF k f a -> r
$cgmapQr :: forall k k (f :: k -> *) (a :: k) r r'.
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NEMapF k f a -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NEMapF k f a -> r
$cgmapQl :: forall k k (f :: k -> *) (a :: k) r r'.
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NEMapF k f a -> r
gmapT :: (forall b. Data b => b -> b) -> NEMapF k f a -> NEMapF k f a
$cgmapT :: forall k k (f :: k -> *) (a :: k).
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k) =>
(forall b. Data b => b -> b) -> NEMapF k f a -> NEMapF k f a
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (NEMapF k f a))
$cdataCast2 :: forall k k (f :: k -> *) (a :: k) (t :: * -> * -> *) (c :: * -> *).
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k,
 Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (NEMapF k f a))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (NEMapF k f a))
$cdataCast1 :: forall k k (f :: k -> *) (a :: k) (t :: * -> *) (c :: * -> *).
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k,
 Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (NEMapF k f a))
dataTypeOf :: NEMapF k f a -> DataType
$cdataTypeOf :: forall k k (f :: k -> *) (a :: k).
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k) =>
NEMapF k f a -> DataType
toConstr :: NEMapF k f a -> Constr
$ctoConstr :: forall k k (f :: k -> *) (a :: k).
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k) =>
NEMapF k f a -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (NEMapF k f a)
$cgunfold :: forall k k (f :: k -> *) (a :: k) (c :: * -> *).
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (NEMapF k f a)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NEMapF k f a -> c (NEMapF k f a)
$cgfoldl :: forall k k (f :: k -> *) (a :: k) (c :: * -> *).
(Typeable a, Typeable f, Typeable k, Data k, Data (f a), Ord k) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NEMapF k f a -> c (NEMapF k f a)
Data)

deriveShow1 ''NEMapF
deriveEq1 ''NEMapF
deriveOrd1 ''NEMapF

instance (Ord k, Read k, Read1 f) => Read1 (NEMapF k f) where
    liftReadsPrec :: forall a.
(Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (NEMapF k f a)
liftReadsPrec = $(makeLiftReadsPrec ''NEMapF)

instance Foldable1 f => Foldable1 (NEMapF k f) where
    fold1 :: forall m. Semigroup m => NEMapF k f m -> m
fold1      = forall (t :: * -> *) m a.
(Foldable1 t, Semigroup m) =>
(a -> m) -> t a -> m
foldMap1 forall (t :: * -> *) m. (Foldable1 t, Semigroup m) => t m -> m
fold1 forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k} k (f :: k -> *) (a :: k). NEMapF k f a -> NEMap k (f a)
runNEMapF
    foldMap1 :: forall m a. Semigroup m => (a -> m) -> NEMapF k f a -> m
foldMap1 a -> m
f = (forall (t :: * -> *) m a.
(Foldable1 t, Semigroup m) =>
(a -> m) -> t a -> m
foldMap1 forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) m a.
(Foldable1 t, Semigroup m) =>
(a -> m) -> t a -> m
foldMap1) a -> m
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k} k (f :: k -> *) (a :: k). NEMapF k f a -> NEMap k (f a)
runNEMapF
    toNonEmpty :: forall a. NEMapF k f a -> NonEmpty a
toNonEmpty = forall (t :: * -> *) m a.
(Foldable1 t, Semigroup m) =>
(a -> m) -> t a -> m
foldMap1 forall (t :: * -> *) a. Foldable1 t => t a -> NonEmpty a
toNonEmpty forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k} k (f :: k -> *) (a :: k). NEMapF k f a -> NEMap k (f a)
runNEMapF

instance Traversable1 f => Traversable1 (NEMapF k f) where
    traverse1 :: forall (f :: * -> *) a b.
Apply f =>
(a -> f b) -> NEMapF k f a -> f (NEMapF k f b)
traverse1 a -> f b
f = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall {k} k (f :: k -> *) (a :: k). NEMap k (f a) -> NEMapF k f a
NEMapF forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall (t :: * -> *) (f :: * -> *) a b.
(Traversable1 t, Apply f) =>
(a -> f b) -> t a -> f (t b)
traverse1 forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) (f :: * -> *) a b.
(Traversable1 t, Apply f) =>
(a -> f b) -> t a -> f (t b)
traverse1) a -> f b
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k} k (f :: k -> *) (a :: k). NEMapF k f a -> NEMap k (f a)
runNEMapF
    sequence1 :: forall (f :: * -> *) b.
Apply f =>
NEMapF k f (f b) -> f (NEMapF k f b)
sequence1   = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall {k} k (f :: k -> *) (a :: k). NEMap k (f a) -> NEMapF k f a
NEMapF forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) (f :: * -> *) a b.
(Traversable1 t, Apply f) =>
(a -> f b) -> t a -> f (t b)
traverse1 forall (t :: * -> *) (f :: * -> *) b.
(Traversable1 t, Apply f) =>
t (f b) -> f (t b)
sequence1 forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k} k (f :: k -> *) (a :: k). NEMapF k f a -> NEMap k (f a)
runNEMapF

-- | A union, combining matching keys with '<!>'.
instance (Ord k, Alt f) => Semigroup (NEMapF k f a) where
    NEMapF NEMap k (f a)
xs <> :: NEMapF k f a -> NEMapF k f a -> NEMapF k f a
<> NEMapF NEMap k (f a)
ys = forall {k} k (f :: k -> *) (a :: k). NEMap k (f a) -> NEMapF k f a
NEMapF forall a b. (a -> b) -> a -> b
$ forall k a.
Ord k =>
(a -> a -> a) -> NEMap k a -> NEMap k a -> NEMap k a
NEM.unionWith forall (f :: * -> *) a. Alt f => f a -> f a -> f a
(<!>) NEMap k (f a)
xs NEMap k (f a)
ys

-- | Left-biased union
instance (Functor f, Ord k) => Alt (NEMapF k f) where
    NEMapF NEMap k (f a)
xs <!> :: forall a. NEMapF k f a -> NEMapF k f a -> NEMapF k f a
<!> NEMapF NEMap k (f a)
ys = forall {k} k (f :: k -> *) (a :: k). NEMap k (f a) -> NEMapF k f a
NEMapF forall a b. (a -> b) -> a -> b
$ forall k a. Ord k => NEMap k a -> NEMap k a -> NEMap k a
NEM.union NEMap k (f a)
xs NEMap k (f a)
ys

instance (Monoid k, Pointed f) => Pointed (NEMapF k f) where
    point :: forall a. a -> NEMapF k f a
point = forall {k} k (f :: k -> *) (a :: k). NEMap k (f a) -> NEMapF k f a
NEMapF forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. k -> a -> NEMap k a
NEM.singleton forall a. Monoid a => a
mempty forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> *) a. Pointed p => a -> p a
point