Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Useful utilities we need accross multiple modules.
Synopsis
- (&&&) :: Arrow a => a b c -> a b c' -> a b (c, c')
- (***) :: Arrow a => a b c -> a b' c' -> a (b, b') (c, c')
- type (:->) f g = forall n. f n -> g n
- (<.>) :: Monad m => (b -> m c) -> (a -> m b) -> a -> m c
- data Product (f :: k -> Type) (g :: k -> Type) (a :: k) :: forall k. (k -> Type) -> (k -> Type) -> k -> Type = Pair (f a) (g a)
- type (:*:) = Product
- pattern (:*:) :: f a -> g a -> Product f g a
- type Delta f = Product f f
- curry' :: (Product f g x -> a) -> f x -> g x -> a
- uncurry' :: (f x -> g x -> a) -> Product f g x -> a
- delta :: f :-> Delta f
- data Sum (f :: k -> Type) (g :: k -> Type) (a :: k) :: forall k. (k -> Type) -> (k -> Type) -> k -> Type
- either' :: (f :-> r) -> (g :-> r) -> Sum f g :-> r
- either'' :: (forall x. f x -> a) -> (forall y. g y -> a) -> Sum f g r -> a
- data Nat
- proxyUnsuc :: Proxy (S n) -> Proxy n
- data SNat :: Nat -> * where
- snat2int :: SNat n -> Integer
- class IsNat (n :: Nat) where
- getNat :: IsNat n => Proxy n -> Integer
- getSNat' :: forall (n :: Nat). IsNat n => SNat n
- data ListPrf :: [k] -> * where
- class IsList (xs :: [k]) where
- type L1 xs = IsList xs
- type L2 xs ys = (IsList xs, IsList ys)
- type L3 xs ys zs = (IsList xs, IsList ys, IsList zs)
- type L4 xs ys zs as = (IsList xs, IsList ys, IsList zs, IsList as)
- type family (txs :: [k]) :++: (tys :: [k]) :: [k] where ...
- appendIsListLemma :: ListPrf xs -> ListPrf ys -> ListPrf (xs :++: ys)
- type family Lkup (n :: Nat) (ks :: [k]) :: k where ...
- type family Idx (ty :: k) (xs :: [k]) :: Nat where ...
- data El :: [*] -> Nat -> * where
- getElSNat :: forall ix ls. El ls ix -> SNat ix
- into :: forall fam ty ix. (ix ~ Idx ty fam, Lkup ix fam ~ ty, IsNat ix) => ty -> El fam ix
- class EqHO (f :: ki -> *) where
- class ShowHO (f :: ki -> *) where
- showHO :: forall k. f k -> String
- showsPrecHO :: forall k. Int -> f k -> ShowS
Utility Functions and Types
(&&&) :: Arrow a => a b c -> a b c' -> a b (c, c') infixr 3 #
Fanout: send the input to both argument arrows and combine their output.
The default definition may be overridden with a more efficient version if desired.
(***) :: Arrow a => a b c -> a b' c' -> a (b, b') (c, c') infixr 3 #
Split the input between the two argument arrows and combine their output. Note that this is in general not a functor.
The default definition may be overridden with a more efficient version if desired.
Poly-kind indexed product functionality
data Product (f :: k -> Type) (g :: k -> Type) (a :: k) :: forall k. (k -> Type) -> (k -> Type) -> k -> Type #
Lifted product of functors.
Pair (f a) (g a) |
Instances
Generic1 (Product f g :: k -> Type) | |
(ShowHO f, ShowHO g) => ShowHO (Product f g :: ki -> Type) Source # | |
(EqHO f, EqHO g) => EqHO (Product f g :: ki -> Type) Source # | |
(Monad f, Monad g) => Monad (Product f g) | Since: base-4.9.0.0 |
(Functor f, Functor g) => Functor (Product f g) | Since: base-4.9.0.0 |
(MonadFix f, MonadFix g) => MonadFix (Product f g) | Since: base-4.9.0.0 |
Defined in Data.Functor.Product | |
(Applicative f, Applicative g) => Applicative (Product f g) | Since: base-4.9.0.0 |
Defined in Data.Functor.Product | |
(Foldable f, Foldable g) => Foldable (Product f g) | Since: base-4.9.0.0 |
Defined in Data.Functor.Product fold :: Monoid m => Product f g m -> m # foldMap :: Monoid m => (a -> m) -> Product f g a -> m # foldr :: (a -> b -> b) -> b -> Product f g a -> b # foldr' :: (a -> b -> b) -> b -> Product f g a -> b # foldl :: (b -> a -> b) -> b -> Product f g a -> b # foldl' :: (b -> a -> b) -> b -> Product f g a -> b # foldr1 :: (a -> a -> a) -> Product f g a -> a # foldl1 :: (a -> a -> a) -> Product f g a -> a # toList :: Product f g a -> [a] # null :: Product f g a -> Bool # length :: Product f g a -> Int # elem :: Eq a => a -> Product f g a -> Bool # maximum :: Ord a => Product f g a -> a # minimum :: Ord a => Product f g a -> a # | |
(Traversable f, Traversable g) => Traversable (Product f g) | Since: base-4.9.0.0 |
Defined in Data.Functor.Product | |
(Eq1 f, Eq1 g) => Eq1 (Product f g) | Since: base-4.9.0.0 |
(Ord1 f, Ord1 g) => Ord1 (Product f g) | Since: base-4.9.0.0 |
Defined in Data.Functor.Product | |
(Read1 f, Read1 g) => Read1 (Product f g) | Since: base-4.9.0.0 |
Defined in Data.Functor.Product liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Product f g a) # liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [Product f g a] # liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (Product f g a) # liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [Product f g a] # | |
(Show1 f, Show1 g) => Show1 (Product f g) | Since: base-4.9.0.0 |
(MonadZip f, MonadZip g) => MonadZip (Product f g) | Since: base-4.9.0.0 |
(Alternative f, Alternative g) => Alternative (Product f g) | Since: base-4.9.0.0 |
(MonadPlus f, MonadPlus g) => MonadPlus (Product f g) | Since: base-4.9.0.0 |
(Eq1 f, Eq1 g, Eq a) => Eq (Product f g a) | Since: base-4.9.0.0 |
(Typeable a, Typeable f, Typeable g, Typeable k, Data (f a), Data (g a)) => Data (Product f g a) | Since: base-4.9.0.0 |
Defined in Data.Functor.Product gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g0. g0 -> c g0) -> Product f g a -> c (Product f g a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Product f g a) # toConstr :: Product f g a -> Constr # dataTypeOf :: Product f g a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Product f g a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Product f g a)) # gmapT :: (forall b. Data b => b -> b) -> Product f g a -> Product f g a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Product f g a -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Product f g a -> r # gmapQ :: (forall d. Data d => d -> u) -> Product f g a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Product f g a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Product f g a -> m (Product f g a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Product f g a -> m (Product f g a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Product f g a -> m (Product f g a) # | |
(Ord1 f, Ord1 g, Ord a) => Ord (Product f g a) | Since: base-4.9.0.0 |
Defined in Data.Functor.Product compare :: Product f g a -> Product f g a -> Ordering # (<) :: Product f g a -> Product f g a -> Bool # (<=) :: Product f g a -> Product f g a -> Bool # (>) :: Product f g a -> Product f g a -> Bool # (>=) :: Product f g a -> Product f g a -> Bool # | |
(Read1 f, Read1 g, Read a) => Read (Product f g a) | Since: base-4.9.0.0 |
(Show1 f, Show1 g, Show a) => Show (Product f g a) | Since: base-4.9.0.0 |
Generic (Product f g a) | |
type Rep1 (Product f g :: k -> Type) | Since: base-4.9.0.0 |
Defined in Data.Functor.Product type Rep1 (Product f g :: k -> Type) = D1 (MetaData "Product" "Data.Functor.Product" "base" False) (C1 (MetaCons "Pair" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec1 f) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec1 g))) | |
type Rep (Product f g a) | Since: base-4.9.0.0 |
Defined in Data.Functor.Product type Rep (Product f g a) = D1 (MetaData "Product" "Data.Functor.Product" "base" False) (C1 (MetaCons "Pair" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (f a)) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (g a)))) |
Poly-kind indexed sums
data Sum (f :: k -> Type) (g :: k -> Type) (a :: k) :: forall k. (k -> Type) -> (k -> Type) -> k -> Type #
Lifted sum of functors.
Instances
Generic1 (Sum f g :: k -> Type) | |
(ShowHO f, ShowHO g) => ShowHO (Sum f g :: ki -> Type) Source # | |
(EqHO f, EqHO g) => EqHO (Sum f g :: ki -> Type) Source # | |
(Functor f, Functor g) => Functor (Sum f g) | Since: base-4.9.0.0 |
(Foldable f, Foldable g) => Foldable (Sum f g) | Since: base-4.9.0.0 |
Defined in Data.Functor.Sum fold :: Monoid m => Sum f g m -> m # foldMap :: Monoid m => (a -> m) -> Sum f g a -> m # foldr :: (a -> b -> b) -> b -> Sum f g a -> b # foldr' :: (a -> b -> b) -> b -> Sum f g a -> b # foldl :: (b -> a -> b) -> b -> Sum f g a -> b # foldl' :: (b -> a -> b) -> b -> Sum f g a -> b # foldr1 :: (a -> a -> a) -> Sum f g a -> a # foldl1 :: (a -> a -> a) -> Sum f g a -> a # elem :: Eq a => a -> Sum f g a -> Bool # maximum :: Ord a => Sum f g a -> a # minimum :: Ord a => Sum f g a -> a # | |
(Traversable f, Traversable g) => Traversable (Sum f g) | Since: base-4.9.0.0 |
(Eq1 f, Eq1 g) => Eq1 (Sum f g) | Since: base-4.9.0.0 |
(Ord1 f, Ord1 g) => Ord1 (Sum f g) | Since: base-4.9.0.0 |
Defined in Data.Functor.Sum | |
(Read1 f, Read1 g) => Read1 (Sum f g) | Since: base-4.9.0.0 |
Defined in Data.Functor.Sum | |
(Show1 f, Show1 g) => Show1 (Sum f g) | Since: base-4.9.0.0 |
(Eq1 f, Eq1 g, Eq a) => Eq (Sum f g a) | Since: base-4.9.0.0 |
(Typeable a, Typeable f, Typeable g, Typeable k, Data (f a), Data (g a)) => Data (Sum f g a) | Since: base-4.9.0.0 |
Defined in Data.Functor.Sum gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g0. g0 -> c g0) -> Sum f g a -> c (Sum f g a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Sum f g a) # toConstr :: Sum f g a -> Constr # dataTypeOf :: Sum f g a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Sum f g a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Sum f g a)) # gmapT :: (forall b. Data b => b -> b) -> Sum f g a -> Sum f g a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Sum f g a -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Sum f g a -> r # gmapQ :: (forall d. Data d => d -> u) -> Sum f g a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Sum f g a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Sum f g a -> m (Sum f g a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Sum f g a -> m (Sum f g a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Sum f g a -> m (Sum f g a) # | |
(Ord1 f, Ord1 g, Ord a) => Ord (Sum f g a) | Since: base-4.9.0.0 |
Defined in Data.Functor.Sum | |
(Read1 f, Read1 g, Read a) => Read (Sum f g a) | Since: base-4.9.0.0 |
(Show1 f, Show1 g, Show a) => Show (Sum f g a) | Since: base-4.9.0.0 |
Generic (Sum f g a) | |
type Rep1 (Sum f g :: k -> Type) | Since: base-4.9.0.0 |
Defined in Data.Functor.Sum type Rep1 (Sum f g :: k -> Type) = D1 (MetaData "Sum" "Data.Functor.Sum" "base" False) (C1 (MetaCons "InL" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec1 f)) :+: C1 (MetaCons "InR" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec1 g))) | |
type Rep (Sum f g a) | Since: base-4.9.0.0 |
Defined in Data.Functor.Sum type Rep (Sum f g a) = D1 (MetaData "Sum" "Data.Functor.Sum" "base" False) (C1 (MetaCons "InL" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (f a))) :+: C1 (MetaCons "InR" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (g a)))) |
either'' :: (forall x. f x -> a) -> (forall y. g y -> a) -> Sum f g r -> a Source #
Just like either'
, but the result type is of kind Star
Type-level Naturals
Type-level Peano Naturals
Instances
Eq Nat Source # | |
Show Nat Source # | |
TestEquality SNat Source # | |
Defined in Generics.MRSOP.Util | |
TestEquality (Constr codes :: Nat -> Type) Source # | |
Defined in Generics.MRSOP.Base.Universe | |
ShowHO ki => ShowHO (Fix ki codes :: Nat -> Type) Source # | |
EqHO ki => EqHO (Fix ki codes :: Nat -> Type) Source # | |
data SNat :: Nat -> * where Source #
Singleton Term-level natural
Instances
TestEquality SNat Source # | |
Defined in Generics.MRSOP.Util |
Type-level Lists
data ListPrf :: [k] -> * where Source #
An inhabitant of ListPrf ls
is *not* a singleton!
It only proves that ls
is, in fact, a type level list.
This is useful since it enables us to pattern match on
type-level lists whenever we see fit.
class IsList (xs :: [k]) where Source #
The IsList
class allows us to construct
ListPrf
s in a straight forward fashion.
appendIsListLemma :: ListPrf xs -> ListPrf ys -> ListPrf (xs :++: ys) Source #
Concatenation of lists is also a list.
Type-level List Lookup
getElSNat :: forall ix ls. El ls ix -> SNat ix Source #
Convenient way to cast an El
index to term-level.
into :: forall fam ty ix. (ix ~ Idx ty fam, Lkup ix fam ~ ty, IsNat ix) => ty -> El fam ix Source #
Smart constructor into El
Higher-order Eq and Show
class EqHO (f :: ki -> *) where Source #
Higher order , poly kinded, version of Eq
@since 2.3.0
Instances
EqHO Singl Source # | |
Eq a => EqHO (Const a :: ki -> Type) Source # | |
(EqHO f, EqHO g) => EqHO (Sum f g :: ki -> Type) Source # | |
(EqHO f, EqHO g) => EqHO (Product f g :: ki -> Type) Source # | |
EqHO ki => EqHO (Fix ki codes :: Nat -> Type) Source # | |
EqHO f => EqHO (NS f :: [k] -> Type) Source # | Since: 2.3.0 |
EqHO f => EqHO (NP f :: [k] -> Type) Source # | Since: 2.3.0 |
(EqHO phi, EqHO ki) => EqHO (Rep ki phi :: [[Atom kon]] -> Type) Source # | |
(EqHO phi, EqHO ki) => EqHO (NA ki phi :: Atom kon -> Type) Source # | |
(EqHO phi, EqHO ki) => EqHO (Holes ki codes phi :: Atom kon -> Type) Source # | |
class ShowHO (f :: ki -> *) where Source #
Higher order, poly kinded, version of Show
; We provide
the same showsPrec
mechanism. The documentation of Text.Show
has a good example of the correct usage of showsPrec
:
infixr 5 :^: data Tree a = Leaf a | Tree a :^: Tree a instance (Show a) => Show (Tree a) where showsPrec d (Leaf m) = showParen (d > app_prec) $ showString "Leaf " . showsPrec (app_prec+1) m where app_prec = 10 showsPrec d (u :^: v) = showParen (d > up_prec) $ showsPrec (up_prec+1) u . showString " :^: " . showsPrec (up_prec+1) v where up_prec = 5
Since: 2.3.0
Instances
ShowHO Singl Source # | |
Show a => ShowHO (Const a :: ki -> Type) Source # | |
(ShowHO f, ShowHO g) => ShowHO (Sum f g :: ki -> Type) Source # | |
(ShowHO f, ShowHO g) => ShowHO (Product f g :: ki -> Type) Source # | |
ShowHO ki => ShowHO (Fix ki codes :: Nat -> Type) Source # | |
ShowHO f => ShowHO (NS f :: [k] -> Type) Source # | Since: 2.3.0 |
ShowHO f => ShowHO (NP f :: [k] -> Type) Source # | Since: 2.3.0 |
(ShowHO ki, ShowHO phi) => ShowHO (Rep ki phi :: [[Atom kon]] -> Type) Source # | |
(ShowHO phi, ShowHO ki) => ShowHO (NA ki phi :: Atom kon -> Type) Source # | |
(HasDatatypeInfo ki fam codes, ShowHO ki, ShowHO f, ShowHO ann) => ShowHO (HolesAnn ann ki codes f :: Atom kon -> Type) Source # | |