overloaded-0.3: Overloaded pragmas as a plugin
Safe HaskellNone
LanguageHaskell2010

Overloaded

Description

Overloaded* language extensions as a source plugin.

Synopsis

Plugin

plugin :: Plugin Source #

Overloaded plugin.

To enable plugin put the following at top of the module:

{-# OPTIONS -fplugin=Overloaded -fplugin-opt=Overloaded:Symbols #-}

At least one option is required, multiple can given either using multiple -fplugin-opt options, or by separating options with colon:

{-# OPTIONS -fplugin=Overloaded -fplugin-opt=Overloaded:Symbols:Numerals #-}

Options also take optional desugaring names, for example

{-# OPTIONS -fplugin=Overloaded -fplugin-opt=Overloaded:Labels=Data.Generics.ProductFields.field #-}

to desugar OverloadedLabels directly into field from generics-lens (no need to import orphan instance!)

Supported options

  • Symbols desugars literal strings to fromSymbol @sym
  • Strings works like built-in OverloadedStrings (but you can use different method than fromString)
  • Numerals desugars literal numbers to fromNumeral @nat
  • Naturals desugars literal numbers to fromNatural nat (i.e. like fromString)
  • Chars desugars literal characters to fromChars c. Note: there isn't type-level alternative: we cannot promote Chars
  • Lists is not like built-in OverloadedLists, but desugars explicit lists to cons and nil
  • If desugars if-expressions to ifte b t e
  • Unit desugars ()-expressions to nil (but you can use different method, e.g. boring from Data.Boring)
  • Labels works like built-in OverloadedLabels (you should enable OverloadedLabels so parser recognises the syntax)
  • TypeNats and TypeSymbols desugar type-level literals into FromNat and FromTypeSymbol respectively
  • Do desugar in Local Do fashion. See examples.
  • Categories change Arrows desugaring to use "correct" category classes.
  • CodeLabels desugars OverloadedLabels into Typed Template Haskell splices
  • CodeStrings desugars string literals into Typed Template Haskell splices
  • RebindableApplication changes how juxtaposition is interpreted

Known limitations

  • Doesn't desugar inside patterns

RecordFields

WARNING the type-checker plugin is experimental, it's adviced to use

{-# OPTIONS_GHC -ddump-simpl #-}

to avoid surprising segfaults.

Usage

{-# OPTIONS -fplugin=Overloaded -fplugin-opt=Overloaded:RecordFields #-}

Implementation bits

See Note [HasField instances] in ClsInst, the behavior of this plugin is similar.

The HasField class is defined in GHC.Records.Compat module of record-hasfield package:

class HasField {k} x r a | x r -> a where
    hasField :: r -> (a -> r, a)

Suppose we have

data R y = MkR { foo :: [y] }

and foo in scope. We will solve constraints like

HasField "foo" (R Int) a

by emitting a new wanted constraint

[Int] ~# a

and building a HasField dictionary out of selector foo appropriately cast.

Idiom brackets from TemplateHaskellQuotes

{-# LANGUAGE TemplateHaskellQuotes #-}
{-# OPTIONS_GHC -fplugin=Overloaded -fplugin-opt=Overloaded:IdiomBrackets #-}

data Tree a
    = Leaf a
    | Branch (Tree a) (Tree a)
  deriving (Show)

instance Functor Tree where
    fmap f (Leaf x)     = Leaf (f x)
    fmap f (Branch l r) = Branch (fmap f l) (fmap f r)

instance Traversable Tree where
    traverse f (Leaf x)     = [| Leaf (f x) |]
    traverse f (Branch l r) = [| Branch (traverse f l) (traverse f r) |]

RebindableApplication

Converts all f x applications into (f $ x) with whatever $ is in scope.

{-# OPTIONS -fplugin=Overloaded -fplugin-opt=Overloaded:RebindableApplication #-}

let f = pure ((+) :: Int -> Int -> Int)
    x = Just 1
    y = Just 2

    z = let ($) = (<*>) in f x y
in z

Overloaded:Symbols

class FromSymbol (s :: Symbol) a where Source #

Another way to desugar overloaded string literals using this class.

A string literal "example" is desugared to

fromSymbol @"example"

Enabled with:

{-# OPTIONS -fplugin=Overloaded -fplugin-opt=Overloaded:Symbols #-}

Methods

fromSymbol :: a Source #

Instances

Instances details
(KnownNat y, KnownNat m, KnownNat d, ParseDay s ~ '(y, m, d)) => FromSymbol s Day Source # 
Instance details

Defined in Overloaded.Symbols

(KnownSymbol s, SeqList (ToList s)) => FromSymbol s ByteString Source # 
Instance details

Defined in Overloaded.Symbols

(KnownSymbol s, SeqList (ToList s)) => FromSymbol s ByteString Source # 
Instance details

Defined in Overloaded.Symbols

KnownSymbol s => FromSymbol s Text Source # 
Instance details

Defined in Overloaded.Symbols

KnownSymbol s => FromSymbol s Text Source # 
Instance details

Defined in Overloaded.Symbols

(KnownSymbol s, a ~ Char) => FromSymbol s [a] Source # 
Instance details

Defined in Overloaded.Symbols

Methods

fromSymbol :: [a] Source #

Overloaded:Strings

Overloaded:Numerals

class FromNumeral (n :: Nat) a where Source #

Another way to desugar numerals.

A numeric literal 123 is desugared to

fromNumeral @123

Enabled with:

{-# OPTIONS -fplugin=Overloaded -fplugin-opt=Overloaded:Numerals #-}

One can do type-level computations with this.

Methods

fromNumeral :: a Source #

Instances

Instances details
(KnownNat n, (1 <=? n) ~ 'True) => FromNumeral n BinP Source # 
Instance details

Defined in Overloaded.Numerals

KnownNat n => FromNumeral n Bin Source # 
Instance details

Defined in Overloaded.Numerals

KnownNat n => FromNumeral n Nat Source # 
Instance details

Defined in Overloaded.Numerals

(KnownNat n, OverflowCheck n "Word8" (n <=? 18446744073709551615)) => FromNumeral n Word64 Source # 
Instance details

Defined in Overloaded.Numerals

(KnownNat n, OverflowCheck n "Word8" (n <=? 4294967295)) => FromNumeral n Word32 Source # 
Instance details

Defined in Overloaded.Numerals

(KnownNat n, OverflowCheck n "Word8" (n <=? 65535)) => FromNumeral n Word16 Source # 
Instance details

Defined in Overloaded.Numerals

(KnownNat n, OverflowCheck n "Word8" (n <=? 255)) => FromNumeral n Word8 Source # 
Instance details

Defined in Overloaded.Numerals

KnownNat n => FromNumeral n Int Source #

TODO: currently there is no range check

Instance details

Defined in Overloaded.Numerals

KnownNat n => FromNumeral n Integer Source # 
Instance details

Defined in Overloaded.Numerals

KnownNat n => FromNumeral n Natural Source # 
Instance details

Defined in Overloaded.Numerals

(PosFromNumeral (FromGHC n) b, IsLess n (ToGHC b)) => FromNumeral n (Pos ('BP b)) Source # 
Instance details

Defined in Overloaded.Numerals

Methods

fromNumeral :: Pos ('BP b) Source #

(PosFromNumeral (FromGHC n) b, IsLess n (ToGHC b)) => FromNumeral n (PosP b) Source # 
Instance details

Defined in Overloaded.Numerals

Methods

fromNumeral :: PosP b Source #

(FinFromNumeral (FromGHC n) m, IsLess n (ToGHC m)) => FromNumeral n (Fin m) Source # 
Instance details

Defined in Overloaded.Numerals

Methods

fromNumeral :: Fin m Source #

defaultFromNumeral :: forall n a. (KnownNat n, Integral a) => a Source #

Default implementation of fromNumeral.

Usage example:

instance (KnownNat n, ...) => FromNumeral n MyType where
    fromNumeral = defaultFromNumeral @n

Overloaded:Naturals

class FromNatural a where Source #

Class for Natural-like datastructures

A numeric literal 42 is desugared to

fromNatural 42

Methods

fromNatural :: Natural -> a Source #

Instances

Instances details
FromNatural Integer Source # 
Instance details

Defined in Overloaded.Naturals

FromNatural Natural Source # 
Instance details

Defined in Overloaded.Naturals

Overloaded:Chars

class FromChar a where Source #

Class for Char-like datastructures

A character literal x is desugared to

fromChar 'x'

Methods

fromChar :: Char -> a Source #

Instances

Instances details
FromChar Char Source # 
Instance details

Defined in Overloaded.Chars

Methods

fromChar :: Char -> Char Source #

Overloaded:Lists

class Nil a where Source #

Class for nil, []

See test-suite for ways to define instances for Map. There are at-least two-ways.

Methods

nil :: a Source #

Instances

Instances details
Nil IntSet Source #

Since: 0.1.3

Instance details

Defined in Overloaded.Lists

Methods

nil :: IntSet Source #

Nil [a] Source # 
Instance details

Defined in Overloaded.Lists

Methods

nil :: [a] Source #

Nil (IntMap v) Source #

Since: 0.2

Instance details

Defined in Overloaded.Lists

Methods

nil :: IntMap v Source #

Nil (Seq a) Source #

Since: 0.2

Instance details

Defined in Overloaded.Lists

Methods

nil :: Seq a Source #

Nil (Set a) Source #

Since: 0.1.3

Instance details

Defined in Overloaded.Lists

Methods

nil :: Set a Source #

Nil (RAList a) Source # 
Instance details

Defined in Overloaded.Lists

Methods

nil :: RAList a Source #

Nil (Map k v) Source #

Since: 0.2

Instance details

Defined in Overloaded.Lists

Methods

nil :: Map k v Source #

b ~ 'BZ => Nil (RAVec b a) Source # 
Instance details

Defined in Overloaded.Lists

Methods

nil :: RAVec b a Source #

n ~ 'Z => Nil (Vec n a) Source # 
Instance details

Defined in Overloaded.Lists

Methods

nil :: Vec n a Source #

xs ~ ('[] :: [k]) => Nil (NP f xs) Source # 
Instance details

Defined in Overloaded.Lists

Methods

nil :: NP f xs Source #

xs ~ ('[] :: [[k]]) => Nil (POP f xs) Source # 
Instance details

Defined in Overloaded.Lists

Methods

nil :: POP f xs Source #

class Cons x ys zs | zs -> x ys where Source #

Class for Cons :.

Methods

cons :: x -> ys -> zs infixr 5 Source #

Instances

Instances details
Cons Int IntSet IntSet Source #

Since: 0.1.3

Instance details

Defined in Overloaded.Lists

Methods

cons :: Int -> IntSet -> IntSet Source #

(a ~ b, a ~ c) => Cons a (RAList b) (NERAList c) Source # 
Instance details

Defined in Overloaded.Lists

Methods

cons :: a -> RAList b -> NERAList c Source #

(a ~ b, a ~ c) => Cons a (RAList b) (RAList c) Source # 
Instance details

Defined in Overloaded.Lists

Methods

cons :: a -> RAList b -> RAList c Source #

(a ~ b, b ~ c) => Cons a (Seq b) (Seq c) Source #

Since: 0.2

Instance details

Defined in Overloaded.Lists

Methods

cons :: a -> Seq b -> Seq c Source #

(Ord a, a ~ b, b ~ c) => Cons a (Set b) (Set c) Source #

Since: 0.1.3

Instance details

Defined in Overloaded.Lists

Methods

cons :: a -> Set b -> Set c Source #

(a ~ b, b ~ c) => Cons a [b] (NonEmpty c) Source # 
Instance details

Defined in Overloaded.Lists

Methods

cons :: a -> [b] -> NonEmpty c Source #

(a ~ b, b ~ c) => Cons a [b] [c] Source # 
Instance details

Defined in Overloaded.Lists

Methods

cons :: a -> [b] -> [c] Source #

(bp ~ Pred b, b ~ Succ' bp) => Cons a (RAVec bp a) (NERAVec b a) Source # 
Instance details

Defined in Overloaded.Lists

Methods

cons :: a -> RAVec bp a -> NERAVec b a Source #

(b ~ 'BP bb, bp ~ Pred bb, bb ~ Succ' bp) => Cons a (RAVec bp a) (RAVec b a) Source # 
Instance details

Defined in Overloaded.Lists

Methods

cons :: a -> RAVec bp a -> RAVec b a Source #

(a ~ b, b ~ c, m ~ 'S n) => Cons a (Vec n b) (Vec m c) Source # 
Instance details

Defined in Overloaded.Lists

Methods

cons :: a -> Vec n b -> Vec m c Source #

(f ~ g, g ~ h, xxs ~ (x ': xs)) => Cons (f x) (NP g xs) (NP h xxs) Source # 
Instance details

Defined in Overloaded.Lists

Methods

cons :: f x -> NP g xs -> NP h xxs Source #

(i ~ Int, a ~ b, b ~ c) => Cons (i, a) (IntMap b) (IntMap c) Source #

Since: 0.2

Instance details

Defined in Overloaded.Lists

Methods

cons :: (i, a) -> IntMap b -> IntMap c Source #

(Ord k, k ~ k1, k ~ k2, v ~ v1, v ~ v2) => Cons (k, v) (Map k1 v1) (Map k2 v2) Source #

Since: 0.2

Instance details

Defined in Overloaded.Lists

Methods

cons :: (k, v) -> Map k1 v1 -> Map k2 v2 Source #

(f ~ g, g ~ h, xsxss ~ (xs ': xss)) => Cons (NP f xs) (POP g xss) (POP h xsxss) Source # 
Instance details

Defined in Overloaded.Lists

Methods

cons :: NP f xs -> POP g xss -> POP h xsxss Source #

Overloaded:If

class ToBool b where Source #

Class for Bool-like datastrucutres

An if--expression if b then t else e is desugared to

ifte (toBool b) t e

Enabled with:

{-# OPTIONS -fplugin=Overloaded -fplugin-opt=Overloaded:If #-}

Methods

toBool :: b -> Bool Source #

Instances

Instances details
ToBool Bool Source # 
Instance details

Defined in Overloaded.If

Methods

toBool :: Bool -> Bool Source #

ToBool (Maybe a) Source #

Just is True

Instance details

Defined in Overloaded.If

Methods

toBool :: Maybe a -> Bool Source #

ToBool (Either b a) Source #

Right is True

Instance details

Defined in Overloaded.If

Methods

toBool :: Either b a -> Bool Source #

ifte :: ToBool b => b -> a -> a -> a Source #

ToBool overloaded if-expression.

Overloaded:Labels

Overloaded:CodeLabels

class IsCodeLabel (sym :: Symbol) a where Source #

Class for auto-spliced labels

The labels #lbl is desugared into $$(codeFromlabel @"lbl") splice.

{-# OPTIONS -fplugin=Overloaded -fplugin-opt=Overloaded:CodeLabels #-}

This feature is not very usable, see https://gitlab.haskell.org/ghc/ghc/-/issues/18211

Overloaded:CodeStrings

class IsCodeString a where Source #

Class for auto-spliced string literals

The string literals "beer" is desugared into $$(codeFromString @"beer") splice.

{-# OPTIONS -fplugin=Overloaded -fplugin-opt=Overloaded:CodeLabels #-}

This feature is not very usable, see https://gitlab.haskell.org/ghc/ghc/-/issues/18211

Instances

Instances details
IsCodeString ByteString Source # 
Instance details

Defined in Overloaded.CodeStrings

a ~ Char => IsCodeString [a] Source # 
Instance details

Defined in Overloaded.CodeStrings

Overloaded:TypeNats

class FromNatC a Source #

A way to overload type level Nats.

A number type-literal 42 is desugared to

FromNat 42

Enabled with:

{-# OPTIONS -fplugin=Overloaded -fplugin-opt=Overloaded:TypeNats #-}

Associated Types

type FromNat (n :: Nat) :: a Source #

Instances

Instances details
FromNatC Nat Source # 
Instance details

Defined in Overloaded.TypeNats

Associated Types

type FromNat n :: a Source #

FromNatC Nat Source # 
Instance details

Defined in Overloaded.TypeNats

Associated Types

type FromNat n :: a Source #

FromNatC Bin Source # 
Instance details

Defined in Overloaded.TypeNats

Associated Types

type FromNat n :: a Source #

FromNatC BinP Source # 
Instance details

Defined in Overloaded.TypeNats

Associated Types

type FromNat n :: a Source #

Overloaded:TypeSymbols

class FromTypeSymbolC a Source #

A way to overload type level Symbols.

A symbol type-literal "example" is desugared to

FromTypeSymbol "example"

Enabled with:

{-# OPTIONS -fplugin=Overloaded -fplugin-opt=Overloaded:TypeSymbols #-}

Associated Types

type FromTypeSymbol (s :: Symbol) :: a Source #

Instances

Instances details
FromTypeSymbolC Symbol Source # 
Instance details

Defined in Overloaded.TypeSymbols

Associated Types

type FromTypeSymbol s :: a Source #

Overloaded:Do

type Pure = 'Pure Source #

type Then = 'Then Source #

type Bind = 'Bind Source #

class Monad' (method :: DoMethod) (ty :: Type) where Source #

Methods

monad :: ty Source #

Instances

Instances details
(ty ~ (a -> m a), Applicative m) => Monad' 'Pure ty Source # 
Instance details

Defined in Overloaded.Do

Methods

monad :: ty Source #

(ty ~ (m a -> m b -> m b), Applicative m) => Monad' 'Then ty Source # 
Instance details

Defined in Overloaded.Do

Methods

monad :: ty Source #

(ty ~ (m a -> (a -> m b) -> m b), Monad m) => Monad' 'Bind ty Source # 
Instance details

Defined in Overloaded.Do

Methods

monad :: ty Source #

Overloaded:Categories

class Category (cat :: k -> k -> Type) #

A class for categories. Instances should satisfy the laws

Right identity
f . id = f
Left identity
id . f = f
Associativity
f . (g . h) = (f . g) . h

Minimal complete definition

id, (.)

Instances

Instances details
Category (Coercion :: k -> k -> Type)

Since: base-4.7.0.0

Instance details

Defined in Control.Category

Methods

id :: forall (a :: k0). Coercion a a #

(.) :: forall (b :: k0) (c :: k0) (a :: k0). Coercion b c -> Coercion a b -> Coercion a c #

Category ((:~:) :: k -> k -> Type)

Since: base-4.7.0.0

Instance details

Defined in Control.Category

Methods

id :: forall (a :: k0). a :~: a #

(.) :: forall (b :: k0) (c :: k0) (a :: k0). (b :~: c) -> (a :~: b) -> a :~: c #

Category ((:~~:) :: k -> k -> Type)

Since: base-4.10.0.0

Instance details

Defined in Control.Category

Methods

id :: forall (a :: k0). a :~~: a #

(.) :: forall (b :: k0) (c :: k0) (a :: k0). (b :~~: c) -> (a :~~: b) -> a :~~: c #

Category arr => Category (WrappedArrow arr :: k -> k -> Type) Source # 
Instance details

Defined in Overloaded.Categories

Methods

id :: forall (a :: k0). WrappedArrow arr a a #

(.) :: forall (b :: k0) (c :: k0) (a :: k0). WrappedArrow arr b c -> WrappedArrow arr a b -> WrappedArrow arr a c #

Category k2 => Category (Dual k2 :: k1 -> k1 -> Type) 
Instance details

Defined in Data.Semigroupoid.Dual

Methods

id :: forall (a :: k). Dual k2 a a #

(.) :: forall (b :: k) (c :: k) (a :: k). Dual k2 b c -> Dual k2 a b -> Dual k2 a c #

Category p => Category (WrappedArrow p :: k -> k -> Type) 
Instance details

Defined in Data.Profunctor.Types

Methods

id :: forall (a :: k0). WrappedArrow p a a #

(.) :: forall (b :: k0) (c :: k0) (a :: k0). WrappedArrow p b c -> WrappedArrow p a b -> WrappedArrow p a c #

(Category p, Category q) => Category (Product p q :: k -> k -> Type) 
Instance details

Defined in Data.Bifunctor.Product

Methods

id :: forall (a :: k0). Product p q a a #

(.) :: forall (b :: k0) (c :: k0) (a :: k0). Product p q b c -> Product p q a b -> Product p q a c #

(Applicative f, Category p) => Category (Tannen f p :: k -> k -> Type) 
Instance details

Defined in Data.Bifunctor.Tannen

Methods

id :: forall (a :: k0). Tannen f p a a #

(.) :: forall (b :: k0) (c :: k0) (a :: k0). Tannen f p b c -> Tannen f p a b -> Tannen f p a c #

Category Op 
Instance details

Defined in Data.Functor.Contravariant

Methods

id :: forall (a :: k). Op a a #

(.) :: forall (b :: k) (c :: k) (a :: k). Op b c -> Op a b -> Op a c #

Monad m => Category (Kleisli m :: Type -> Type -> Type)

Since: base-3.0

Instance details

Defined in Control.Arrow

Methods

id :: forall (a :: k). Kleisli m a a #

(.) :: forall (b :: k) (c :: k) (a :: k). Kleisli m b c -> Kleisli m a b -> Kleisli m a c #

(Applicative f, Monad f) => Category (WhenMissing f :: Type -> Type -> Type)

Since: containers-0.5.9

Instance details

Defined in Data.IntMap.Internal

Methods

id :: forall (a :: k). WhenMissing f a a #

(.) :: forall (b :: k) (c :: k) (a :: k). WhenMissing f b c -> WhenMissing f a b -> WhenMissing f a c #

Category ((->) :: Type -> Type -> Type)

Since: base-3.0

Instance details

Defined in Control.Category

Methods

id :: forall (a :: k). a -> a #

(.) :: forall (b :: k) (c :: k) (a :: k). (b -> c) -> (a -> b) -> a -> c #

(Monad f, Applicative f) => Category (WhenMatched f x :: Type -> Type -> Type)

Since: containers-0.5.9

Instance details

Defined in Data.IntMap.Internal

Methods

id :: forall (a :: k). WhenMatched f x a a #

(.) :: forall (b :: k) (c :: k) (a :: k). WhenMatched f x b c -> WhenMatched f x a b -> WhenMatched f x a c #

(Applicative f, Monad f) => Category (WhenMissing f k :: Type -> Type -> Type)

Since: containers-0.5.9

Instance details

Defined in Data.Map.Internal

Methods

id :: forall (a :: k0). WhenMissing f k a a #

(.) :: forall (b :: k0) (c :: k0) (a :: k0). WhenMissing f k b c -> WhenMissing f k a b -> WhenMissing f k a c #

Monad f => Category (Star f :: Type -> Type -> Type) 
Instance details

Defined in Data.Profunctor.Types

Methods

id :: forall (a :: k). Star f a a #

(.) :: forall (b :: k) (c :: k) (a :: k). Star f b c -> Star f a b -> Star f a c #

(Monad f, Applicative f) => Category (WhenMatched f k x :: Type -> Type -> Type)

Since: containers-0.5.9

Instance details

Defined in Data.Map.Internal

Methods

id :: forall (a :: k0). WhenMatched f k x a a #

(.) :: forall (b :: k0) (c :: k0) (a :: k0). WhenMatched f k x b c -> WhenMatched f k x a b -> WhenMatched f k x a c #

identity :: Category cat => cat a a Source #

A non-clashing name for id.

(%%) :: Category cat => cat b c -> cat a b -> cat a c infixr 9 Source #

A non-clashing name for (.).

class Category cat => CartesianCategory (cat :: k -> k -> Type) where Source #

Cartesian category is a monoidal category where monoidal product is the categorical product.

Associated Types

type Product cat :: k -> k -> k Source #

Methods

proj1 :: cat (Product cat a b) a Source #

proj2 :: cat (Product cat a b) b Source #

fanout :: cat a b -> cat a c -> cat a (Product cat b c) Source #

fanout f g is written as \(\langle f, g \rangle\) in category theory literature.

Instances

Instances details
CocartesianCategory cat => CartesianCategory (Dual cat :: k -> k -> Type) Source # 
Instance details

Defined in Overloaded.Categories

Associated Types

type Product (Dual cat) :: k -> k -> k Source #

Methods

proj1 :: forall (a :: k0) (b :: k0). Dual cat (Product (Dual cat) a b) a Source #

proj2 :: forall (a :: k0) (b :: k0). Dual cat (Product (Dual cat) a b) b Source #

fanout :: forall (a :: k0) (b :: k0) (c :: k0). Dual cat a b -> Dual cat a c -> Dual cat a (Product (Dual cat) b c) Source #

CartesianCategory Op Source # 
Instance details

Defined in Overloaded.Categories

Associated Types

type Product Op :: k -> k -> k Source #

Methods

proj1 :: forall (a :: k) (b :: k). Op (Product Op a b) a Source #

proj2 :: forall (a :: k) (b :: k). Op (Product Op a b) b Source #

fanout :: forall (a :: k) (b :: k) (c :: k). Op a b -> Op a c -> Op a (Product Op b c) Source #

Monad m => CartesianCategory (Kleisli m :: Type -> Type -> Type) Source # 
Instance details

Defined in Overloaded.Categories

Associated Types

type Product (Kleisli m) :: k -> k -> k Source #

Methods

proj1 :: forall (a :: k) (b :: k). Kleisli m (Product (Kleisli m) a b) a Source #

proj2 :: forall (a :: k) (b :: k). Kleisli m (Product (Kleisli m) a b) b Source #

fanout :: forall (a :: k) (b :: k) (c :: k). Kleisli m a b -> Kleisli m a c -> Kleisli m a (Product (Kleisli m) b c) Source #

CartesianCategory ((->) :: Type -> Type -> Type) Source # 
Instance details

Defined in Overloaded.Categories

Associated Types

type Product (->) :: k -> k -> k Source #

Methods

proj1 :: forall (a :: k) (b :: k). Product (->) a b -> a Source #

proj2 :: forall (a :: k) (b :: k). Product (->) a b -> b Source #

fanout :: forall (a :: k) (b :: k) (c :: k). (a -> b) -> (a -> c) -> a -> Product (->) b c Source #

Monad m => CartesianCategory (Star m :: Type -> Type -> Type) Source # 
Instance details

Defined in Overloaded.Categories

Associated Types

type Product (Star m) :: k -> k -> k Source #

Methods

proj1 :: forall (a :: k) (b :: k). Star m (Product (Star m) a b) a Source #

proj2 :: forall (a :: k) (b :: k). Star m (Product (Star m) a b) b Source #

fanout :: forall (a :: k) (b :: k) (c :: k). Star m a b -> Star m a c -> Star m a (Product (Star m) b c) Source #

Arrow arr => CartesianCategory (WrappedArrow arr :: Type -> Type -> Type) Source # 
Instance details

Defined in Overloaded.Categories

Associated Types

type Product (WrappedArrow arr) :: k -> k -> k Source #

Methods

proj1 :: forall (a :: k) (b :: k). WrappedArrow arr (Product (WrappedArrow arr) a b) a Source #

proj2 :: forall (a :: k) (b :: k). WrappedArrow arr (Product (WrappedArrow arr) a b) b Source #

fanout :: forall (a :: k) (b :: k) (c :: k). WrappedArrow arr a b -> WrappedArrow arr a c -> WrappedArrow arr a (Product (WrappedArrow arr) b c) Source #

class Category cat => CocartesianCategory (cat :: k -> k -> Type) where Source #

Cocartesian category is a monoidal category where monoidal product is the categorical coproduct.

Associated Types

type Coproduct cat :: k -> k -> k Source #

Methods

inl :: cat a (Coproduct cat a b) Source #

inr :: cat b (Coproduct cat a b) Source #

fanin :: cat a c -> cat b c -> cat (Coproduct cat a b) c Source #

fanin f g is written as \([f, g]\) in category theory literature.

Instances

Instances details
CartesianCategory cat => CocartesianCategory (Dual cat :: k -> k -> Type) Source # 
Instance details

Defined in Overloaded.Categories

Associated Types

type Coproduct (Dual cat) :: k -> k -> k Source #

Methods

inl :: forall (a :: k0) (b :: k0). Dual cat a (Coproduct (Dual cat) a b) Source #

inr :: forall (b :: k0) (a :: k0). Dual cat b (Coproduct (Dual cat) a b) Source #

fanin :: forall (a :: k0) (c :: k0) (b :: k0). Dual cat a c -> Dual cat b c -> Dual cat (Coproduct (Dual cat) a b) c Source #

CocartesianCategory Op Source # 
Instance details

Defined in Overloaded.Categories

Associated Types

type Coproduct Op :: k -> k -> k Source #

Methods

inl :: forall (a :: k) (b :: k). Op a (Coproduct Op a b) Source #

inr :: forall (b :: k) (a :: k). Op b (Coproduct Op a b) Source #

fanin :: forall (a :: k) (c :: k) (b :: k). Op a c -> Op b c -> Op (Coproduct Op a b) c Source #

Monad m => CocartesianCategory (Kleisli m :: Type -> Type -> Type) Source # 
Instance details

Defined in Overloaded.Categories

Associated Types

type Coproduct (Kleisli m) :: k -> k -> k Source #

Methods

inl :: forall (a :: k) (b :: k). Kleisli m a (Coproduct (Kleisli m) a b) Source #

inr :: forall (b :: k) (a :: k). Kleisli m b (Coproduct (Kleisli m) a b) Source #

fanin :: forall (a :: k) (c :: k) (b :: k). Kleisli m a c -> Kleisli m b c -> Kleisli m (Coproduct (Kleisli m) a b) c Source #

CocartesianCategory ((->) :: Type -> Type -> Type) Source # 
Instance details

Defined in Overloaded.Categories

Associated Types

type Coproduct (->) :: k -> k -> k Source #

Methods

inl :: forall (a :: k) (b :: k). a -> Coproduct (->) a b Source #

inr :: forall (b :: k) (a :: k). b -> Coproduct (->) a b Source #

fanin :: forall (a :: k) (c :: k) (b :: k). (a -> c) -> (b -> c) -> Coproduct (->) a b -> c Source #

Monad m => CocartesianCategory (Star m :: Type -> Type -> Type) Source # 
Instance details

Defined in Overloaded.Categories

Associated Types

type Coproduct (Star m) :: k -> k -> k Source #

Methods

inl :: forall (a :: k) (b :: k). Star m a (Coproduct (Star m) a b) Source #

inr :: forall (b :: k) (a :: k). Star m b (Coproduct (Star m) a b) Source #

fanin :: forall (a :: k) (c :: k) (b :: k). Star m a c -> Star m b c -> Star m (Coproduct (Star m) a b) c Source #

ArrowChoice arr => CocartesianCategory (WrappedArrow arr :: Type -> Type -> Type) Source # 
Instance details

Defined in Overloaded.Categories

Associated Types

type Coproduct (WrappedArrow arr) :: k -> k -> k Source #

Methods

inl :: forall (a :: k) (b :: k). WrappedArrow arr a (Coproduct (WrappedArrow arr) a b) Source #

inr :: forall (b :: k) (a :: k). WrappedArrow arr b (Coproduct (WrappedArrow arr) a b) Source #

fanin :: forall (a :: k) (c :: k) (b :: k). WrappedArrow arr a c -> WrappedArrow arr b c -> WrappedArrow arr (Coproduct (WrappedArrow arr) a b) c Source #

class (CartesianCategory cat, CocartesianCategory cat) => BicartesianCategory cat where Source #

Bicartesian category is category which is both cartesian and cocartesian.

We also require distributive morpism.

Methods

distr :: cat (Product cat (Coproduct cat a b) c) (Coproduct cat (Product cat a c) (Product cat b c)) Source #

Instances

Instances details
Monad m => BicartesianCategory (Kleisli m :: Type -> Type -> Type) Source # 
Instance details

Defined in Overloaded.Categories

Methods

distr :: forall (a :: k) (b :: k) (c :: k). Kleisli m (Product (Kleisli m) (Coproduct (Kleisli m) a b) c) (Coproduct (Kleisli m) (Product (Kleisli m) a c) (Product (Kleisli m) b c)) Source #

BicartesianCategory ((->) :: Type -> Type -> Type) Source # 
Instance details

Defined in Overloaded.Categories

Methods

distr :: forall (a :: k) (b :: k) (c :: k). Product (->) (Coproduct (->) a b) c -> Coproduct (->) (Product (->) a c) (Product (->) b c) Source #

Monad m => BicartesianCategory (Star m :: Type -> Type -> Type) Source # 
Instance details

Defined in Overloaded.Categories

Methods

distr :: forall (a :: k) (b :: k) (c :: k). Star m (Product (Star m) (Coproduct (Star m) a b) c) (Coproduct (Star m) (Product (Star m) a c) (Product (Star m) b c)) Source #

ArrowChoice arr => BicartesianCategory (WrappedArrow arr :: Type -> Type -> Type) Source # 
Instance details

Defined in Overloaded.Categories

Methods

distr :: forall (a :: k) (b :: k) (c :: k). WrappedArrow arr (Product (WrappedArrow arr) (Coproduct (WrappedArrow arr) a b) c) (Coproduct (WrappedArrow arr) (Product (WrappedArrow arr) a c) (Product (WrappedArrow arr) b c)) Source #

class CartesianCategory cat => CCC (cat :: k -> k -> Type) where Source #

Closed cartesian category.

Associated Types

type Exponential cat :: k -> k -> k Source #

Exponential cat a b represents \(B^A\). This is due how (->) works.

Methods

eval :: cat (Product cat (Exponential cat a b) a) b Source #

transpose :: cat (Product cat a b) c -> cat a (Exponential cat b c) Source #

Instances

Instances details
Monad m => CCC (Kleisli m :: Type -> Type -> Type) Source # 
Instance details

Defined in Overloaded.Categories

Associated Types

type Exponential (Kleisli m) :: k -> k -> k Source #

Methods

eval :: forall (a :: k) (b :: k). Kleisli m (Product (Kleisli m) (Exponential (Kleisli m) a b) a) b Source #

transpose :: forall (a :: k) (b :: k) (c :: k). Kleisli m (Product (Kleisli m) a b) c -> Kleisli m a (Exponential (Kleisli m) b c) Source #

CCC ((->) :: Type -> Type -> Type) Source # 
Instance details

Defined in Overloaded.Categories

Associated Types

type Exponential (->) :: k -> k -> k Source #

Methods

eval :: forall (a :: k) (b :: k). Product (->) (Exponential (->) a b) a -> b Source #

transpose :: forall (a :: k) (b :: k) (c :: k). (Product (->) a b -> c) -> a -> Exponential (->) b c Source #

Monad m => CCC (Star m :: Type -> Type -> Type) Source # 
Instance details

Defined in Overloaded.Categories

Associated Types

type Exponential (Star m) :: k -> k -> k Source #

Methods

eval :: forall (a :: k) (b :: k). Star m (Product (Star m) (Exponential (Star m) a b) a) b Source #

transpose :: forall (a :: k) (b :: k) (c :: k). Star m (Product (Star m) a b) c -> Star m a (Exponential (Star m) b c) Source #

ArrowApply arr => CCC (WrappedArrow arr :: Type -> Type -> Type) Source # 
Instance details

Defined in Overloaded.Categories

Associated Types

type Exponential (WrappedArrow arr) :: k -> k -> k Source #

Methods

eval :: forall (a :: k) (b :: k). WrappedArrow arr (Product (WrappedArrow arr) (Exponential (WrappedArrow arr) a b) a) b Source #

transpose :: forall (a :: k) (b :: k) (c :: k). WrappedArrow arr (Product (WrappedArrow arr) a b) c -> WrappedArrow arr a (Exponential (WrappedArrow arr) b c) Source #

Overloaded:RecordFields

See GHC.Records.Compat from record-hasfield package.