Safe Haskell | Safe |
---|---|

Language | Haskell2010 |

This library defines *fiber bundles*. Fiber bundles can be seen as a set of
*fibers* that have similar structure. These fibers are indexed by a set,
called the *base space*.

This is a structure that is well adapted to many cases where one almost have an algebraic structure, except for some information in the type, which must match for the algebraic operation to happen.

A good example is money. One can add `1 EUR`

to `1 EUR`

, but not to ```
1
USD
```

. That is, one can add the quantities, provided that the currencies are
equals. This means that one can give money the structure of a fiber bundle
whose base space is a set of currencies.

## Synopsis

- class FiberBundle a where
- class FiberBundle a => SemigroupBundle a where
- class SemigroupBundle a => MonoidBundle a where
- unitOf :: MonoidBundle a => a -> a
- isUnit :: (MonoidBundle a, Eq a) => a -> Bool
- class MonoidBundle a => GroupBundle a where
- class SemigroupBundle a => AbelianBundle a
- data BundleMorphism a b = BundleMorphism (a -> b) (Base a -> Base b)
- monoidBundleMorphism :: (MonoidBundle a, FiberBundle b) => (a -> b) -> BundleMorphism a b
- prop_SemigroupBundle_combine_base :: (SemigroupBundle a, Eq (Base a)) => a -> a -> Bool
- prop_SemigroupBundle_combine_associative :: (SemigroupBundle a, Eq a) => a -> a -> a -> Bool
- prop_MonoidBundle_unit_left :: (MonoidBundle a, Eq a) => a -> Bool
- prop_MonoidBundle_unit_right :: (MonoidBundle a, Eq a) => a -> Bool
- prop_GroupBundle_inverse_base :: (GroupBundle a, Eq (Base a)) => a -> Bool
- prop_GroupBundle_inverse_combine_left :: (GroupBundle a, Eq a) => a -> Bool
- prop_GroupBundle_inverse_combine_right :: (GroupBundle a, Eq a) => a -> Bool
- prop_AbelianBundle_combine_commutative :: (AbelianBundle a, Eq a) => a -> a -> Bool
- prop_BundleMorphism_fiber_preserving :: (FiberBundle a, FiberBundle b, Eq (Base b)) => BundleMorphism a b -> a -> Bool
- prop_BundleMorphism_semigroup :: (SemigroupBundle a, SemigroupBundle b, Eq b) => BundleMorphism a b -> a -> a -> Bool
- prop_BundleMorphism_monoid :: (MonoidBundle a, MonoidBundle b, Eq b) => BundleMorphism a b -> Base a -> Bool
- prop_BundleMorphism_group :: (GroupBundle a, GroupBundle b, Eq b) => BundleMorphism a b -> a -> Bool

# Fiber Bundle

class FiberBundle a where Source #

A `FiberBundle`

is composed of:

- a type
`a`

, called the*fiber space* - a type

, called the`Base`

a*base space* - a mapping

that maps each point to its corresponding base.`base`

: a ->`Base`

The *fiber* at `b :: `

is the set of all elements `Base`

a`x :: a`

such that
`base x = b`

.

## Instances

(FiberBundle a, FiberBundle b) => FiberBundle (Either a b) Source # | |

(FiberBundle a, FiberBundle b) => FiberBundle (a, b) Source # | |

FiberBundle (TrivialBundle b a) Source # | |

Defined in Data.FiberBundle.Trivial type Base (TrivialBundle b a) :: * Source # base :: TrivialBundle b a -> Base (TrivialBundle b a) Source # |

# Semigroup Bundle

class FiberBundle a => SemigroupBundle a where Source #

A `SemigroupBundle`

is a `FiberBundle`

whose fibers have a `Semigroup`

structure. We represent this structure by a partial function `combine`

that
has the following semantics: given `x`

and `y`

, if they belong to the same
fiber, we return `Just`

their combination, otherwise, we return
`Nothing`

.

combine :: a -> a -> Maybe a Source #

unsafeCombine :: a -> a -> a Source #

An unsafe version of `combine`

that assumes that both arguments are in
the same fiber. Errors otherwise.

## Instances

(SemigroupBundle a, SemigroupBundle b) => SemigroupBundle (Either a b) Source # | |

(SemigroupBundle a, SemigroupBundle b) => SemigroupBundle (a, b) Source # | |

Defined in Data.FiberBundle | |

(Eq b, Semigroup a) => SemigroupBundle (TrivialBundle b a) Source # | |

Defined in Data.FiberBundle.Trivial combine :: TrivialBundle b a -> TrivialBundle b a -> Maybe (TrivialBundle b a) Source # unsafeCombine :: TrivialBundle b a -> TrivialBundle b a -> TrivialBundle b a Source # |

# Monoid Bundle

