{-# LANGUAGE CPP #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE PatternGuards #-}
{-# LANGUAGE DeriveFoldable #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE UndecidableInstances #-}
module Data.Fold.Internal
  ( SnocList(..)
  , SnocList1(..)
  , List1(..)
  , Maybe'(..), maybe'
  , Pair'(..)
  , N(..)
  , S(..)
  , Tree(..)
  , Tree1(..)
  , An(..)
  , Box(..)
  , FreeMonoid(..)
  , foldDeRef
  , FreeSemigroup(..)
  , foldDeRef1
  ) where

import Control.Monad.Fix
import Data.Bifunctor
import Data.Bifoldable
import Data.Bitraversable
import Data.Constraint
import Data.Data (Data)
import Data.Kind
import Data.Semigroup hiding (Last, First)
import Data.Functor.Bind
import Data.HashMap.Lazy as HM
import Data.Profunctor.Unsafe
import Data.Proxy (Proxy(Proxy))
import Data.Reflection
import Data.Reify
import Data.Semigroup.Foldable
import Data.Semigroup.Bifoldable
import Data.Semigroup.Bitraversable
import System.IO.Unsafe

-- | Reversed '[]'
data SnocList a = Snoc (SnocList a) a | Nil
  deriving (SnocList a -> SnocList a -> Bool
(SnocList a -> SnocList a -> Bool)
-> (SnocList a -> SnocList a -> Bool) -> Eq (SnocList a)
forall a. Eq a => SnocList a -> SnocList a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SnocList a -> SnocList a -> Bool
$c/= :: forall a. Eq a => SnocList a -> SnocList a -> Bool
== :: SnocList a -> SnocList a -> Bool
$c== :: forall a. Eq a => SnocList a -> SnocList a -> Bool
Eq,Eq (SnocList a)
Eq (SnocList a)
-> (SnocList a -> SnocList a -> Ordering)
-> (SnocList a -> SnocList a -> Bool)
-> (SnocList a -> SnocList a -> Bool)
-> (SnocList a -> SnocList a -> Bool)
-> (SnocList a -> SnocList a -> Bool)
-> (SnocList a -> SnocList a -> SnocList a)
-> (SnocList a -> SnocList a -> SnocList a)
-> Ord (SnocList a)
SnocList a -> SnocList a -> Bool
SnocList a -> SnocList a -> Ordering
SnocList a -> SnocList a -> SnocList 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 a. Ord a => Eq (SnocList a)
forall a. Ord a => SnocList a -> SnocList a -> Bool
forall a. Ord a => SnocList a -> SnocList a -> Ordering
forall a. Ord a => SnocList a -> SnocList a -> SnocList a
min :: SnocList a -> SnocList a -> SnocList a
$cmin :: forall a. Ord a => SnocList a -> SnocList a -> SnocList a
max :: SnocList a -> SnocList a -> SnocList a
$cmax :: forall a. Ord a => SnocList a -> SnocList a -> SnocList a
>= :: SnocList a -> SnocList a -> Bool
$c>= :: forall a. Ord a => SnocList a -> SnocList a -> Bool
> :: SnocList a -> SnocList a -> Bool
$c> :: forall a. Ord a => SnocList a -> SnocList a -> Bool
<= :: SnocList a -> SnocList a -> Bool
$c<= :: forall a. Ord a => SnocList a -> SnocList a -> Bool
< :: SnocList a -> SnocList a -> Bool
$c< :: forall a. Ord a => SnocList a -> SnocList a -> Bool
compare :: SnocList a -> SnocList a -> Ordering
$ccompare :: forall a. Ord a => SnocList a -> SnocList a -> Ordering
$cp1Ord :: forall a. Ord a => Eq (SnocList a)
Ord,Int -> SnocList a -> ShowS
[SnocList a] -> ShowS
SnocList a -> String
(Int -> SnocList a -> ShowS)
-> (SnocList a -> String)
-> ([SnocList a] -> ShowS)
-> Show (SnocList a)
forall a. Show a => Int -> SnocList a -> ShowS
forall a. Show a => [SnocList a] -> ShowS
forall a. Show a => SnocList a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SnocList a] -> ShowS
$cshowList :: forall a. Show a => [SnocList a] -> ShowS
show :: SnocList a -> String
$cshow :: forall a. Show a => SnocList a -> String
showsPrec :: Int -> SnocList a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> SnocList a -> ShowS
Show,ReadPrec [SnocList a]
ReadPrec (SnocList a)
Int -> ReadS (SnocList a)
ReadS [SnocList a]
(Int -> ReadS (SnocList a))
-> ReadS [SnocList a]
-> ReadPrec (SnocList a)
-> ReadPrec [SnocList a]
-> Read (SnocList a)
forall a. Read a => ReadPrec [SnocList a]
forall a. Read a => ReadPrec (SnocList a)
forall a. Read a => Int -> ReadS (SnocList a)
forall a. Read a => ReadS [SnocList a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SnocList a]
$creadListPrec :: forall a. Read a => ReadPrec [SnocList a]
readPrec :: ReadPrec (SnocList a)
$creadPrec :: forall a. Read a => ReadPrec (SnocList a)
readList :: ReadS [SnocList a]
$creadList :: forall a. Read a => ReadS [SnocList a]
readsPrec :: Int -> ReadS (SnocList a)
$creadsPrec :: forall a. Read a => Int -> ReadS (SnocList a)
Read,Typeable (SnocList a)
DataType
Constr
Typeable (SnocList a)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> SnocList a -> c (SnocList a))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (SnocList a))
-> (SnocList a -> Constr)
-> (SnocList a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (SnocList a)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (SnocList a)))
-> ((forall b. Data b => b -> b) -> SnocList a -> SnocList a)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> SnocList a -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> SnocList a -> r)
-> (forall u. (forall d. Data d => d -> u) -> SnocList a -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> SnocList a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> SnocList a -> m (SnocList a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> SnocList a -> m (SnocList a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> SnocList a -> m (SnocList a))
-> Data (SnocList a)
SnocList a -> DataType
SnocList a -> Constr
(forall d. Data d => c (t d)) -> Maybe (c (SnocList a))
(forall b. Data b => b -> b) -> SnocList a -> SnocList a
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SnocList a -> c (SnocList a)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (SnocList a)
forall a. Data a => Typeable (SnocList a)
forall a. Data a => SnocList a -> DataType
forall a. Data a => SnocList a -> Constr
forall a.
Data a =>
(forall b. Data b => b -> b) -> SnocList a -> SnocList a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> SnocList a -> u
forall a u.
Data a =>
(forall d. Data d => d -> u) -> SnocList a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> SnocList a -> r
forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> SnocList a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> SnocList a -> m (SnocList a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> SnocList a -> m (SnocList a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (SnocList a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SnocList a -> c (SnocList a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (SnocList a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (SnocList a))
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 u. Int -> (forall d. Data d => d -> u) -> SnocList a -> u
forall u. (forall d. Data d => d -> u) -> SnocList a -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> SnocList a -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> SnocList a -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> SnocList a -> m (SnocList a)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> SnocList a -> m (SnocList a)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (SnocList a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SnocList a -> c (SnocList a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (SnocList a))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (SnocList a))
$cNil :: Constr
$cSnoc :: Constr
$tSnocList :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> SnocList a -> m (SnocList a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> SnocList a -> m (SnocList a)
gmapMp :: (forall d. Data d => d -> m d) -> SnocList a -> m (SnocList a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> SnocList a -> m (SnocList a)
gmapM :: (forall d. Data d => d -> m d) -> SnocList a -> m (SnocList a)
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> SnocList a -> m (SnocList a)
gmapQi :: Int -> (forall d. Data d => d -> u) -> SnocList a -> u
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> SnocList a -> u
gmapQ :: (forall d. Data d => d -> u) -> SnocList a -> [u]
$cgmapQ :: forall a u.
Data a =>
(forall d. Data d => d -> u) -> SnocList a -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> SnocList a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> SnocList a -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> SnocList a -> r
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> SnocList a -> r
gmapT :: (forall b. Data b => b -> b) -> SnocList a -> SnocList a
$cgmapT :: forall a.
Data a =>
(forall b. Data b => b -> b) -> SnocList a -> SnocList a
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (SnocList a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (SnocList a))
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c (SnocList a))
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (SnocList a))
dataTypeOf :: SnocList a -> DataType
$cdataTypeOf :: forall a. Data a => SnocList a -> DataType
toConstr :: SnocList a -> Constr
$ctoConstr :: forall a. Data a => SnocList a -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (SnocList a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (SnocList a)
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SnocList a -> c (SnocList a)
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SnocList a -> c (SnocList a)
$cp1Data :: forall a. Data a => Typeable (SnocList a)
Data)

instance Functor SnocList where
  fmap :: (a -> b) -> SnocList a -> SnocList b
fmap a -> b
f (Snoc SnocList a
xs a
x) = SnocList b -> b -> SnocList b
forall a. SnocList a -> a -> SnocList a
Snoc ((a -> b) -> SnocList a -> SnocList b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f SnocList a
xs) (a -> b
f a
x)
  fmap a -> b
_ SnocList a
Nil = SnocList b
forall a. SnocList a
Nil
  {-# INLINABLE fmap #-}

instance Foldable SnocList where
  foldl :: (b -> a -> b) -> b -> SnocList a -> b
foldl b -> a -> b
f b
z SnocList a
m0 = SnocList a -> b
go SnocList a
m0 where
    go :: SnocList a -> b
go (Snoc SnocList a
xs a
x) = b -> a -> b
f (SnocList a -> b
go SnocList a
xs) a
x
    go SnocList a
Nil = b
z
  {-# INLINE foldl #-}
  foldMap :: (a -> m) -> SnocList a -> m
foldMap a -> m
f (Snoc SnocList a
xs a
x) = (a -> m) -> SnocList a -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap a -> m
f SnocList a
xs m -> m -> m
forall a. Monoid a => a -> a -> a
`mappend` a -> m
f a
x
  foldMap a -> m
_ SnocList a
Nil = m
forall a. Monoid a => a
mempty
  {-# INLINABLE foldMap #-}

instance Traversable SnocList where
  traverse :: (a -> f b) -> SnocList a -> f (SnocList b)
traverse a -> f b
f (Snoc SnocList a
xs a
x) = SnocList b -> b -> SnocList b
forall a. SnocList a -> a -> SnocList a
Snoc (SnocList b -> b -> SnocList b)
-> f (SnocList b) -> f (b -> SnocList b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> f b) -> SnocList a -> f (SnocList b)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse a -> f b
f SnocList a
xs f (b -> SnocList b) -> f b -> f (SnocList b)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> a -> f b
f a
x
  traverse a -> f b
_ SnocList a
Nil = SnocList b -> f (SnocList b)
forall (f :: * -> *) a. Applicative f => a -> f a
pure SnocList b
forall a. SnocList a
Nil
  {-# INLINABLE traverse #-}

data SnocList1 a = Snoc1 (SnocList1 a) a | First a
  deriving (SnocList1 a -> SnocList1 a -> Bool
(SnocList1 a -> SnocList1 a -> Bool)
-> (SnocList1 a -> SnocList1 a -> Bool) -> Eq (SnocList1 a)
forall a. Eq a => SnocList1 a -> SnocList1 a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SnocList1 a -> SnocList1 a -> Bool
$c/= :: forall a. Eq a => SnocList1 a -> SnocList1 a -> Bool
== :: SnocList1 a -> SnocList1 a -> Bool
$c== :: forall a. Eq a => SnocList1 a -> SnocList1 a -> Bool
Eq,Eq (SnocList1 a)
Eq (SnocList1 a)
-> (SnocList1 a -> SnocList1 a -> Ordering)
-> (SnocList1 a -> SnocList1 a -> Bool)
-> (SnocList1 a -> SnocList1 a -> Bool)
-> (SnocList1 a -> SnocList1 a -> Bool)
-> (SnocList1 a -> SnocList1 a -> Bool)
-> (SnocList1 a -> SnocList1 a -> SnocList1 a)
-> (SnocList1 a -> SnocList1 a -> SnocList1 a)
-> Ord (SnocList1 a)
SnocList1 a -> SnocList1 a -> Bool
SnocList1 a -> SnocList1 a -> Ordering
SnocList1 a -> SnocList1 a -> SnocList1 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 a. Ord a => Eq (SnocList1 a)
forall a. Ord a => SnocList1 a -> SnocList1 a -> Bool
forall a. Ord a => SnocList1 a -> SnocList1 a -> Ordering
forall a. Ord a => SnocList1 a -> SnocList1 a -> SnocList1 a
min :: SnocList1 a -> SnocList1 a -> SnocList1 a
$cmin :: forall a. Ord a => SnocList1 a -> SnocList1 a -> SnocList1 a
max :: SnocList1 a -> SnocList1 a -> SnocList1 a
$cmax :: forall a. Ord a => SnocList1 a -> SnocList1 a -> SnocList1 a
>= :: SnocList1 a -> SnocList1 a -> Bool
$c>= :: forall a. Ord a => SnocList1 a -> SnocList1 a -> Bool
> :: SnocList1 a -> SnocList1 a -> Bool
$c> :: forall a. Ord a => SnocList1 a -> SnocList1 a -> Bool
<= :: SnocList1 a -> SnocList1 a -> Bool
$c<= :: forall a. Ord a => SnocList1 a -> SnocList1 a -> Bool
< :: SnocList1 a -> SnocList1 a -> Bool
$c< :: forall a. Ord a => SnocList1 a -> SnocList1 a -> Bool
compare :: SnocList1 a -> SnocList1 a -> Ordering
$ccompare :: forall a. Ord a => SnocList1 a -> SnocList1 a -> Ordering
$cp1Ord :: forall a. Ord a => Eq (SnocList1 a)
Ord,Int -> SnocList1 a -> ShowS
[SnocList1 a] -> ShowS
SnocList1 a -> String
(Int -> SnocList1 a -> ShowS)
-> (SnocList1 a -> String)
-> ([SnocList1 a] -> ShowS)
-> Show (SnocList1 a)
forall a. Show a => Int -> SnocList1 a -> ShowS
forall a. Show a => [SnocList1 a] -> ShowS
forall a. Show a => SnocList1 a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SnocList1 a] -> ShowS
$cshowList :: forall a. Show a => [SnocList1 a] -> ShowS
show :: SnocList1 a -> String
$cshow :: forall a. Show a => SnocList1 a -> String
showsPrec :: Int -> SnocList1 a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> SnocList1 a -> ShowS
Show,ReadPrec [SnocList1 a]
ReadPrec (SnocList1 a)
Int -> ReadS (SnocList1 a)
ReadS [SnocList1 a]
(Int -> ReadS (SnocList1 a))
-> ReadS [SnocList1 a]
-> ReadPrec (SnocList1 a)
-> ReadPrec [SnocList1 a]
-> Read (SnocList1 a)
forall a. Read a => ReadPrec [SnocList1 a]
forall a. Read a => ReadPrec (SnocList1 a)
forall a. Read a => Int -> ReadS (SnocList1 a)
forall a. Read a => ReadS [SnocList1 a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SnocList1 a]
$creadListPrec :: forall a. Read a => ReadPrec [SnocList1 a]
readPrec :: ReadPrec (SnocList1 a)
$creadPrec :: forall a. Read a => ReadPrec (SnocList1 a)
readList :: ReadS [SnocList1 a]
$creadList :: forall a. Read a => ReadS [SnocList1 a]
readsPrec :: Int -> ReadS (SnocList1 a)
$creadsPrec :: forall a. Read a => Int -> ReadS (SnocList1 a)
Read,Typeable (SnocList1 a)
DataType
Constr
Typeable (SnocList1 a)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> SnocList1 a -> c (SnocList1 a))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (SnocList1 a))
-> (SnocList1 a -> Constr)
-> (SnocList1 a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (SnocList1 a)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (SnocList1 a)))
-> ((forall b. Data b => b -> b) -> SnocList1 a -> SnocList1 a)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> SnocList1 a -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> SnocList1 a -> r)
-> (forall u. (forall d. Data d => d -> u) -> SnocList1 a -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> SnocList1 a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> SnocList1 a -> m (SnocList1 a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> SnocList1 a -> m (SnocList1 a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> SnocList1 a -> m (SnocList1 a))
-> Data (SnocList1 a)
SnocList1 a -> DataType
SnocList1 a -> Constr
(forall d. Data d => c (t d)) -> Maybe (c (SnocList1 a))
(forall b. Data b => b -> b) -> SnocList1 a -> SnocList1 a
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SnocList1 a -> c (SnocList1 a)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (SnocList1 a)
forall a. Data a => Typeable (SnocList1 a)
forall a. Data a => SnocList1 a -> DataType
forall a. Data a => SnocList1 a -> Constr
forall a.
Data a =>
(forall b. Data b => b -> b) -> SnocList1 a -> SnocList1 a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> SnocList1 a -> u
forall a u.
Data a =>
(forall d. Data d => d -> u) -> SnocList1 a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> SnocList1 a -> r
forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> SnocList1 a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> SnocList1 a -> m (SnocList1 a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> SnocList1 a -> m (SnocList1 a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (SnocList1 a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SnocList1 a -> c (SnocList1 a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (SnocList1 a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (SnocList1 a))
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 u. Int -> (forall d. Data d => d -> u) -> SnocList1 a -> u
forall u. (forall d. Data d => d -> u) -> SnocList1 a -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> SnocList1 a -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> SnocList1 a -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> SnocList1 a -> m (SnocList1 a)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> SnocList1 a -> m (SnocList1 a)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (SnocList1 a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SnocList1 a -> c (SnocList1 a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (SnocList1 a))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (SnocList1 a))
$cFirst :: Constr
$cSnoc1 :: Constr
$tSnocList1 :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> SnocList1 a -> m (SnocList1 a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> SnocList1 a -> m (SnocList1 a)
gmapMp :: (forall d. Data d => d -> m d) -> SnocList1 a -> m (SnocList1 a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> SnocList1 a -> m (SnocList1 a)
gmapM :: (forall d. Data d => d -> m d) -> SnocList1 a -> m (SnocList1 a)
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> SnocList1 a -> m (SnocList1 a)
gmapQi :: Int -> (forall d. Data d => d -> u) -> SnocList1 a -> u
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> SnocList1 a -> u
gmapQ :: (forall d. Data d => d -> u) -> SnocList1 a -> [u]
$cgmapQ :: forall a u.
Data a =>
(forall d. Data d => d -> u) -> SnocList1 a -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> SnocList1 a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> SnocList1 a -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> SnocList1 a -> r
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> SnocList1 a -> r
gmapT :: (forall b. Data b => b -> b) -> SnocList1 a -> SnocList1 a
$cgmapT :: forall a.
Data a =>
(forall b. Data b => b -> b) -> SnocList1 a -> SnocList1 a
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (SnocList1 a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (SnocList1 a))
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c (SnocList1 a))
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (SnocList1 a))
dataTypeOf :: SnocList1 a -> DataType
$cdataTypeOf :: forall a. Data a => SnocList1 a -> DataType
toConstr :: SnocList1 a -> Constr
$ctoConstr :: forall a. Data a => SnocList1 a -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (SnocList1 a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (SnocList1 a)
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SnocList1 a -> c (SnocList1 a)
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SnocList1 a -> c (SnocList1 a)
$cp1Data :: forall a. Data a => Typeable (SnocList1 a)
Data)

instance Functor SnocList1 where
  fmap :: (a -> b) -> SnocList1 a -> SnocList1 b
fmap a -> b
f (Snoc1 SnocList1 a
xs a
x) = SnocList1 b -> b -> SnocList1 b
forall a. SnocList1 a -> a -> SnocList1 a
Snoc1 ((a -> b) -> SnocList1 a -> SnocList1 b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f SnocList1 a
xs) (a -> b
f a
x)
  fmap a -> b
f (First a
a) = b -> SnocList1 b
forall a. a -> SnocList1 a
First (a -> b
f a
a)
  {-# INLINABLE fmap #-}

instance Foldable SnocList1 where
  foldl :: (b -> a -> b) -> b -> SnocList1 a -> b
foldl b -> a -> b
f b
z SnocList1 a
m0 = SnocList1 a -> b
go SnocList1 a
m0 where
    go :: SnocList1 a -> b
go (Snoc1 SnocList1 a
xs a
x) = b -> a -> b
f (SnocList1 a -> b
go SnocList1 a
xs) a
x
    go (First a
a) = b -> a -> b
f b
z a
a
  {-# INLINE foldl #-}
  foldl1 :: (a -> a -> a) -> SnocList1 a -> a
foldl1 a -> a -> a
f SnocList1 a
m0 = SnocList1 a -> a
go SnocList1 a
m0 where
    go :: SnocList1 a -> a
go (Snoc1 SnocList1 a
xs a
x) = a -> a -> a
f (SnocList1 a -> a
go SnocList1 a
xs) a
x
    go (First a
a) = a
a
  {-# INLINE foldl1 #-}
  foldMap :: (a -> m) -> SnocList1 a -> m
foldMap a -> m
f (Snoc1 SnocList1 a
xs a
x) = (a -> m) -> SnocList1 a -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap a -> m
f SnocList1 a
xs m -> m -> m
forall a. Monoid a => a -> a -> a
`mappend` a -> m
f a
x
  foldMap a -> m
f (First a
a) = a -> m
f a
a
  {-# INLINABLE foldMap #-}

instance Traversable SnocList1 where
  traverse :: (a -> f b) -> SnocList1 a -> f (SnocList1 b)
traverse a -> f b
f (Snoc1 SnocList1 a
xs a
x) = SnocList1 b -> b -> SnocList1 b
forall a. SnocList1 a -> a -> SnocList1 a
Snoc1 (SnocList1 b -> b -> SnocList1 b)
-> f (SnocList1 b) -> f (b -> SnocList1 b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> f b) -> SnocList1 a -> f (SnocList1 b)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse a -> f b
f SnocList1 a
xs f (b -> SnocList1 b) -> f b -> f (SnocList1 b)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> a -> f b
f a
x
  traverse a -> f b
f (First a
a) = b -> SnocList1 b
forall a. a -> SnocList1 a
First (b -> SnocList1 b) -> f b -> f (SnocList1 b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f b
f a
a
  {-# INLINABLE traverse #-}

-- | Strict 'Maybe'
data Maybe' a = Nothing' | Just' !a
  deriving (Maybe' a -> Maybe' a -> Bool
(Maybe' a -> Maybe' a -> Bool)
-> (Maybe' a -> Maybe' a -> Bool) -> Eq (Maybe' a)
forall a. Eq a => Maybe' a -> Maybe' a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Maybe' a -> Maybe' a -> Bool
$c/= :: forall a. Eq a => Maybe' a -> Maybe' a -> Bool
== :: Maybe' a -> Maybe' a -> Bool
$c== :: forall a. Eq a => Maybe' a -> Maybe' a -> Bool
Eq,Eq (Maybe' a)
Eq (Maybe' a)
-> (Maybe' a -> Maybe' a -> Ordering)
-> (Maybe' a -> Maybe' a -> Bool)
-> (Maybe' a -> Maybe' a -> Bool)
-> (Maybe' a -> Maybe' a -> Bool)
-> (Maybe' a -> Maybe' a -> Bool)
-> (Maybe' a -> Maybe' a -> Maybe' a)
-> (Maybe' a -> Maybe' a -> Maybe' a)
-> Ord (Maybe' a)
Maybe' a -> Maybe' a -> Bool
Maybe' a -> Maybe' a -> Ordering
Maybe' a -> Maybe' a -> Maybe' 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 a. Ord a => Eq (Maybe' a)
forall a. Ord a => Maybe' a -> Maybe' a -> Bool
forall a. Ord a => Maybe' a -> Maybe' a -> Ordering
forall a. Ord a => Maybe' a -> Maybe' a -> Maybe' a
min :: Maybe' a -> Maybe' a -> Maybe' a
$cmin :: forall a. Ord a => Maybe' a -> Maybe' a -> Maybe' a
max :: Maybe' a -> Maybe' a -> Maybe' a
$cmax :: forall a. Ord a => Maybe' a -> Maybe' a -> Maybe' a
>= :: Maybe' a -> Maybe' a -> Bool
$c>= :: forall a. Ord a => Maybe' a -> Maybe' a -> Bool
> :: Maybe' a -> Maybe' a -> Bool
$c> :: forall a. Ord a => Maybe' a -> Maybe' a -> Bool
<= :: Maybe' a -> Maybe' a -> Bool
$c<= :: forall a. Ord a => Maybe' a -> Maybe' a -> Bool
< :: Maybe' a -> Maybe' a -> Bool
$c< :: forall a. Ord a => Maybe' a -> Maybe' a -> Bool
compare :: Maybe' a -> Maybe' a -> Ordering
$ccompare :: forall a. Ord a => Maybe' a -> Maybe' a -> Ordering
$cp1Ord :: forall a. Ord a => Eq (Maybe' a)
Ord,Int -> Maybe' a -> ShowS
[Maybe' a] -> ShowS
Maybe' a -> String
(Int -> Maybe' a -> ShowS)
-> (Maybe' a -> String) -> ([Maybe' a] -> ShowS) -> Show (Maybe' a)
forall a. Show a => Int -> Maybe' a -> ShowS
forall a. Show a => [Maybe' a] -> ShowS
forall a. Show a => Maybe' a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Maybe' a] -> ShowS
$cshowList :: forall a. Show a => [Maybe' a] -> ShowS
show :: Maybe' a -> String
$cshow :: forall a. Show a => Maybe' a -> String
showsPrec :: Int -> Maybe' a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> Maybe' a -> ShowS
Show,ReadPrec [Maybe' a]
ReadPrec (Maybe' a)
Int -> ReadS (Maybe' a)
ReadS [Maybe' a]
(Int -> ReadS (Maybe' a))
-> ReadS [Maybe' a]
-> ReadPrec (Maybe' a)
-> ReadPrec [Maybe' a]
-> Read (Maybe' a)
forall a. Read a => ReadPrec [Maybe' a]
forall a. Read a => ReadPrec (Maybe' a)
forall a. Read a => Int -> ReadS (Maybe' a)
forall a. Read a => ReadS [Maybe' a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Maybe' a]
$creadListPrec :: forall a. Read a => ReadPrec [Maybe' a]
readPrec :: ReadPrec (Maybe' a)
$creadPrec :: forall a. Read a => ReadPrec (Maybe' a)
readList :: ReadS [Maybe' a]
$creadList :: forall a. Read a => ReadS [Maybe' a]
readsPrec :: Int -> ReadS (Maybe' a)
$creadsPrec :: forall a. Read a => Int -> ReadS (Maybe' a)
Read,Typeable (Maybe' a)
DataType
Constr
Typeable (Maybe' a)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Maybe' a -> c (Maybe' a))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Maybe' a))
-> (Maybe' a -> Constr)
-> (Maybe' a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (Maybe' a)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (Maybe' a)))
-> ((forall b. Data b => b -> b) -> Maybe' a -> Maybe' a)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Maybe' a -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Maybe' a -> r)
-> (forall u. (forall d. Data d => d -> u) -> Maybe' a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Maybe' a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Maybe' a -> m (Maybe' a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Maybe' a -> m (Maybe' a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Maybe' a -> m (Maybe' a))
-> Data (Maybe' a)
Maybe' a -> DataType
Maybe' a -> Constr
(forall d. Data d => c (t d)) -> Maybe (c (Maybe' a))
(forall b. Data b => b -> b) -> Maybe' a -> Maybe' a
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Maybe' a -> c (Maybe' a)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Maybe' a)
forall a. Data a => Typeable (Maybe' a)
forall a. Data a => Maybe' a -> DataType
forall a. Data a => Maybe' a -> Constr
forall a.
Data a =>
(forall b. Data b => b -> b) -> Maybe' a -> Maybe' a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Maybe' a -> u
forall a u.
Data a =>
(forall d. Data d => d -> u) -> Maybe' a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Maybe' a -> r
forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Maybe' a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Maybe' a -> m (Maybe' a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Maybe' a -> m (Maybe' a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Maybe' a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Maybe' a -> c (Maybe' a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Maybe' a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Maybe' a))
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 u. Int -> (forall d. Data d => d -> u) -> Maybe' a -> u
forall u. (forall d. Data d => d -> u) -> Maybe' a -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Maybe' a -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Maybe' a -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Maybe' a -> m (Maybe' a)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Maybe' a -> m (Maybe' a)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Maybe' a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Maybe' a -> c (Maybe' a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Maybe' a))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Maybe' a))
$cJust' :: Constr
$cNothing' :: Constr
$tMaybe' :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Maybe' a -> m (Maybe' a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Maybe' a -> m (Maybe' a)
gmapMp :: (forall d. Data d => d -> m d) -> Maybe' a -> m (Maybe' a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Maybe' a -> m (Maybe' a)
gmapM :: (forall d. Data d => d -> m d) -> Maybe' a -> m (Maybe' a)
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Maybe' a -> m (Maybe' a)
gmapQi :: Int -> (forall d. Data d => d -> u) -> Maybe' a -> u
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Maybe' a -> u
gmapQ :: (forall d. Data d => d -> u) -> Maybe' a -> [u]
$cgmapQ :: forall a u.
Data a =>
(forall d. Data d => d -> u) -> Maybe' a -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Maybe' a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Maybe' a -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Maybe' a -> r
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Maybe' a -> r
gmapT :: (forall b. Data b => b -> b) -> Maybe' a -> Maybe' a
$cgmapT :: forall a.
Data a =>
(forall b. Data b => b -> b) -> Maybe' a -> Maybe' a
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Maybe' a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Maybe' a))
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c (Maybe' a))
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Maybe' a))
dataTypeOf :: Maybe' a -> DataType
$cdataTypeOf :: forall a. Data a => Maybe' a -> DataType
toConstr :: Maybe' a -> Constr
$ctoConstr :: forall a. Data a => Maybe' a -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Maybe' a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Maybe' a)
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Maybe' a -> c (Maybe' a)
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Maybe' a -> c (Maybe' a)
$cp1Data :: forall a. Data a => Typeable (Maybe' a)
Data)

instance Foldable Maybe' where
  foldMap :: (a -> m) -> Maybe' a -> m
foldMap a -> m
_ Maybe' a
Nothing' = m
forall a. Monoid a => a
mempty
  foldMap a -> m
f (Just' a
a) = a -> m
f a
a

maybe' :: b -> (a -> b) -> Maybe' a -> b
maybe' :: b -> (a -> b) -> Maybe' a -> b
maybe' b
_ a -> b
f (Just' a
a) = a -> b
f a
a
maybe' b
z a -> b
_ Maybe' a
Nothing'  = b
z
{-# INLINE maybe' #-}

-- | A reified 'Monoid'.
newtype N a s = N { N a s -> a
runN :: a }
  deriving (N a s -> N a s -> Bool
(N a s -> N a s -> Bool) -> (N a s -> N a s -> Bool) -> Eq (N a s)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall a s. Eq a => N a s -> N a s -> Bool
/= :: N a s -> N a s -> Bool
$c/= :: forall a s. Eq a => N a s -> N a s -> Bool
== :: N a s -> N a s -> Bool
$c== :: forall a s. Eq a => N a s -> N a s -> Bool
Eq,Eq (N a s)
Eq (N a s)
-> (N a s -> N a s -> Ordering)
-> (N a s -> N a s -> Bool)
-> (N a s -> N a s -> Bool)
-> (N a s -> N a s -> Bool)
-> (N a s -> N a s -> Bool)
-> (N a s -> N a s -> N a s)
-> (N a s -> N a s -> N a s)
-> Ord (N a s)
N a s -> N a s -> Bool
N a s -> N a s -> Ordering
N a s -> N a s -> N a s
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 a s. Ord a => Eq (N a s)
forall a s. Ord a => N a s -> N a s -> Bool
forall a s. Ord a => N a s -> N a s -> Ordering
forall a s. Ord a => N a s -> N a s -> N a s
min :: N a s -> N a s -> N a s
$cmin :: forall a s. Ord a => N a s -> N a s -> N a s
max :: N a s -> N a s -> N a s
$cmax :: forall a s. Ord a => N a s -> N a s -> N a s
>= :: N a s -> N a s -> Bool
$c>= :: forall a s. Ord a => N a s -> N a s -> Bool
> :: N a s -> N a s -> Bool
$c> :: forall a s. Ord a => N a s -> N a s -> Bool
<= :: N a s -> N a s -> Bool
$c<= :: forall a s. Ord a => N a s -> N a s -> Bool
< :: N a s -> N a s -> Bool
$c< :: forall a s. Ord a => N a s -> N a s -> Bool
compare :: N a s -> N a s -> Ordering
$ccompare :: forall a s. Ord a => N a s -> N a s -> Ordering
$cp1Ord :: forall a s. Ord a => Eq (N a s)
Ord,Int -> N a s -> ShowS
[N a s] -> ShowS
N a s -> String
(Int -> N a s -> ShowS)
-> (N a s -> String) -> ([N a s] -> ShowS) -> Show (N a s)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall a s. Show a => Int -> N a s -> ShowS
forall a s. Show a => [N a s] -> ShowS
forall a s. Show a => N a s -> String
showList :: [N a s] -> ShowS
$cshowList :: forall a s. Show a => [N a s] -> ShowS
show :: N a s -> String
$cshow :: forall a s. Show a => N a s -> String
showsPrec :: Int -> N a s -> ShowS
$cshowsPrec :: forall a s. Show a => Int -> N a s -> ShowS
Show,ReadPrec [N a s]
ReadPrec (N a s)
Int -> ReadS (N a s)
ReadS [N a s]
(Int -> ReadS (N a s))
-> ReadS [N a s]
-> ReadPrec (N a s)
-> ReadPrec [N a s]
-> Read (N a s)
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
forall a s. Read a => ReadPrec [N a s]
forall a s. Read a => ReadPrec (N a s)
forall a s. Read a => Int -> ReadS (N a s)
forall a s. Read a => ReadS [N a s]
readListPrec :: ReadPrec [N a s]
$creadListPrec :: forall a s. Read a => ReadPrec [N a s]
readPrec :: ReadPrec (N a s)
$creadPrec :: forall a s. Read a => ReadPrec (N a s)
readList :: ReadS [N a s]
$creadList :: forall a s. Read a => ReadS [N a s]
readsPrec :: Int -> ReadS (N a s)
$creadsPrec :: forall a s. Read a => Int -> ReadS (N a s)
Read,Typeable (N a s)
DataType
Constr
Typeable (N a s)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> N a s -> c (N a s))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (N a s))
-> (N a s -> Constr)
-> (N a s -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (N a s)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (N a s)))
-> ((forall b. Data b => b -> b) -> N a s -> N a s)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> N a s -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> N a s -> r)
-> (forall u. (forall d. Data d => d -> u) -> N a s -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> N a s -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> N a s -> m (N a s))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> N a s -> m (N a s))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> N a s -> m (N a s))
-> Data (N a s)
N a s -> DataType
N a s -> Constr
(forall b. Data b => b -> b) -> N a s -> N a s
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> N a s -> c (N a s)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (N a s)
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (N a s))
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 u. Int -> (forall d. Data d => d -> u) -> N a s -> u
forall u. (forall d. Data d => d -> u) -> N a s -> [u]
forall a s. (Data a, Data s) => Typeable (N a s)
forall a s. (Data a, Data s) => N a s -> DataType
forall a s. (Data a, Data s) => N a s -> Constr
forall a s.
(Data a, Data s) =>
(forall b. Data b => b -> b) -> N a s -> N a s
forall a s u.
(Data a, Data s) =>
Int -> (forall d. Data d => d -> u) -> N a s -> u
forall a s u.
(Data a, Data s) =>
(forall d. Data d => d -> u) -> N a s -> [u]
forall a s r r'.
(Data a, Data s) =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> N a s -> r
forall a s r r'.
(Data a, Data s) =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> N a s -> r
forall a s (m :: * -> *).
(Data a, Data s, Monad m) =>
(forall d. Data d => d -> m d) -> N a s -> m (N a s)
forall a s (m :: * -> *).
(Data a, Data s, MonadPlus m) =>
(forall d. Data d => d -> m d) -> N a s -> m (N a s)
forall a s (c :: * -> *).
(Data a, Data s) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (N a s)
forall a s (c :: * -> *).
(Data a, Data s) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> N a s -> c (N a s)
forall a s (t :: * -> *) (c :: * -> *).
(Data a, Data s, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (N a s))
forall a s (t :: * -> * -> *) (c :: * -> *).
(Data a, Data s, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (N a s))
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> N a s -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> N a s -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> N a s -> m (N a s)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> N a s -> m (N a s)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (N a s)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> N a s -> c (N a s)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (N a s))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (N a s))
$cN :: Constr
$tN :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> N a s -> m (N a s)
$cgmapMo :: forall a s (m :: * -> *).
(Data a, Data s, MonadPlus m) =>
(forall d. Data d => d -> m d) -> N a s -> m (N a s)
gmapMp :: (forall d. Data d => d -> m d) -> N a s -> m (N a s)
$cgmapMp :: forall a s (m :: * -> *).
(Data a, Data s, MonadPlus m) =>
(forall d. Data d => d -> m d) -> N a s -> m (N a s)
gmapM :: (forall d. Data d => d -> m d) -> N a s -> m (N a s)
$cgmapM :: forall a s (m :: * -> *).
(Data a, Data s, Monad m) =>
(forall d. Data d => d -> m d) -> N a s -> m (N a s)
gmapQi :: Int -> (forall d. Data d => d -> u) -> N a s -> u
$cgmapQi :: forall a s u.
(Data a, Data s) =>
Int -> (forall d. Data d => d -> u) -> N a s -> u
gmapQ :: (forall d. Data d => d -> u) -> N a s -> [u]
$cgmapQ :: forall a s u.
(Data a, Data s) =>
(forall d. Data d => d -> u) -> N a s -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> N a s -> r
$cgmapQr :: forall a s r r'.
(Data a, Data s) =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> N a s -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> N a s -> r
$cgmapQl :: forall a s r r'.
(Data a, Data s) =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> N a s -> r
gmapT :: (forall b. Data b => b -> b) -> N a s -> N a s
$cgmapT :: forall a s.
(Data a, Data s) =>
(forall b. Data b => b -> b) -> N a s -> N a s
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (N a s))
$cdataCast2 :: forall a s (t :: * -> * -> *) (c :: * -> *).
(Data a, Data s, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (N a s))
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c (N a s))
$cdataCast1 :: forall a s (t :: * -> *) (c :: * -> *).
(Data a, Data s, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (N a s))
dataTypeOf :: N a s -> DataType
$cdataTypeOf :: forall a s. (Data a, Data s) => N a s -> DataType
toConstr :: N a s -> Constr
$ctoConstr :: forall a s. (Data a, Data s) => N a s -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (N a s)
$cgunfold :: forall a s (c :: * -> *).
(Data a, Data s) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (N a s)
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> N a s -> c (N a s)
$cgfoldl :: forall a s (c :: * -> *).
(Data a, Data s) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> N a s -> c (N a s)
$cp1Data :: forall a s. (Data a, Data s) => Typeable (N a s)
Data)

instance Reifies s (a -> a -> a, a) => Semigroup (N a s) where
  N a
a <> :: N a s -> N a s -> N a s
<> N a
b = a -> N a s
forall a s. a -> N a s
N (a -> N a s) -> a -> N a s
forall a b. (a -> b) -> a -> b
$ (a -> a -> a, a) -> a -> a -> a
forall a b. (a, b) -> a
fst (Proxy s -> (a -> a -> a, a)
forall k (s :: k) a (proxy :: k -> *). Reifies s a => proxy s -> a
reflect (Proxy s
forall k (t :: k). Proxy t
Proxy :: Proxy s)) a
a a
b
  {-# INLINE (<>) #-}

instance Reifies s (a -> a -> a, a) => Monoid (N a s) where
  mempty :: N a s
mempty = a -> N a s
forall a s. a -> N a s
N (a -> N a s) -> a -> N a s
forall a b. (a -> b) -> a -> b
$ (a -> a -> a, a) -> a
forall a b. (a, b) -> b
snd ((a -> a -> a, a) -> a) -> (a -> a -> a, a) -> a
forall a b. (a -> b) -> a -> b
$ Proxy s -> (a -> a -> a, a)
forall k (s :: k) a (proxy :: k -> *). Reifies s a => proxy s -> a
reflect (Proxy s
forall k (t :: k). Proxy t
Proxy :: Proxy s)
  {-# INLINE mempty #-}
  mappend :: N a s -> N a s -> N a s
mappend = N a s -> N a s -> N a s
forall a. Semigroup a => a -> a -> a
(<>)
  {-# INLINE mappend #-}

-- | The shape of a 'foldMap'
data Tree a
  = Zero
  | One a
  | Two (Tree a) (Tree a)
  deriving (Tree a -> Tree a -> Bool
(Tree a -> Tree a -> Bool)
-> (Tree a -> Tree a -> Bool) -> Eq (Tree a)
forall a. Eq a => Tree a -> Tree a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Tree a -> Tree a -> Bool
$c/= :: forall a. Eq a => Tree a -> Tree a -> Bool
== :: Tree a -> Tree a -> Bool
$c== :: forall a. Eq a => Tree a -> Tree a -> Bool
Eq,Eq (Tree a)
Eq (Tree a)
-> (Tree a -> Tree a -> Ordering)
-> (Tree a -> Tree a -> Bool)
-> (Tree a -> Tree a -> Bool)
-> (Tree a -> Tree a -> Bool)
-> (Tree a -> Tree a -> Bool)
-> (Tree a -> Tree a -> Tree a)
-> (Tree a -> Tree a -> Tree a)
-> Ord (Tree a)
Tree a -> Tree a -> Bool
Tree a -> Tree a -> Ordering
Tree a -> Tree a -> Tree 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 a. Ord a => Eq (Tree a)
forall a. Ord a => Tree a -> Tree a -> Bool
forall a. Ord a => Tree a -> Tree a -> Ordering
forall a. Ord a => Tree a -> Tree a -> Tree a
min :: Tree a -> Tree a -> Tree a
$cmin :: forall a. Ord a => Tree a -> Tree a -> Tree a
max :: Tree a -> Tree a -> Tree a
$cmax :: forall a. Ord a => Tree a -> Tree a -> Tree a
>= :: Tree a -> Tree a -> Bool
$c>= :: forall a. Ord a => Tree a -> Tree a -> Bool
> :: Tree a -> Tree a -> Bool
$c> :: forall a. Ord a => Tree a -> Tree a -> Bool
<= :: Tree a -> Tree a -> Bool
$c<= :: forall a. Ord a => Tree a -> Tree a -> Bool
< :: Tree a -> Tree a -> Bool
$c< :: forall a. Ord a => Tree a -> Tree a -> Bool
compare :: Tree a -> Tree a -> Ordering
$ccompare :: forall a. Ord a => Tree a -> Tree a -> Ordering
$cp1Ord :: forall a. Ord a => Eq (Tree a)
Ord,Int -> Tree a -> ShowS
[Tree a] -> ShowS
Tree a -> String
(Int -> Tree a -> ShowS)
-> (Tree a -> String) -> ([Tree a] -> ShowS) -> Show (Tree a)
forall a. Show a => Int -> Tree a -> ShowS
forall a. Show a => [Tree a] -> ShowS
forall a. Show a => Tree a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Tree a] -> ShowS
$cshowList :: forall a. Show a => [Tree a] -> ShowS
show :: Tree a -> String
$cshow :: forall a. Show a => Tree a -> String
showsPrec :: Int -> Tree a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> Tree a -> ShowS
Show,ReadPrec [Tree a]
ReadPrec (Tree a)
Int -> ReadS (Tree a)
ReadS [Tree a]
(Int -> ReadS (Tree a))
-> ReadS [Tree a]
-> ReadPrec (Tree a)
-> ReadPrec [Tree a]
-> Read (Tree a)
forall a. Read a => ReadPrec [Tree a]
forall a. Read a => ReadPrec (Tree a)
forall a. Read a => Int -> ReadS (Tree a)
forall a. Read a => ReadS [Tree a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Tree a]
$creadListPrec :: forall a. Read a => ReadPrec [Tree a]
readPrec :: ReadPrec (Tree a)
$creadPrec :: forall a. Read a => ReadPrec (Tree a)
readList :: ReadS [Tree a]
$creadList :: forall a. Read a => ReadS [Tree a]
readsPrec :: Int -> ReadS (Tree a)
$creadsPrec :: forall a. Read a => Int -> ReadS (Tree a)
Read,Typeable (Tree a)
DataType
Constr
Typeable (Tree a)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Tree a -> c (Tree a))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Tree a))
-> (Tree a -> Constr)
-> (Tree a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (Tree a)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Tree a)))
-> ((forall b. Data b => b -> b) -> Tree a -> Tree a)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Tree a -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Tree a -> r)
-> (forall u. (forall d. Data d => d -> u) -> Tree a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Tree a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Tree a -> m (Tree a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Tree a -> m (Tree a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Tree a -> m (Tree a))
-> Data (Tree a)
Tree a -> DataType
Tree a -> Constr
(forall d. Data d => c (t d)) -> Maybe (c (Tree a))
(forall b. Data b => b -> b) -> Tree a -> Tree a
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Tree a -> c (Tree a)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Tree a)
forall a. Data a => Typeable (Tree a)
forall a. Data a => Tree a -> DataType
forall a. Data a => Tree a -> Constr
forall a.
Data a =>
(forall b. Data b => b -> b) -> Tree a -> Tree a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Tree a -> u
forall a u. Data a => (forall d. Data d => d -> u) -> Tree a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Tree a -> r
forall a r r'.
Data a =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Tree a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Tree a -> m (Tree a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Tree a -> m (Tree a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Tree a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Tree a -> c (Tree a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Tree a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Tree a))
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 u. Int -> (forall d. Data d => d -> u) -> Tree a -> u
forall u. (forall d. Data d => d -> u) -> Tree a -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Tree a -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Tree a -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Tree a -> m (Tree a)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Tree a -> m (Tree a)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Tree a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Tree a -> c (Tree a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Tree a))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Tree a))
$cTwo :: Constr
$cOne :: Constr
$cZero :: Constr
$tTree :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Tree a -> m (Tree a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Tree a -> m (Tree a)
gmapMp :: (forall d. Data d => d -> m d) -> Tree a -> m (Tree a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Tree a -> m (Tree a)
gmapM :: (forall d. Data d => d -> m d) -> Tree a -> m (Tree a)
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Tree a -> m (Tree a)
gmapQi :: Int -> (forall d. Data d => d -> u) -> Tree a -> u
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Tree a -> u
gmapQ :: (forall d. Data d => d -> u) -> Tree a -> [u]
$cgmapQ :: forall a u. Data a => (forall d. Data d => d -> u) -> Tree a -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Tree a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Tree a -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Tree a -> r
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Tree a -> r
gmapT :: (forall b. Data b => b -> b) -> Tree a -> Tree a
$cgmapT :: forall a.
Data a =>
(forall b. Data b => b -> b) -> Tree a -> Tree a
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Tree a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Tree a))
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c (Tree a))
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Tree a))
dataTypeOf :: Tree a -> DataType
$cdataTypeOf :: forall a. Data a => Tree a -> DataType
toConstr :: Tree a -> Constr
$ctoConstr :: forall a. Data a => Tree a -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Tree a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Tree a)
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Tree a -> c (Tree a)
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Tree a -> c (Tree a)
$cp1Data :: forall a. Data a => Typeable (Tree a)
Data)

instance Functor Tree where
  fmap :: (a -> b) -> Tree a -> Tree b
fmap a -> b
_ Tree a
Zero = Tree b
forall a. Tree a
Zero
  fmap a -> b
f (One a
a) = b -> Tree b
forall a. a -> Tree a
One (a -> b
f a
a)
  fmap a -> b
f (Two Tree a
a Tree a
b) = Tree b -> Tree b -> Tree b
forall a. Tree a -> Tree a -> Tree a
Two ((a -> b) -> Tree a -> Tree b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Tree a
a) ((a -> b) -> Tree a -> Tree b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Tree a
b)

instance Foldable Tree where
  foldMap :: (a -> m) -> Tree a -> m
foldMap a -> m
_ Tree a
Zero = m
forall a. Monoid a => a
mempty
  foldMap a -> m
f (One a
a) = a -> m
f a
a
  foldMap a -> m
f (Two Tree a
a Tree a
b) = (a -> m) -> Tree a -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap a -> m
f Tree a
a m -> m -> m
forall a. Monoid a => a -> a -> a
`mappend` (a -> m) -> Tree a -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap a -> m
f Tree a
b

instance Traversable Tree where
  traverse :: (a -> f b) -> Tree a -> f (Tree b)
traverse a -> f b
_ Tree a
Zero = Tree b -> f (Tree b)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Tree b
forall a. Tree a
Zero
  traverse a -> f b
f (One a
a) = b -> Tree b
forall a. a -> Tree a
One (b -> Tree b) -> f b -> f (Tree b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f b
f a
a
  traverse a -> f b
f (Two Tree a
a Tree a
b) = Tree b -> Tree b -> Tree b
forall a. Tree a -> Tree a -> Tree a
Two (Tree b -> Tree b -> Tree b) -> f (Tree b) -> f (Tree b -> Tree b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> f b) -> Tree a -> f (Tree b)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse a -> f b
f Tree a
a f (Tree b -> Tree b) -> f (Tree b) -> f (Tree b)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (a -> f b) -> Tree a -> f (Tree b)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse a -> f b
f Tree a
b

-- | A reified 'Semigroup'.
newtype S a s = S { S a s -> a
runS :: a }
  deriving (S a s -> S a s -> Bool
(S a s -> S a s -> Bool) -> (S a s -> S a s -> Bool) -> Eq (S a s)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall a s. Eq a => S a s -> S a s -> Bool
/= :: S a s -> S a s -> Bool
$c/= :: forall a s. Eq a => S a s -> S a s -> Bool
== :: S a s -> S a s -> Bool
$c== :: forall a s. Eq a => S a s -> S a s -> Bool
Eq,Eq (S a s)
Eq (S a s)
-> (S a s -> S a s -> Ordering)
-> (S a s -> S a s -> Bool)
-> (S a s -> S a s -> Bool)
-> (S a s -> S a s -> Bool)
-> (S a s -> S a s -> Bool)
-> (S a s -> S a s -> S a s)
-> (S a s -> S a s -> S a s)
-> Ord (S a s)
S a s -> S a s -> Bool
S a s -> S a s -> Ordering
S a s -> S a s -> S a s
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 a s. Ord a => Eq (S a s)
forall a s. Ord a => S a s -> S a s -> Bool
forall a s. Ord a => S a s -> S a s -> Ordering
forall a s. Ord a => S a s -> S a s -> S a s
min :: S a s -> S a s -> S a s
$cmin :: forall a s. Ord a => S a s -> S a s -> S a s
max :: S a s -> S a s -> S a s
$cmax :: forall a s. Ord a => S a s -> S a s -> S a s
>= :: S a s -> S a s -> Bool
$c>= :: forall a s. Ord a => S a s -> S a s -> Bool
> :: S a s -> S a s -> Bool
$c> :: forall a s. Ord a => S a s -> S a s -> Bool
<= :: S a s -> S a s -> Bool
$c<= :: forall a s. Ord a => S a s -> S a s -> Bool
< :: S a s -> S a s -> Bool
$c< :: forall a s. Ord a => S a s -> S a s -> Bool
compare :: S a s -> S a s -> Ordering
$ccompare :: forall a s. Ord a => S a s -> S a s -> Ordering
$cp1Ord :: forall a s. Ord a => Eq (S a s)
Ord,Int -> S a s -> ShowS
[S a s] -> ShowS
S a s -> String
(Int -> S a s -> ShowS)
-> (S a s -> String) -> ([S a s] -> ShowS) -> Show (S a s)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall a s. Show a => Int -> S a s -> ShowS
forall a s. Show a => [S a s] -> ShowS
forall a s. Show a => S a s -> String
showList :: [S a s] -> ShowS
$cshowList :: forall a s. Show a => [S a s] -> ShowS
show :: S a s -> String
$cshow :: forall a s. Show a => S a s -> String
showsPrec :: Int -> S a s -> ShowS
$cshowsPrec :: forall a s. Show a => Int -> S a s -> ShowS
Show,ReadPrec [S a s]
ReadPrec (S a s)
Int -> ReadS (S a s)
ReadS [S a s]
(Int -> ReadS (S a s))
-> ReadS [S a s]
-> ReadPrec (S a s)
-> ReadPrec [S a s]
-> Read (S a s)
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
forall a s. Read a => ReadPrec [S a s]
forall a s. Read a => ReadPrec (S a s)
forall a s. Read a => Int -> ReadS (S a s)
forall a s. Read a => ReadS [S a s]
readListPrec :: ReadPrec [S a s]
$creadListPrec :: forall a s. Read a => ReadPrec [S a s]
readPrec :: ReadPrec (S a s)
$creadPrec :: forall a s. Read a => ReadPrec (S a s)
readList :: ReadS [S a s]
$creadList :: forall a s. Read a => ReadS [S a s]
readsPrec :: Int -> ReadS (S a s)
$creadsPrec :: forall a s. Read a => Int -> ReadS (S a s)
Read,Typeable (S a s)
DataType
Constr
Typeable (S a s)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> S a s -> c (S a s))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (S a s))
-> (S a s -> Constr)
-> (S a s -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (S a s)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (S a s)))
-> ((forall b. Data b => b -> b) -> S a s -> S a s)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> S a s -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> S a s -> r)
-> (forall u. (forall d. Data d => d -> u) -> S a s -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> S a s -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> S a s -> m (S a s))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> S a s -> m (S a s))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> S a s -> m (S a s))
-> Data (S a s)
S a s -> DataType
S a s -> Constr
(forall b. Data b => b -> b) -> S a s -> S a s
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> S a s -> c (S a s)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (S a s)
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (S a s))
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 u. Int -> (forall d. Data d => d -> u) -> S a s -> u
forall u. (forall d. Data d => d -> u) -> S a s -> [u]
forall a s. (Data a, Data s) => Typeable (S a s)
forall a s. (Data a, Data s) => S a s -> DataType
forall a s. (Data a, Data s) => S a s -> Constr
forall a s.
(Data a, Data s) =>
(forall b. Data b => b -> b) -> S a s -> S a s
forall a s u.
(Data a, Data s) =>
Int -> (forall d. Data d => d -> u) -> S a s -> u
forall a s u.
(Data a, Data s) =>
(forall d. Data d => d -> u) -> S a s -> [u]
forall a s r r'.
(Data a, Data s) =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> S a s -> r
forall a s r r'.
(Data a, Data s) =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> S a s -> r
forall a s (m :: * -> *).
(Data a, Data s, Monad m) =>
(forall d. Data d => d -> m d) -> S a s -> m (S a s)
forall a s (m :: * -> *).
(Data a, Data s, MonadPlus m) =>
(forall d. Data d => d -> m d) -> S a s -> m (S a s)
forall a s (c :: * -> *).
(Data a, Data s) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (S a s)
forall a s (c :: * -> *).
(Data a, Data s) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> S a s -> c (S a s)
forall a s (t :: * -> *) (c :: * -> *).
(Data a, Data s, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (S a s))
forall a s (t :: * -> * -> *) (c :: * -> *).
(Data a, Data s, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (S a s))
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> S a s -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> S a s -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> S a s -> m (S a s)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> S a s -> m (S a s)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (S a s)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> S a s -> c (S a s)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (S a s))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (S a s))
$cS :: Constr
$tS :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> S a s -> m (S a s)
$cgmapMo :: forall a s (m :: * -> *).
(Data a, Data s, MonadPlus m) =>
(forall d. Data d => d -> m d) -> S a s -> m (S a s)
gmapMp :: (forall d. Data d => d -> m d) -> S a s -> m (S a s)
$cgmapMp :: forall a s (m :: * -> *).
(Data a, Data s, MonadPlus m) =>
(forall d. Data d => d -> m d) -> S a s -> m (S a s)
gmapM :: (forall d. Data d => d -> m d) -> S a s -> m (S a s)
$cgmapM :: forall a s (m :: * -> *).
(Data a, Data s, Monad m) =>
(forall d. Data d => d -> m d) -> S a s -> m (S a s)
gmapQi :: Int -> (forall d. Data d => d -> u) -> S a s -> u
$cgmapQi :: forall a s u.
(Data a, Data s) =>
Int -> (forall d. Data d => d -> u) -> S a s -> u
gmapQ :: (forall d. Data d => d -> u) -> S a s -> [u]
$cgmapQ :: forall a s u.
(Data a, Data s) =>
(forall d. Data d => d -> u) -> S a s -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> S a s -> r
$cgmapQr :: forall a s r r'.
(Data a, Data s) =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> S a s -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> S a s -> r
$cgmapQl :: forall a s r r'.
(Data a, Data s) =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> S a s -> r
gmapT :: (forall b. Data b => b -> b) -> S a s -> S a s
$cgmapT :: forall a s.
(Data a, Data s) =>
(forall b. Data b => b -> b) -> S a s -> S a s
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (S a s))
$cdataCast2 :: forall a s (t :: * -> * -> *) (c :: * -> *).
(Data a, Data s, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (S a s))
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c (S a s))
$cdataCast1 :: forall a s (t :: * -> *) (c :: * -> *).
(Data a, Data s, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (S a s))
dataTypeOf :: S a s -> DataType
$cdataTypeOf :: forall a s. (Data a, Data s) => S a s -> DataType
toConstr :: S a s -> Constr
$ctoConstr :: forall a s. (Data a, Data s) => S a s -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (S a s)
$cgunfold :: forall a s (c :: * -> *).
(Data a, Data s) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (S a s)
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> S a s -> c (S a s)
$cgfoldl :: forall a s (c :: * -> *).
(Data a, Data s) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> S a s -> c (S a s)
$cp1Data :: forall a s. (Data a, Data s) => Typeable (S a s)
Data)

instance Reifies s (a -> a -> a) => Semigroup (S a s) where
  S a
a <> :: S a s -> S a s -> S a s
<> S a
b = a -> S a s
forall a s. a -> S a s
S (a -> S a s) -> a -> S a s
forall a b. (a -> b) -> a -> b
$ Proxy s -> a -> a -> a
forall k (s :: k) a (proxy :: k -> *). Reifies s a => proxy s -> a
reflect (Proxy s
forall k (t :: k). Proxy t
Proxy :: Proxy s) a
a a
b

-- | Strict Pair
data Pair' a b = Pair' !a !b deriving (Pair' a b -> Pair' a b -> Bool
(Pair' a b -> Pair' a b -> Bool)
-> (Pair' a b -> Pair' a b -> Bool) -> Eq (Pair' a b)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall a b. (Eq a, Eq b) => Pair' a b -> Pair' a b -> Bool
/= :: Pair' a b -> Pair' a b -> Bool
$c/= :: forall a b. (Eq a, Eq b) => Pair' a b -> Pair' a b -> Bool
== :: Pair' a b -> Pair' a b -> Bool
$c== :: forall a b. (Eq a, Eq b) => Pair' a b -> Pair' a b -> Bool
Eq,Eq (Pair' a b)
Eq (Pair' a b)
-> (Pair' a b -> Pair' a b -> Ordering)
-> (Pair' a b -> Pair' a b -> Bool)
-> (Pair' a b -> Pair' a b -> Bool)
-> (Pair' a b -> Pair' a b -> Bool)
-> (Pair' a b -> Pair' a b -> Bool)
-> (Pair' a b -> Pair' a b -> Pair' a b)
-> (Pair' a b -> Pair' a b -> Pair' a b)
-> Ord (Pair' a b)
Pair' a b -> Pair' a b -> Bool
Pair' a b -> Pair' a b -> Ordering
Pair' a b -> Pair' a b -> Pair' a b
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 a b. (Ord a, Ord b) => Eq (Pair' a b)
forall a b. (Ord a, Ord b) => Pair' a b -> Pair' a b -> Bool
forall a b. (Ord a, Ord b) => Pair' a b -> Pair' a b -> Ordering
forall a b. (Ord a, Ord b) => Pair' a b -> Pair' a b -> Pair' a b
min :: Pair' a b -> Pair' a b -> Pair' a b
$cmin :: forall a b. (Ord a, Ord b) => Pair' a b -> Pair' a b -> Pair' a b
max :: Pair' a b -> Pair' a b -> Pair' a b
$cmax :: forall a b. (Ord a, Ord b) => Pair' a b -> Pair' a b -> Pair' a b
>= :: Pair' a b -> Pair' a b -> Bool
$c>= :: forall a b. (Ord a, Ord b) => Pair' a b -> Pair' a b -> Bool
> :: Pair' a b -> Pair' a b -> Bool
$c> :: forall a b. (Ord a, Ord b) => Pair' a b -> Pair' a b -> Bool
<= :: Pair' a b -> Pair' a b -> Bool
$c<= :: forall a b. (Ord a, Ord b) => Pair' a b -> Pair' a b -> Bool
< :: Pair' a b -> Pair' a b -> Bool
$c< :: forall a b. (Ord a, Ord b) => Pair' a b -> Pair' a b -> Bool
compare :: Pair' a b -> Pair' a b -> Ordering
$ccompare :: forall a b. (Ord a, Ord b) => Pair' a b -> Pair' a b -> Ordering
$cp1Ord :: forall a b. (Ord a, Ord b) => Eq (Pair' a b)
Ord,Int -> Pair' a b -> ShowS
[Pair' a b] -> ShowS
Pair' a b -> String
(Int -> Pair' a b -> ShowS)
-> (Pair' a b -> String)
-> ([Pair' a b] -> ShowS)
-> Show (Pair' a b)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall a b. (Show a, Show b) => Int -> Pair' a b -> ShowS
forall a b. (Show a, Show b) => [Pair' a b] -> ShowS
forall a b. (Show a, Show b) => Pair' a b -> String
showList :: [Pair' a b] -> ShowS
$cshowList :: forall a b. (Show a, Show b) => [Pair' a b] -> ShowS
show :: Pair' a b -> String
$cshow :: forall a b. (Show a, Show b) => Pair' a b -> String
showsPrec :: Int -> Pair' a b -> ShowS
$cshowsPrec :: forall a b. (Show a, Show b) => Int -> Pair' a b -> ShowS
Show,ReadPrec [Pair' a b]
ReadPrec (Pair' a b)
Int -> ReadS (Pair' a b)
ReadS [Pair' a b]
(Int -> ReadS (Pair' a b))
-> ReadS [Pair' a b]
-> ReadPrec (Pair' a b)
-> ReadPrec [Pair' a b]
-> Read (Pair' a b)
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
forall a b. (Read a, Read b) => ReadPrec [Pair' a b]
forall a b. (Read a, Read b) => ReadPrec (Pair' a b)
forall a b. (Read a, Read b) => Int -> ReadS (Pair' a b)
forall a b. (Read a, Read b) => ReadS [Pair' a b]
readListPrec :: ReadPrec [Pair' a b]
$creadListPrec :: forall a b. (Read a, Read b) => ReadPrec [Pair' a b]
readPrec :: ReadPrec (Pair' a b)
$creadPrec :: forall a b. (Read a, Read b) => ReadPrec (Pair' a b)
readList :: ReadS [Pair' a b]
$creadList :: forall a b. (Read a, Read b) => ReadS [Pair' a b]
readsPrec :: Int -> ReadS (Pair' a b)
$creadsPrec :: forall a b. (Read a, Read b) => Int -> ReadS (Pair' a b)
Read,Typeable (Pair' a b)
DataType
Constr
Typeable (Pair' a b)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Pair' a b -> c (Pair' a b))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Pair' a b))
-> (Pair' a b -> Constr)
-> (Pair' a b -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (Pair' a b)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (Pair' a b)))
-> ((forall b. Data b => b -> b) -> Pair' a b -> Pair' a b)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Pair' a b -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Pair' a b -> r)
-> (forall u. (forall d. Data d => d -> u) -> Pair' a b -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> Pair' a b -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Pair' a b -> m (Pair' a b))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Pair' a b -> m (Pair' a b))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Pair' a b -> m (Pair' a b))
-> Data (Pair' a b)
Pair' a b -> DataType
Pair' a b -> Constr
(forall b. Data b => b -> b) -> Pair' a b -> Pair' a b
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Pair' a b -> c (Pair' a b)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Pair' a b)
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Pair' a b))
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 u. Int -> (forall d. Data d => d -> u) -> Pair' a b -> u
forall u. (forall d. Data d => d -> u) -> Pair' a b -> [u]
forall a b. (Data a, Data b) => Typeable (Pair' a b)
forall a b. (Data a, Data b) => Pair' a b -> DataType
forall a b. (Data a, Data b) => Pair' a b -> Constr
forall a b.
(Data a, Data b) =>
(forall b. Data b => b -> b) -> Pair' a b -> Pair' a b
forall a b u.
(Data a, Data b) =>
Int -> (forall d. Data d => d -> u) -> Pair' a b -> u
forall a b u.
(Data a, Data b) =>
(forall d. Data d => d -> u) -> Pair' a b -> [u]
forall a b r r'.
(Data a, Data b) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Pair' a b -> r
forall a b r r'.
(Data a, Data b) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Pair' a b -> r
forall a b (m :: * -> *).
(Data a, Data b, Monad m) =>
(forall d. Data d => d -> m d) -> Pair' a b -> m (Pair' a b)
forall a b (m :: * -> *).
(Data a, Data b, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Pair' a b -> m (Pair' a b)
forall a b (c :: * -> *).
(Data a, Data b) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Pair' a b)
forall a b (c :: * -> *).
(Data a, Data b) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Pair' a b -> c (Pair' a b)
forall a b (t :: * -> *) (c :: * -> *).
(Data a, Data b, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Pair' a b))
forall a b (t :: * -> * -> *) (c :: * -> *).
(Data a, Data b, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Pair' a b))
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Pair' a b -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Pair' a b -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Pair' a b -> m (Pair' a b)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Pair' a b -> m (Pair' a b)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Pair' a b)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Pair' a b -> c (Pair' a b)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Pair' a b))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Pair' a b))
$cPair' :: Constr
$tPair' :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Pair' a b -> m (Pair' a b)
$cgmapMo :: forall a b (m :: * -> *).
(Data a, Data b, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Pair' a b -> m (Pair' a b)
gmapMp :: (forall d. Data d => d -> m d) -> Pair' a b -> m (Pair' a b)
$cgmapMp :: forall a b (m :: * -> *).
(Data a, Data b, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Pair' a b -> m (Pair' a b)
gmapM :: (forall d. Data d => d -> m d) -> Pair' a b -> m (Pair' a b)
$cgmapM :: forall a b (m :: * -> *).
(Data a, Data b, Monad m) =>
(forall d. Data d => d -> m d) -> Pair' a b -> m (Pair' a b)
gmapQi :: Int -> (forall d. Data d => d -> u) -> Pair' a b -> u
$cgmapQi :: forall a b u.
(Data a, Data b) =>
Int -> (forall d. Data d => d -> u) -> Pair' a b -> u
gmapQ :: (forall d. Data d => d -> u) -> Pair' a b -> [u]
$cgmapQ :: forall a b u.
(Data a, Data b) =>
(forall d. Data d => d -> u) -> Pair' a b -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Pair' a b -> r
$cgmapQr :: forall a b r r'.
(Data a, Data b) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Pair' a b -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Pair' a b -> r
$cgmapQl :: forall a b r r'.
(Data a, Data b) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Pair' a b -> r
gmapT :: (forall b. Data b => b -> b) -> Pair' a b -> Pair' a b
$cgmapT :: forall a b.
(Data a, Data b) =>
(forall b. Data b => b -> b) -> Pair' a b -> Pair' a b
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Pair' a b))
$cdataCast2 :: forall a b (t :: * -> * -> *) (c :: * -> *).
(Data a, Data b, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Pair' a b))
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c (Pair' a b))
$cdataCast1 :: forall a b (t :: * -> *) (c :: * -> *).
(Data a, Data b, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Pair' a b))
dataTypeOf :: Pair' a b -> DataType
$cdataTypeOf :: forall a b. (Data a, Data b) => Pair' a b -> DataType
toConstr :: Pair' a b -> Constr
$ctoConstr :: forall a b. (Data a, Data b) => Pair' a b -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Pair' a b)
$cgunfold :: forall a b (c :: * -> *).
(Data a, Data b) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Pair' a b)
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Pair' a b -> c (Pair' a b)
$cgfoldl :: forall a b (c :: * -> *).
(Data a, Data b) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Pair' a b -> c (Pair' a b)
$cp1Data :: forall a b. (Data a, Data b) => Typeable (Pair' a b)
Data)

instance (Semigroup a, Semigroup b) => Semigroup (Pair' a b) where
  Pair' a
a b
b <> :: Pair' a b -> Pair' a b -> Pair' a b
<> Pair' a
c b
d = a -> b -> Pair' a b
forall a b. a -> b -> Pair' a b
Pair' (a
a a -> a -> a
forall a. Semigroup a => a -> a -> a
<> a
c) (b
b b -> b -> b
forall a. Semigroup a => a -> a -> a
<> b
d)
  {-# INLINE (<>) #-}

instance (Monoid a, Monoid b) => Monoid (Pair' a b) where
  mempty :: Pair' a b
mempty = a -> b -> Pair' a b
forall a b. a -> b -> Pair' a b
Pair' a
forall a. Monoid a => a
mempty b
forall a. Monoid a => a
mempty
  {-# INLINE mempty #-}

#if !(MIN_VERSION_base(4,11,0))
  mappend (Pair' a b) (Pair' c d) = Pair' (mappend a c) (mappend b d)
  {-# INLINE mappend #-}
#endif

newtype An a = An a deriving (An a -> An a -> Bool
(An a -> An a -> Bool) -> (An a -> An a -> Bool) -> Eq (An a)
forall a. Eq a => An a -> An a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: An a -> An a -> Bool
$c/= :: forall a. Eq a => An a -> An a -> Bool
== :: An a -> An a -> Bool
$c== :: forall a. Eq a => An a -> An a -> Bool
Eq,Eq (An a)
Eq (An a)
-> (An a -> An a -> Ordering)
-> (An a -> An a -> Bool)
-> (An a -> An a -> Bool)
-> (An a -> An a -> Bool)
-> (An a -> An a -> Bool)
-> (An a -> An a -> An a)
-> (An a -> An a -> An a)
-> Ord (An a)
An a -> An a -> Bool
An a -> An a -> Ordering
An a -> An a -> An 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 a. Ord a => Eq (An a)
forall a. Ord a => An a -> An a -> Bool
forall a. Ord a => An a -> An a -> Ordering
forall a. Ord a => An a -> An a -> An a
min :: An a -> An a -> An a
$cmin :: forall a. Ord a => An a -> An a -> An a
max :: An a -> An a -> An a
$cmax :: forall a. Ord a => An a -> An a -> An a
>= :: An a -> An a -> Bool
$c>= :: forall a. Ord a => An a -> An a -> Bool
> :: An a -> An a -> Bool
$c> :: forall a. Ord a => An a -> An a -> Bool
<= :: An a -> An a -> Bool
$c<= :: forall a. Ord a => An a -> An a -> Bool
< :: An a -> An a -> Bool
$c< :: forall a. Ord a => An a -> An a -> Bool
compare :: An a -> An a -> Ordering
$ccompare :: forall a. Ord a => An a -> An a -> Ordering
$cp1Ord :: forall a. Ord a => Eq (An a)
Ord,Int -> An a -> ShowS
[An a] -> ShowS
An a -> String
(Int -> An a -> ShowS)
-> (An a -> String) -> ([An a] -> ShowS) -> Show (An a)
forall a. Show a => Int -> An a -> ShowS
forall a. Show a => [An a] -> ShowS
forall a. Show a => An a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [An a] -> ShowS
$cshowList :: forall a. Show a => [An a] -> ShowS
show :: An a -> String
$cshow :: forall a. Show a => An a -> String
showsPrec :: Int -> An a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> An a -> ShowS
Show,ReadPrec [An a]
ReadPrec (An a)
Int -> ReadS (An a)
ReadS [An a]
(Int -> ReadS (An a))
-> ReadS [An a]
-> ReadPrec (An a)
-> ReadPrec [An a]
-> Read (An a)
forall a. Read a => ReadPrec [An a]
forall a. Read a => ReadPrec (An a)
forall a. Read a => Int -> ReadS (An a)
forall a. Read a => ReadS [An a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [An a]
$creadListPrec :: forall a. Read a => ReadPrec [An a]
readPrec :: ReadPrec (An a)
$creadPrec :: forall a. Read a => ReadPrec (An a)
readList :: ReadS [An a]
$creadList :: forall a. Read a => ReadS [An a]
readsPrec :: Int -> ReadS (An a)
$creadsPrec :: forall a. Read a => Int -> ReadS (An a)
Read,Typeable (An a)
DataType
Constr
Typeable (An a)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> An a -> c (An a))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (An a))
-> (An a -> Constr)
-> (An a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (An a)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (An a)))
-> ((forall b. Data b => b -> b) -> An a -> An a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> An a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> An a -> r)
-> (forall u. (forall d. Data d => d -> u) -> An a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> An a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> An a -> m (An a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> An a -> m (An a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> An a -> m (An a))
-> Data (An a)
An a -> DataType
An a -> Constr
(forall d. Data d => c (t d)) -> Maybe (c (An a))
(forall b. Data b => b -> b) -> An a -> An a
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> An a -> c (An a)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (An a)
forall a. Data a => Typeable (An a)
forall a. Data a => An a -> DataType
forall a. Data a => An a -> Constr
forall a. Data a => (forall b. Data b => b -> b) -> An a -> An a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> An a -> u
forall a u. Data a => (forall d. Data d => d -> u) -> An a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> An a -> r
forall a r r'.
Data a =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> An a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> An a -> m (An a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> An a -> m (An a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (An a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> An a -> c (An a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (An a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (An a))
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 u. Int -> (forall d. Data d => d -> u) -> An a -> u
forall u. (forall d. Data d => d -> u) -> An a -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> An a -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> An a -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> An a -> m (An a)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> An a -> m (An a)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (An a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> An a -> c (An a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (An a))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (An a))
$cAn :: Constr
$tAn :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> An a -> m (An a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> An a -> m (An a)
gmapMp :: (forall d. Data d => d -> m d) -> An a -> m (An a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> An a -> m (An a)
gmapM :: (forall d. Data d => d -> m d) -> An a -> m (An a)
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> An a -> m (An a)
gmapQi :: Int -> (forall d. Data d => d -> u) -> An a -> u
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> An a -> u
gmapQ :: (forall d. Data d => d -> u) -> An a -> [u]
$cgmapQ :: forall a u. Data a => (forall d. Data d => d -> u) -> An a -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> An a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> An a -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> An a -> r
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> An a -> r
gmapT :: (forall b. Data b => b -> b) -> An a -> An a
$cgmapT :: forall a. Data a => (forall b. Data b => b -> b) -> An a -> An a
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (An a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (An a))
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c (An a))
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (An a))
dataTypeOf :: An a -> DataType
$cdataTypeOf :: forall a. Data a => An a -> DataType
toConstr :: An a -> Constr
$ctoConstr :: forall a. Data a => An a -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (An a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (An a)
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> An a -> c (An a)
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> An a -> c (An a)
$cp1Data :: forall a. Data a => Typeable (An a)
Data)

instance Functor An where
  fmap :: (a -> b) -> An a -> An b
fmap a -> b
f (An a
a) = b -> An b
forall a. a -> An a
An (a -> b
f a
a)

instance Foldable An where
  foldMap :: (a -> m) -> An a -> m
foldMap a -> m
f (An a
a) = a -> m
f a
a

instance Traversable An where
  traverse :: (a -> f b) -> An a -> f (An b)
traverse a -> f b
f (An a
a) = b -> An b
forall a. a -> An a
An (b -> An b) -> f b -> f (An b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f b
f a
a

data Box a = Box a deriving (Box a -> Box a -> Bool
(Box a -> Box a -> Bool) -> (Box a -> Box a -> Bool) -> Eq (Box a)
forall a. Eq a => Box a -> Box a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Box a -> Box a -> Bool
$c/= :: forall a. Eq a => Box a -> Box a -> Bool
== :: Box a -> Box a -> Bool
$c== :: forall a. Eq a => Box a -> Box a -> Bool
Eq,Eq (Box a)
Eq (Box a)
-> (Box a -> Box a -> Ordering)
-> (Box a -> Box a -> Bool)
-> (Box a -> Box a -> Bool)
-> (Box a -> Box a -> Bool)
-> (Box a -> Box a -> Bool)
-> (Box a -> Box a -> Box a)
-> (Box a -> Box a -> Box a)
-> Ord (Box a)
Box a -> Box a -> Bool
Box a -> Box a -> Ordering
Box a -> Box a -> Box 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 a. Ord a => Eq (Box a)
forall a. Ord a => Box a -> Box a -> Bool
forall a. Ord a => Box a -> Box a -> Ordering
forall a. Ord a => Box a -> Box a -> Box a
min :: Box a -> Box a -> Box a
$cmin :: forall a. Ord a => Box a -> Box a -> Box a
max :: Box a -> Box a -> Box a
$cmax :: forall a. Ord a => Box a -> Box a -> Box a
>= :: Box a -> Box a -> Bool
$c>= :: forall a. Ord a => Box a -> Box a -> Bool
> :: Box a -> Box a -> Bool
$c> :: forall a. Ord a => Box a -> Box a -> Bool
<= :: Box a -> Box a -> Bool
$c<= :: forall a. Ord a => Box a -> Box a -> Bool
< :: Box a -> Box a -> Bool
$c< :: forall a. Ord a => Box a -> Box a -> Bool
compare :: Box a -> Box a -> Ordering
$ccompare :: forall a. Ord a => Box a -> Box a -> Ordering
$cp1Ord :: forall a. Ord a => Eq (Box a)
Ord,Int -> Box a -> ShowS
[Box a] -> ShowS
Box a -> String
(Int -> Box a -> ShowS)
-> (Box a -> String) -> ([Box a] -> ShowS) -> Show (Box a)
forall a. Show a => Int -> Box a -> ShowS
forall a. Show a => [Box a] -> ShowS
forall a. Show a => Box a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Box a] -> ShowS
$cshowList :: forall a. Show a => [Box a] -> ShowS
show :: Box a -> String
$cshow :: forall a. Show a => Box a -> String
showsPrec :: Int -> Box a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> Box a -> ShowS
Show,ReadPrec [Box a]
ReadPrec (Box a)
Int -> ReadS (Box a)
ReadS [Box a]
(Int -> ReadS (Box a))
-> ReadS [Box a]
-> ReadPrec (Box a)
-> ReadPrec [Box a]
-> Read (Box a)
forall a. Read a => ReadPrec [Box a]
forall a. Read a => ReadPrec (Box a)
forall a. Read a => Int -> ReadS (Box a)
forall a. Read a => ReadS [Box a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Box a]
$creadListPrec :: forall a. Read a => ReadPrec [Box a]
readPrec :: ReadPrec (Box a)
$creadPrec :: forall a. Read a => ReadPrec (Box a)
readList :: ReadS [Box a]
$creadList :: forall a. Read a => ReadS [Box a]
readsPrec :: Int -> ReadS (Box a)
$creadsPrec :: forall a. Read a => Int -> ReadS (Box a)
Read,Typeable (Box a)
DataType
Constr
Typeable (Box a)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Box a -> c (Box a))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Box a))
-> (Box a -> Constr)
-> (Box a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (Box a)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Box a)))
-> ((forall b. Data b => b -> b) -> Box a -> Box a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Box a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Box a -> r)
-> (forall u. (forall d. Data d => d -> u) -> Box a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Box a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Box a -> m (Box a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Box a -> m (Box a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Box a -> m (Box a))
-> Data (Box a)
Box a -> DataType
Box a -> Constr
(forall d. Data d => c (t d)) -> Maybe (c (Box a))
(forall b. Data b => b -> b) -> Box a -> Box a
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Box a -> c (Box a)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Box a)
forall a. Data a => Typeable (Box a)
forall a. Data a => Box a -> DataType
forall a. Data a => Box a -> Constr
forall a. Data a => (forall b. Data b => b -> b) -> Box a -> Box a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Box a -> u
forall a u. Data a => (forall d. Data d => d -> u) -> Box a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Box a -> r
forall a r r'.
Data a =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Box a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Box a -> m (Box a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Box a -> m (Box a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Box a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Box a -> c (Box a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Box a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Box a))
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 u. Int -> (forall d. Data d => d -> u) -> Box a -> u
forall u. (forall d. Data d => d -> u) -> Box a -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Box a -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Box a -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Box a -> m (Box a)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Box a -> m (Box a)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Box a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Box a -> c (Box a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Box a))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Box a))
$cBox :: Constr
$tBox :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Box a -> m (Box a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Box a -> m (Box a)
gmapMp :: (forall d. Data d => d -> m d) -> Box a -> m (Box a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Box a -> m (Box a)
gmapM :: (forall d. Data d => d -> m d) -> Box a -> m (Box a)
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Box a -> m (Box a)
gmapQi :: Int -> (forall d. Data d => d -> u) -> Box a -> u
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Box a -> u
gmapQ :: (forall d. Data d => d -> u) -> Box a -> [u]
$cgmapQ :: forall a u. Data a => (forall d. Data d => d -> u) -> Box a -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Box a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Box a -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Box a -> r
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Box a -> r
gmapT :: (forall b. Data b => b -> b) -> Box a -> Box a
$cgmapT :: forall a. Data a => (forall b. Data b => b -> b) -> Box a -> Box a
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Box a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Box a))
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c (Box a))
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Box a))
dataTypeOf :: Box a -> DataType
$cdataTypeOf :: forall a. Data a => Box a -> DataType
toConstr :: Box a -> Constr
$ctoConstr :: forall a. Data a => Box a -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Box a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Box a)
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Box a -> c (Box a)
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Box a -> c (Box a)
$cp1Data :: forall a. Data a => Typeable (Box a)
Data)

instance Functor Box where
  fmap :: (a -> b) -> Box a -> Box b
fmap a -> b
f (Box a
a) = b -> Box b
forall a. a -> Box a
Box (a -> b
f a
a)

instance Foldable Box where
  foldMap :: (a -> m) -> Box a -> m
foldMap a -> m
f (Box a
a) = a -> m
f a
a

instance Traversable Box where
  traverse :: (a -> f b) -> Box a -> f (Box b)
traverse a -> f b
f (Box a
a) = b -> Box b
forall a. a -> Box a
Box (b -> Box b) -> f b -> f (Box b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f b
f a
a

data List1 a = Cons1 a (List1 a) | Last a

instance Functor List1 where
  fmap :: (a -> b) -> List1 a -> List1 b
fmap a -> b
f (Cons1 a
a List1 a
as) = b -> List1 b -> List1 b
forall a. a -> List1 a -> List1 a
Cons1 (a -> b
f a
a) ((a -> b) -> List1 a -> List1 b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f List1 a
as)
  fmap a -> b
f (Last a
a) = b -> List1 b
forall a. a -> List1 a
Last (a -> b
f a
a)

instance Foldable List1 where
  foldMap :: (a -> m) -> List1 a -> m
foldMap a -> m
f = List1 a -> m
go where
    go :: List1 a -> m
go (Cons1 a
a List1 a
as) = a -> m
f a
a m -> m -> m
forall a. Monoid a => a -> a -> a
`mappend` (a -> m) -> List1 a -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap a -> m
f List1 a
as
    go (Last a
a) = a -> m
f a
a
  {-# INLINE foldMap #-}

  foldr :: (a -> b -> b) -> b -> List1 a -> b
foldr a -> b -> b
f b
z = List1 a -> b
go where
    go :: List1 a -> b
go (Cons1 a
a List1 a
as) = a -> b -> b
f a
a (List1 a -> b
go List1 a
as)
    go (Last a
a) = a -> b -> b
f a
a b
z
  {-# INLINE foldr #-}

  foldr1 :: (a -> a -> a) -> List1 a -> a
foldr1 a -> a -> a
f = List1 a -> a
go where
    go :: List1 a -> a
go (Cons1 a
a List1 a
as) = a -> a -> a
f a
a (List1 a -> a
go List1 a
as)
    go (Last a
a)     = a
a
  {-# INLINE foldr1 #-}

instance Traversable List1 where
  traverse :: (a -> f b) -> List1 a -> f (List1 b)
traverse a -> f b
f (Cons1 a
a List1 a
as) = b -> List1 b -> List1 b
forall a. a -> List1 a -> List1 a
Cons1 (b -> List1 b -> List1 b) -> f b -> f (List1 b -> List1 b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f b
f a
a f (List1 b -> List1 b) -> f (List1 b) -> f (List1 b)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (a -> f b) -> List1 a -> f (List1 b)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse a -> f b
f List1 a
as
  traverse a -> f b
f (Last a
a) = b -> List1 b
forall a. a -> List1 a
Last (b -> List1 b) -> f b -> f (List1 b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f b
f a
a
  {-# INLINABLE traverse #-}

data Tree1 a = Bin1 (Tree1 a) (Tree1 a) | Tip1 a

instance Functor Tree1 where
  fmap :: (a -> b) -> Tree1 a -> Tree1 b
fmap a -> b
f (Bin1 Tree1 a
as Tree1 a
bs) = Tree1 b -> Tree1 b -> Tree1 b
forall a. Tree1 a -> Tree1 a -> Tree1 a
Bin1 ((a -> b) -> Tree1 a -> Tree1 b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Tree1 a
as) ((a -> b) -> Tree1 a -> Tree1 b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f Tree1 a
bs)
  fmap a -> b
f (Tip1 a
a) = b -> Tree1 b
forall a. a -> Tree1 a
Tip1 (a -> b
f a
a)

instance Foldable Tree1 where
  foldMap :: (a -> m) -> Tree1 a -> m
foldMap a -> m
f (Bin1 Tree1 a
as Tree1 a
bs) = (a -> m) -> Tree1 a -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap a -> m
f Tree1 a
as m -> m -> m
forall a. Monoid a => a -> a -> a
`mappend` (a -> m) -> Tree1 a -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap a -> m
f Tree1 a
bs
  foldMap a -> m
f (Tip1 a
a) = a -> m
f a
a

instance Traversable Tree1 where
  traverse :: (a -> f b) -> Tree1 a -> f (Tree1 b)
traverse a -> f b
f (Bin1 Tree1 a
as Tree1 a
bs) = Tree1 b -> Tree1 b -> Tree1 b
forall a. Tree1 a -> Tree1 a -> Tree1 a
Bin1 (Tree1 b -> Tree1 b -> Tree1 b)
-> f (Tree1 b) -> f (Tree1 b -> Tree1 b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> f b) -> Tree1 a -> f (Tree1 b)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse a -> f b
f Tree1 a
as f (Tree1 b -> Tree1 b) -> f (Tree1 b) -> f (Tree1 b)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (a -> f b) -> Tree1 a -> f (Tree1 b)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse a -> f b
f Tree1 a
bs
  traverse a -> f b
f (Tip1 a
a) = b -> Tree1 b
forall a. a -> Tree1 a
Tip1 (b -> Tree1 b) -> f b -> f (Tree1 b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f b
f a
a

newtype FreeMonoid a = FreeMonoid { FreeMonoid a -> forall m. Monoid m => (a -> m) -> m
runFreeMonoid :: forall m. Monoid m => (a -> m) -> m } deriving a -> FreeMonoid b -> FreeMonoid a
(a -> b) -> FreeMonoid a -> FreeMonoid b
(forall a b. (a -> b) -> FreeMonoid a -> FreeMonoid b)
-> (forall a b. a -> FreeMonoid b -> FreeMonoid a)
-> Functor FreeMonoid
forall a b. a -> FreeMonoid b -> FreeMonoid a
forall a b. (a -> b) -> FreeMonoid a -> FreeMonoid b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> FreeMonoid b -> FreeMonoid a
$c<$ :: forall a b. a -> FreeMonoid b -> FreeMonoid a
fmap :: (a -> b) -> FreeMonoid a -> FreeMonoid b
$cfmap :: forall a b. (a -> b) -> FreeMonoid a -> FreeMonoid b
Functor

instance Foldable FreeMonoid where
  foldMap :: (a -> m) -> FreeMonoid a -> m
foldMap a -> m
f FreeMonoid a
m = FreeMonoid a -> (a -> m) -> m
forall a. FreeMonoid a -> forall m. Monoid m => (a -> m) -> m
runFreeMonoid FreeMonoid a
m a -> m
f

newtype FreeSemigroup a = FreeSemigroup { FreeSemigroup a -> forall m. Semigroup m => (a -> m) -> m
runFreeSemigroup :: forall m. Semigroup m => (a -> m) -> m } deriving a -> FreeSemigroup b -> FreeSemigroup a
(a -> b) -> FreeSemigroup a -> FreeSemigroup b
(forall a b. (a -> b) -> FreeSemigroup a -> FreeSemigroup b)
-> (forall a b. a -> FreeSemigroup b -> FreeSemigroup a)
-> Functor FreeSemigroup
forall a b. a -> FreeSemigroup b -> FreeSemigroup a
forall a b. (a -> b) -> FreeSemigroup a -> FreeSemigroup b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> FreeSemigroup b -> FreeSemigroup a
$c<$ :: forall a b. a -> FreeSemigroup b -> FreeSemigroup a
fmap :: (a -> b) -> FreeSemigroup a -> FreeSemigroup b
$cfmap :: forall a b. (a -> b) -> FreeSemigroup a -> FreeSemigroup b
Functor

instance Foldable FreeSemigroup where
  foldMap :: (a -> m) -> FreeSemigroup a -> m
foldMap a -> m
f (FreeSemigroup forall m. Semigroup m => (a -> m) -> m
m) = WrappedMonoid m -> m
forall m. WrappedMonoid m -> m
unwrapMonoid (WrappedMonoid m -> m) -> WrappedMonoid m -> m
forall a b. (a -> b) -> a -> b
$ (a -> WrappedMonoid m) -> WrappedMonoid m
forall m. Semigroup m => (a -> m) -> m
m (m -> WrappedMonoid m
forall m. m -> WrappedMonoid m
WrapMonoid (m -> WrappedMonoid m) -> (a -> m) -> a -> WrappedMonoid m
forall (p :: * -> * -> *) a b c (q :: * -> * -> *).
(Profunctor p, Coercible c b) =>
q b c -> p a b -> p a c
#. a -> m
f)

instance Foldable1 FreeSemigroup where
  foldMap1 :: (a -> m) -> FreeSemigroup a -> m
foldMap1 a -> m
f (FreeSemigroup forall m. Semigroup m => (a -> m) -> m
m) = (a -> m) -> m
forall m. Semigroup m => (a -> m) -> m
m a -> m
f

data T a b = T0 | T1 a | T2 b b deriving (a -> T a b -> T a a
(a -> b) -> T a a -> T a b
(forall a b. (a -> b) -> T a a -> T a b)
-> (forall a b. a -> T a b -> T a a) -> Functor (T a)
forall a b. a -> T a b -> T a a
forall a b. (a -> b) -> T a a -> T a b
forall a a b. a -> T a b -> T a a
forall a a b. (a -> b) -> T a a -> T a b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> T a b -> T a a
$c<$ :: forall a a b. a -> T a b -> T a a
fmap :: (a -> b) -> T a a -> T a b
$cfmap :: forall a a b. (a -> b) -> T a a -> T a b
Functor, T a a -> Bool
(a -> m) -> T a a -> m
(a -> b -> b) -> b -> T a a -> b
(forall m. Monoid m => T a m -> m)
-> (forall m a. Monoid m => (a -> m) -> T a a -> m)
-> (forall m a. Monoid m => (a -> m) -> T a a -> m)
-> (forall a b. (a -> b -> b) -> b -> T a a -> b)
-> (forall a b. (a -> b -> b) -> b -> T a a -> b)
-> (forall b a. (b -> a -> b) -> b -> T a a -> b)
-> (forall b a. (b -> a -> b) -> b -> T a a -> b)
-> (forall a. (a -> a -> a) -> T a a -> a)
-> (forall a. (a -> a -> a) -> T a a -> a)
-> (forall a. T a a -> [a])
-> (forall a. T a a -> Bool)
-> (forall a. T a a -> Int)
-> (forall a. Eq a => a -> T a a -> Bool)
-> (forall a. Ord a => T a a -> a)
-> (forall a. Ord a => T a a -> a)
-> (forall a. Num a => T a a -> a)
-> (forall a. Num a => T a a -> a)
-> Foldable (T a)
forall a. Eq a => a -> T a a -> Bool
forall a. Num a => T a a -> a
forall a. Ord a => T a a -> a
forall m. Monoid m => T a m -> m
forall a. T a a -> Bool
forall a. T a a -> Int
forall a. T a a -> [a]
forall a. (a -> a -> a) -> T a a -> a
forall a a. Eq a => a -> T a a -> Bool
forall a a. Num a => T a a -> a
forall a a. Ord a => T a a -> a
forall m a. Monoid m => (a -> m) -> T a a -> m
forall a m. Monoid m => T a m -> m
forall a a. T a a -> Bool
forall a a. T a a -> Int
forall a a. T a a -> [a]
forall b a. (b -> a -> b) -> b -> T a a -> b
forall a b. (a -> b -> b) -> b -> T a a -> b
forall a a. (a -> a -> a) -> T a a -> a
forall a m a. Monoid m => (a -> m) -> T a a -> m
forall a b a. (b -> a -> b) -> b -> T a a -> b
forall a a b. (a -> b -> b) -> b -> T a 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 :: T a a -> a
$cproduct :: forall a a. Num a => T a a -> a
sum :: T a a -> a
$csum :: forall a a. Num a => T a a -> a
minimum :: T a a -> a
$cminimum :: forall a a. Ord a => T a a -> a
maximum :: T a a -> a
$cmaximum :: forall a a. Ord a => T a a -> a
elem :: a -> T a a -> Bool
$celem :: forall a a. Eq a => a -> T a a -> Bool
length :: T a a -> Int
$clength :: forall a a. T a a -> Int
null :: T a a -> Bool
$cnull :: forall a a. T a a -> Bool
toList :: T a a -> [a]
$ctoList :: forall a a. T a a -> [a]
foldl1 :: (a -> a -> a) -> T a a -> a
$cfoldl1 :: forall a a. (a -> a -> a) -> T a a -> a
foldr1 :: (a -> a -> a) -> T a a -> a
$cfoldr1 :: forall a a. (a -> a -> a) -> T a a -> a
foldl' :: (b -> a -> b) -> b -> T a a -> b
$cfoldl' :: forall a b a. (b -> a -> b) -> b -> T a a -> b
foldl :: (b -> a -> b) -> b -> T a a -> b
$cfoldl :: forall a b a. (b -> a -> b) -> b -> T a a -> b
foldr' :: (a -> b -> b) -> b -> T a a -> b
$cfoldr' :: forall a a b. (a -> b -> b) -> b -> T a a -> b
foldr :: (a -> b -> b) -> b -> T a a -> b
$cfoldr :: forall a a b. (a -> b -> b) -> b -> T a a -> b
foldMap' :: (a -> m) -> T a a -> m
$cfoldMap' :: forall a m a. Monoid m => (a -> m) -> T a a -> m
foldMap :: (a -> m) -> T a a -> m
$cfoldMap :: forall a m a. Monoid m => (a -> m) -> T a a -> m
fold :: T a m -> m
$cfold :: forall a m. Monoid m => T a m -> m
Foldable, Functor (T a)
Foldable (T a)
Functor (T a)
-> Foldable (T a)
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> T a a -> f (T a b))
-> (forall (f :: * -> *) a.
    Applicative f =>
    T a (f a) -> f (T a a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> T a a -> m (T a b))
-> (forall (m :: * -> *) a. Monad m => T a (m a) -> m (T a a))
-> Traversable (T a)
(a -> f b) -> T a a -> f (T a b)
forall a. Functor (T a)
forall a. Foldable (T a)
forall a (m :: * -> *) a. Monad m => T a (m a) -> m (T a a)
forall a (f :: * -> *) a. Applicative f => T a (f a) -> f (T a a)
forall a (m :: * -> *) a b.
Monad m =>
(a -> m b) -> T a a -> m (T a b)
forall a (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> T a a -> f (T a 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 (m :: * -> *) a. Monad m => T a (m a) -> m (T a a)
forall (f :: * -> *) a. Applicative f => T a (f a) -> f (T a a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> T a a -> m (T a b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> T a a -> f (T a b)
sequence :: T a (m a) -> m (T a a)
$csequence :: forall a (m :: * -> *) a. Monad m => T a (m a) -> m (T a a)
mapM :: (a -> m b) -> T a a -> m (T a b)
$cmapM :: forall a (m :: * -> *) a b.
Monad m =>
(a -> m b) -> T a a -> m (T a b)
sequenceA :: T a (f a) -> f (T a a)
$csequenceA :: forall a (f :: * -> *) a. Applicative f => T a (f a) -> f (T a a)
traverse :: (a -> f b) -> T a a -> f (T a b)
$ctraverse :: forall a (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> T a a -> f (T a b)
$cp2Traversable :: forall a. Foldable (T a)
$cp1Traversable :: forall a. Functor (T a)
Traversable)

instance MuRef (Tree a) where
  type DeRef (Tree a) = T a
  mapDeRef :: (forall b. (MuRef b, DeRef (Tree a) ~ DeRef b) => b -> f u)
-> Tree a -> f (DeRef (Tree a) u)
mapDeRef forall b. (MuRef b, DeRef (Tree a) ~ DeRef b) => b -> f u
_ Tree a
Zero    = T a u -> f (T a u)
forall (f :: * -> *) a. Applicative f => a -> f a
pure T a u
forall a b. T a b
T0
  mapDeRef forall b. (MuRef b, DeRef (Tree a) ~ DeRef b) => b -> f u
_ (One a
a) = T a u -> f (T a u)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (a -> T a u
forall a b. a -> T a b
T1 a
a)
  mapDeRef forall b. (MuRef b, DeRef (Tree a) ~ DeRef b) => b -> f u
f (Two Tree a
x Tree a
y) = u -> u -> T a u
forall a b. b -> b -> T a b
T2 (u -> u -> T a u) -> f u -> f (u -> T a u)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Tree a -> f u
forall b. (MuRef b, DeRef (Tree a) ~ DeRef b) => b -> f u
f Tree a
x f (u -> T a u) -> f u -> f (T a u)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Tree a -> f u
forall b. (MuRef b, DeRef (Tree a) ~ DeRef b) => b -> f u
f Tree a
y

class MuRef1 (f :: Type -> Type) where
  type DeRef1 f :: Type -> Type -> Type
  muRef1 :: proxy (f a) -> Dict (MuRef (f a), DeRef (f a) ~ DeRef1 f a)

foldDeRef :: forall f a. (MuRef1 f, Bifoldable (DeRef1 f)) => f a -> FreeMonoid a
foldDeRef :: f a -> FreeMonoid a
foldDeRef f a
m = case Proxy (f a) -> Dict (MuRef (f a), DeRef (f a) ~ DeRef1 f a)
forall (f :: * -> *) (proxy :: * -> *) a.
MuRef1 f =>
proxy (f a) -> Dict (MuRef (f a), DeRef (f a) ~ DeRef1 f a)
muRef1 (Proxy (f a)
forall a. HasCallStack => a
undefined :: Proxy (f a)) of
  Dict (MuRef (f a), DeRef (f a) ~ DeRef1 f a)
Dict -> case IO (Graph (DeRef1 f a)) -> Graph (DeRef1 f a)
forall a. IO a -> a
unsafePerformIO (f a -> IO (Graph (DeRef (f a)))
forall s. MuRef s => s -> IO (Graph (DeRef s))
reifyGraph f a
m) of
    Graph [(Int, DeRef1 f a Int)]
xs Int
i | HashMap Int (DeRef1 f a Int)
hm <- [(Int, DeRef1 f a Int)] -> HashMap Int (DeRef1 f a Int)
forall k v. (Eq k, Hashable k) => [(k, v)] -> HashMap k v
HM.fromList [(Int, DeRef1 f a Int)]
xs -> (forall m. Monoid m => (a -> m) -> m) -> FreeMonoid a
forall a. (forall m. Monoid m => (a -> m) -> m) -> FreeMonoid a
FreeMonoid ((forall m. Monoid m => (a -> m) -> m) -> FreeMonoid a)
-> (forall m. Monoid m => (a -> m) -> m) -> FreeMonoid a
forall a b. (a -> b) -> a -> b
$ \ a -> m
f -> (HashMap Int m -> HashMap Int m) -> HashMap Int m
forall a. (a -> a) -> a
fix (\HashMap Int m
mm -> (DeRef1 f a Int -> m)
-> HashMap Int (DeRef1 f a Int) -> HashMap Int m
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((a -> m) -> (Int -> m) -> DeRef1 f a Int -> m
forall (p :: * -> * -> *) m a b.
(Bifoldable p, Monoid m) =>
(a -> m) -> (b -> m) -> p a b -> m
bifoldMap a -> m
f (HashMap Int m
mm HashMap Int m -> Int -> m
forall k v.
(Eq k, Hashable k, HasCallStack) =>
HashMap k v -> k -> v
!)) HashMap Int (DeRef1 f a Int)
hm) HashMap Int m -> Int -> m
forall k v.
(Eq k, Hashable k, HasCallStack) =>
HashMap k v -> k -> v
! Int
i

instance MuRef1 Tree where
  type DeRef1 Tree = T
  muRef1 :: proxy (Tree a)
-> Dict (MuRef (Tree a), DeRef (Tree a) ~ DeRef1 Tree a)
muRef1 proxy (Tree a)
_ = Dict (MuRef (Tree a), DeRef (Tree a) ~ DeRef1 Tree a)
forall (a :: Constraint). a => Dict a
Dict

instance Bifunctor T where
  bimap :: (a -> b) -> (c -> d) -> T a c -> T b d
bimap a -> b
_ c -> d
_ T a c
T0 = T b d
forall a b. T a b
T0
  bimap a -> b
f c -> d
_ (T1 a
a) = b -> T b d
forall a b. a -> T a b
T1 (a -> b
f a
a)
  bimap a -> b
_ c -> d
g (T2 c
b c
c) = d -> d -> T b d
forall a b. b -> b -> T a b
T2 (c -> d
g c
b) (c -> d
g c
c)

instance Bifoldable T where
  bifoldMap :: (a -> m) -> (b -> m) -> T a b -> m
bifoldMap a -> m
_ b -> m
_ T a b
T0 = m
forall a. Monoid a => a
mempty
  bifoldMap a -> m
f b -> m
_ (T1 a
a) = a -> m
f a
a
  bifoldMap a -> m
_ b -> m
g (T2 b
b b
c) = b -> m
g b
b m -> m -> m
forall a. Monoid a => a -> a -> a
`mappend` b -> m
g b
c

instance Bitraversable T where
  bitraverse :: (a -> f c) -> (b -> f d) -> T a b -> f (T c d)
bitraverse a -> f c
_ b -> f d
_ T a b
T0 = T c d -> f (T c d)
forall (f :: * -> *) a. Applicative f => a -> f a
pure T c d
forall a b. T a b
T0
  bitraverse a -> f c
f b -> f d
_ (T1 a
a) = c -> T c d
forall a b. a -> T a b
T1 (c -> T c d) -> f c -> f (T c d)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f c
f a
a
  bitraverse a -> f c
_ b -> f d
g (T2 b
b b
c) = d -> d -> T c d
forall a b. b -> b -> T a b
T2 (d -> d -> T c d) -> f d -> f (d -> T c d)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> b -> f d
g b
b f (d -> T c d) -> f d -> f (T c d)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> b -> f d
g b
c

data T1 a b = A a | B b b deriving (a -> T1 a b -> T1 a a
(a -> b) -> T1 a a -> T1 a b
(forall a b. (a -> b) -> T1 a a -> T1 a b)
-> (forall a b. a -> T1 a b -> T1 a a) -> Functor (T1 a)
forall a b. a -> T1 a b -> T1 a a
forall a b. (a -> b) -> T1 a a -> T1 a b
forall a a b. a -> T1 a b -> T1 a a
forall a a b. (a -> b) -> T1 a a -> T1 a b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> T1 a b -> T1 a a
$c<$ :: forall a a b. a -> T1 a b -> T1 a a
fmap :: (a -> b) -> T1 a a -> T1 a b
$cfmap :: forall a a b. (a -> b) -> T1 a a -> T1 a b
Functor, T1 a a -> Bool
(a -> m) -> T1 a a -> m
(a -> b -> b) -> b -> T1 a a -> b
(forall m. Monoid m => T1 a m -> m)
-> (forall m a. Monoid m => (a -> m) -> T1 a a -> m)
-> (forall m a. Monoid m => (a -> m) -> T1 a a -> m)
-> (forall a b. (a -> b -> b) -> b -> T1 a a -> b)
-> (forall a b. (a -> b -> b) -> b -> T1 a a -> b)
-> (forall b a. (b -> a -> b) -> b -> T1 a a -> b)
-> (forall b a. (b -> a -> b) -> b -> T1 a a -> b)
-> (forall a. (a -> a -> a) -> T1 a a -> a)
-> (forall a. (a -> a -> a) -> T1 a a -> a)
-> (forall a. T1 a a -> [a])
-> (forall a. T1 a a -> Bool)
-> (forall a. T1 a a -> Int)
-> (forall a. Eq a => a -> T1 a a -> Bool)
-> (forall a. Ord a => T1 a a -> a)
-> (forall a. Ord a => T1 a a -> a)
-> (forall a. Num a => T1 a a -> a)
-> (forall a. Num a => T1 a a -> a)
-> Foldable (T1 a)
forall a. Eq a => a -> T1 a a -> Bool
forall a. Num a => T1 a a -> a
forall a. Ord a => T1 a a -> a
forall m. Monoid m => T1 a m -> m
forall a. T1 a a -> Bool
forall a. T1 a a -> Int
forall a. T1 a a -> [a]
forall a. (a -> a -> a) -> T1 a a -> a
forall a a. Eq a => a -> T1 a a -> Bool
forall a a. Num a => T1 a a -> a
forall a a. Ord a => T1 a a -> a
forall m a. Monoid m => (a -> m) -> T1 a a -> m
forall a m. Monoid m => T1 a m -> m
forall a a. T1 a a -> Bool
forall a a. T1 a a -> Int
forall a a. T1 a a -> [a]
forall b a. (b -> a -> b) -> b -> T1 a a -> b
forall a b. (a -> b -> b) -> b -> T1 a a -> b
forall a a. (a -> a -> a) -> T1 a a -> a
forall a m a. Monoid m => (a -> m) -> T1 a a -> m
forall a b a. (b -> a -> b) -> b -> T1 a a -> b
forall a a b. (a -> b -> b) -> b -> T1 a 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 :: T1 a a -> a
$cproduct :: forall a a. Num a => T1 a a -> a
sum :: T1 a a -> a
$csum :: forall a a. Num a => T1 a a -> a
minimum :: T1 a a -> a
$cminimum :: forall a a. Ord a => T1 a a -> a
maximum :: T1 a a -> a
$cmaximum :: forall a a. Ord a => T1 a a -> a
elem :: a -> T1 a a -> Bool
$celem :: forall a a. Eq a => a -> T1 a a -> Bool
length :: T1 a a -> Int
$clength :: forall a a. T1 a a -> Int
null :: T1 a a -> Bool
$cnull :: forall a a. T1 a a -> Bool
toList :: T1 a a -> [a]
$ctoList :: forall a a. T1 a a -> [a]
foldl1 :: (a -> a -> a) -> T1 a a -> a
$cfoldl1 :: forall a a. (a -> a -> a) -> T1 a a -> a
foldr1 :: (a -> a -> a) -> T1 a a -> a
$cfoldr1 :: forall a a. (a -> a -> a) -> T1 a a -> a
foldl' :: (b -> a -> b) -> b -> T1 a a -> b
$cfoldl' :: forall a b a. (b -> a -> b) -> b -> T1 a a -> b
foldl :: (b -> a -> b) -> b -> T1 a a -> b
$cfoldl :: forall a b a. (b -> a -> b) -> b -> T1 a a -> b
foldr' :: (a -> b -> b) -> b -> T1 a a -> b
$cfoldr' :: forall a a b. (a -> b -> b) -> b -> T1 a a -> b
foldr :: (a -> b -> b) -> b -> T1 a a -> b
$cfoldr :: forall a a b. (a -> b -> b) -> b -> T1 a a -> b
foldMap' :: (a -> m) -> T1 a a -> m
$cfoldMap' :: forall a m a. Monoid m => (a -> m) -> T1 a a -> m
foldMap :: (a -> m) -> T1 a a -> m
$cfoldMap :: forall a m a. Monoid m => (a -> m) -> T1 a a -> m
fold :: T1 a m -> m
$cfold :: forall a m. Monoid m => T1 a m -> m
Foldable, Functor (T1 a)
Foldable (T1 a)
Functor (T1 a)
-> Foldable (T1 a)
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> T1 a a -> f (T1 a b))
-> (forall (f :: * -> *) a.
    Applicative f =>
    T1 a (f a) -> f (T1 a a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> T1 a a -> m (T1 a b))
-> (forall (m :: * -> *) a. Monad m => T1 a (m a) -> m (T1 a a))
-> Traversable (T1 a)
(a -> f b) -> T1 a a -> f (T1 a b)
forall a. Functor (T1 a)
forall a. Foldable (T1 a)
forall a (m :: * -> *) a. Monad m => T1 a (m a) -> m (T1 a a)
forall a (f :: * -> *) a. Applicative f => T1 a (f a) -> f (T1 a a)
forall a (m :: * -> *) a b.
Monad m =>
(a -> m b) -> T1 a a -> m (T1 a b)
forall a (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> T1 a a -> f (T1 a 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 (m :: * -> *) a. Monad m => T1 a (m a) -> m (T1 a a)
forall (f :: * -> *) a. Applicative f => T1 a (f a) -> f (T1 a a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> T1 a a -> m (T1 a b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> T1 a a -> f (T1 a b)
sequence :: T1 a (m a) -> m (T1 a a)
$csequence :: forall a (m :: * -> *) a. Monad m => T1 a (m a) -> m (T1 a a)
mapM :: (a -> m b) -> T1 a a -> m (T1 a b)
$cmapM :: forall a (m :: * -> *) a b.
Monad m =>
(a -> m b) -> T1 a a -> m (T1 a b)
sequenceA :: T1 a (f a) -> f (T1 a a)
$csequenceA :: forall a (f :: * -> *) a. Applicative f => T1 a (f a) -> f (T1 a a)
traverse :: (a -> f b) -> T1 a a -> f (T1 a b)
$ctraverse :: forall a (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> T1 a a -> f (T1 a b)
$cp2Traversable :: forall a. Foldable (T1 a)
$cp1Traversable :: forall a. Functor (T1 a)
Traversable)

instance MuRef (Tree1 a) where
  type DeRef (Tree1 a) = T1 a
  mapDeRef :: (forall b. (MuRef b, DeRef (Tree1 a) ~ DeRef b) => b -> f u)
-> Tree1 a -> f (DeRef (Tree1 a) u)
mapDeRef forall b. (MuRef b, DeRef (Tree1 a) ~ DeRef b) => b -> f u
_ (Tip1 a
a) = T1 a u -> f (T1 a u)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (a -> T1 a u
forall a b. a -> T1 a b
A a
a)
  mapDeRef forall b. (MuRef b, DeRef (Tree1 a) ~ DeRef b) => b -> f u
f (Bin1 Tree1 a
b Tree1 a
c) = u -> u -> T1 a u
forall a b. b -> b -> T1 a b
B (u -> u -> T1 a u) -> f u -> f (u -> T1 a u)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Tree1 a -> f u
forall b. (MuRef b, DeRef (Tree1 a) ~ DeRef b) => b -> f u
f Tree1 a
b f (u -> T1 a u) -> f u -> f (T1 a u)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Tree1 a -> f u
forall b. (MuRef b, DeRef (Tree1 a) ~ DeRef b) => b -> f u
f Tree1 a
c

instance MuRef1 Tree1 where
  type DeRef1 Tree1 = T1
  muRef1 :: proxy (Tree1 a)
-> Dict (MuRef (Tree1 a), DeRef (Tree1 a) ~ DeRef1 Tree1 a)
muRef1 proxy (Tree1 a)
_ = Dict (MuRef (Tree1 a), DeRef (Tree1 a) ~ DeRef1 Tree1 a)
forall (a :: Constraint). a => Dict a
Dict

instance Bifunctor T1 where
  bimap :: (a -> b) -> (c -> d) -> T1 a c -> T1 b d
bimap a -> b
f c -> d
_ (A a
a) = b -> T1 b d
forall a b. a -> T1 a b
A (a -> b
f a
a)
  bimap a -> b
_ c -> d
g (B c
b c
c) = d -> d -> T1 b d
forall a b. b -> b -> T1 a b
B (c -> d
g c
b) (c -> d
g c
c)

instance Bifoldable T1 where
  bifoldMap :: (a -> m) -> (b -> m) -> T1 a b -> m
bifoldMap a -> m
f b -> m
_ (A a
a) = a -> m
f a
a
  bifoldMap a -> m
_ b -> m
g (B b
b b
c) = b -> m
g b
b m -> m -> m
forall a. Monoid a => a -> a -> a
`mappend` b -> m
g b
c

instance Bitraversable T1 where
  bitraverse :: (a -> f c) -> (b -> f d) -> T1 a b -> f (T1 c d)
bitraverse a -> f c
f b -> f d
_ (A a
a) = c -> T1 c d
forall a b. a -> T1 a b
A (c -> T1 c d) -> f c -> f (T1 c d)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f c
f a
a
  bitraverse a -> f c
_ b -> f d
g (B b
b b
c) = d -> d -> T1 c d
forall a b. b -> b -> T1 a b
B (d -> d -> T1 c d) -> f d -> f (d -> T1 c d)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> b -> f d
g b
b f (d -> T1 c d) -> f d -> f (T1 c d)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> b -> f d
g b
c

foldDeRef1 :: forall f a. (MuRef1 f, Bifoldable1 (DeRef1 f)) => f a -> FreeSemigroup a
foldDeRef1 :: f a -> FreeSemigroup a
foldDeRef1 f a
m = case Proxy (f a) -> Dict (MuRef (f a), DeRef (f a) ~ DeRef1 f a)
forall (f :: * -> *) (proxy :: * -> *) a.
MuRef1 f =>
proxy (f a) -> Dict (MuRef (f a), DeRef (f a) ~ DeRef1 f a)
muRef1 (Proxy (f a)
forall a. HasCallStack => a
undefined :: Proxy (f a)) of
  Dict (MuRef (f a), DeRef (f a) ~ DeRef1 f a)
Dict -> case IO (Graph (DeRef1 f a)) -> Graph (DeRef1 f a)
forall a. IO a -> a
unsafePerformIO (f a -> IO (Graph (DeRef (f a)))
forall s. MuRef s => s -> IO (Graph (DeRef s))
reifyGraph f a
m) of
    Graph [(Int, DeRef1 f a Int)]
xs Int
i | HashMap Int (DeRef1 f a Int)
hm <- [(Int, DeRef1 f a Int)] -> HashMap Int (DeRef1 f a Int)
forall k v. (Eq k, Hashable k) => [(k, v)] -> HashMap k v
HM.fromList [(Int, DeRef1 f a Int)]
xs -> (forall m. Semigroup m => (a -> m) -> m) -> FreeSemigroup a
forall a.
(forall m. Semigroup m => (a -> m) -> m) -> FreeSemigroup a
FreeSemigroup ((forall m. Semigroup m => (a -> m) -> m) -> FreeSemigroup a)
-> (forall m. Semigroup m => (a -> m) -> m) -> FreeSemigroup a
forall a b. (a -> b) -> a -> b
$ \ a -> m
f -> (HashMap Int m -> HashMap Int m) -> HashMap Int m
forall a. (a -> a) -> a
fix (\HashMap Int m
mm -> (DeRef1 f a Int -> m)
-> HashMap Int (DeRef1 f a Int) -> HashMap Int m
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((a -> m) -> (Int -> m) -> DeRef1 f a Int -> m
forall (t :: * -> * -> *) m a b.
(Bifoldable1 t, Semigroup m) =>
(a -> m) -> (b -> m) -> t a b -> m
bifoldMap1 a -> m
f (HashMap Int m
mm HashMap Int m -> Int -> m
forall k v.
(Eq k, Hashable k, HasCallStack) =>
HashMap k v -> k -> v
!)) HashMap Int (DeRef1 f a Int)
hm) HashMap Int m -> Int -> m
forall k v.
(Eq k, Hashable k, HasCallStack) =>
HashMap k v -> k -> v
! Int
i

instance Bifoldable1 T1 where
  bifoldMap1 :: (a -> m) -> (b -> m) -> T1 a b -> m
bifoldMap1 a -> m
f b -> m
_ (A a
a) = a -> m
f a
a
  bifoldMap1 a -> m
_ b -> m
g (B b
b b
c) = b -> m
g b
b m -> m -> m
forall a. Semigroup a => a -> a -> a
<> b -> m
g b
c

instance Bitraversable1 T1 where
  bitraverse1 :: (a -> f b) -> (c -> f d) -> T1 a c -> f (T1 b d)
bitraverse1 a -> f b
f c -> f d
_ (A a
a) = b -> T1 b d
forall a b. a -> T1 a b
A (b -> T1 b d) -> f b -> f (T1 b d)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f b
f a
a
  bitraverse1 a -> f b
_ c -> f d
g (B c
b c
c) = d -> d -> T1 b d
forall a b. b -> b -> T1 a b
B (d -> d -> T1 b d) -> f d -> f (d -> T1 b d)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> c -> f d
g c
b f (d -> T1 b d) -> f d -> f (T1 b d)
forall (f :: * -> *) a b. Apply f => f (a -> b) -> f a -> f b
<.> c -> f d
g c
c