class SemigroupBundle a => MonoidBundle a where Source #

A `MonoidBundle`

is a `FiberBundle`

whose fibers have a `Monoid`

structure. That is, for each fiber we have an `unit`

element that is the
neutral element for `combine`

.

## Instances

(MonoidBundle a, MonoidBundle b) => MonoidBundle (Either a b) Source # | |

(MonoidBundle a, MonoidBundle b) => MonoidBundle (a, b) Source # | |

Defined in Data.FiberBundle | |

(Eq b, Monoid a) => MonoidBundle (TrivialBundle b a) Source # | |

Defined in Data.FiberBundle.Trivial unit :: Base (TrivialBundle b a) -> TrivialBundle b a Source # |

unitOf :: MonoidBundle a => a -> a Source #

Get the unit element on the fiber of the given element.

# Group Bundle

class MonoidBundle a => GroupBundle a where Source #

A `GroupBundle`

is a `FiberBundle`

whose fibers have a `Group`

structure.
That is, we can `inverse`

any element, keeping it on the same fiber. This
inversed element is the inverse with relation to `combine`

.

## Instances

(GroupBundle a, GroupBundle b) => GroupBundle (Either a b) Source # | |

(GroupBundle a, GroupBundle b) => GroupBundle (a, b) Source # | |

Defined in Data.FiberBundle | |

(Eq b, Group a) => GroupBundle (TrivialBundle b a) Source # | |

Defined in Data.FiberBundle.Trivial inverse :: TrivialBundle b a -> TrivialBundle b a Source # |

# Abelian Bundle

class SemigroupBundle a => AbelianBundle a Source #

A `AbelianBundle`

is a `FiberBundle`

whose fibers have an abelian
`Semigroup`

structure. That is, the `combine`

operation is commutative.

# Bundle Morphism

data BundleMorphism a b Source #

A morphism between two `FiberBundle`

s is a pair

that preserves fibers. That is, the following diagram commute:`BundleMorphism`

f g

g . base = base . f f a ------------> b | | base | | base V V Base a --------> Base b g

This morphism can have extra properties, such as preserving the `Semigroup`

,
`Monoid`

or `Group`

structure of fibers. See the corresponding QuickCheck
properties below for more details.

One of the uses of `BundleMorphism`

s to map between
`Section`

s.

BundleMorphism (a -> b) (Base a -> Base b) |

monoidBundleMorphism :: (MonoidBundle a, FiberBundle b) => (a -> b) -> BundleMorphism a b Source #

In a `MonoidBundle`

any function `a -> b`

has a corresponding function
`Base a -> Base b`

, namely `base . f . unit`

. This pair corresponds to a
lawful `BundleMorphism`

if:

base . f . unitOf = base . f

# QuickCheck Properties

prop_SemigroupBundle_combine_base :: (SemigroupBundle a, Eq (Base a)) => a -> a -> Bool Source #

Checks that `combine`

returns a result if and only if the arguments belong
to the same fiber.

prop_SemigroupBundle_combine_associative :: (SemigroupBundle a, Eq a) => a -> a -> a -> Bool Source #

Checks that `combine`

is associative.

prop_MonoidBundle_unit_left :: (MonoidBundle a, Eq a) => a -> Bool Source #

prop_MonoidBundle_unit_right :: (MonoidBundle a, Eq a) => a -> Bool Source #

prop_GroupBundle_inverse_base :: (GroupBundle a, Eq (Base a)) => a -> Bool Source #

Check that `inverse`

preserves the fiber.

prop_GroupBundle_inverse_combine_left :: (GroupBundle a, Eq a) => a -> Bool Source #

prop_GroupBundle_inverse_combine_right :: (GroupBundle a, Eq a) => a -> Bool Source #

prop_AbelianBundle_combine_commutative :: (AbelianBundle a, Eq a) => a -> a -> Bool Source #

Checks that `combine`

is commutative.

prop_BundleMorphism_fiber_preserving :: (FiberBundle a, FiberBundle b, Eq (Base b)) => BundleMorphism a b -> a -> Bool Source #

Checks that the `BundleMorphism`

preserves fibers.

prop_BundleMorphism_semigroup :: (SemigroupBundle a, SemigroupBundle b, Eq b) => BundleMorphism a b -> a -> a -> Bool Source #

Checks that the `BundleMorphism`

preserves `combine`

.

prop_BundleMorphism_monoid :: (MonoidBundle a, MonoidBundle b, Eq b) => BundleMorphism a b -> Base a -> Bool Source #

Checks that the `BundleMorphism`

preserves the `unit`

of each fiber.

prop_BundleMorphism_group :: (GroupBundle a, GroupBundle b, Eq b) => BundleMorphism a b -> a -> Bool Source #

Checks that the `BundleMorphism`

preserves `inverse`

.