fiber-bundles-0.1.0: Fiber bundles and related algebraic structures.

Safe HaskellSafe
LanguageHaskell2010

Data.FiberBundle

Contents

Description

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

Fiber Bundle

class FiberBundle a where Source #

A FiberBundle is composed of:

  • a type a, called the fiber space
  • a type Base a, called the base space
  • a mapping base : a -> Base that maps each point to its corresponding base.

The fiber at b :: Base a is the set of all elements x :: a such that base x = b.

Minimal complete definition

base

Associated Types

type Base a :: * Source #

Methods

base :: a -> Base a Source #

Instances
(FiberBundle a, FiberBundle b) => FiberBundle (Either a b) Source # 
Instance details

Defined in Data.FiberBundle

Associated Types

type Base (Either a b) :: * Source #

Methods

base :: Either a b -> Base (Either a b) Source #

(FiberBundle a, FiberBundle b) => FiberBundle (a, b) Source # 
Instance details

Defined in Data.FiberBundle

Associated Types

type Base (a, b) :: * Source #

Methods

base :: (a, b) -> Base (a, b) Source #

FiberBundle (TrivialBundle b a) Source # 
Instance details

Defined in Data.FiberBundle.Trivial

Associated Types

type Base (TrivialBundle b a) :: * Source #

Methods

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.

Minimal complete definition

combine

Methods

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 # 
Instance details

Defined in Data.FiberBundle

Methods

combine :: Either a b -> Either a b -> Maybe (Either a b) Source #

unsafeCombine :: Either a b -> Either a b -> Either a b Source #

(SemigroupBundle a, SemigroupBundle b) => SemigroupBundle (a, b) Source # 
Instance details

Defined in Data.FiberBundle

Methods

combine :: (a, b) -> (a, b) -> Maybe (a, b) Source #

unsafeCombine :: (a, b) -> (a, b) -> (a, b) Source #

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

Defined in Data.FiberBundle.Trivial

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.

Minimal complete definition

unit

Methods

unit :: Base a -> a Source #

Instances
(MonoidBundle a, MonoidBundle b) => MonoidBundle (Either a b) Source # 
Instance details

Defined in Data.FiberBundle

Methods

unit :: Base (Either a b) -> Either a b Source #

(MonoidBundle a, MonoidBundle b) => MonoidBundle (a, b) Source # 
Instance details

Defined in Data.FiberBundle

Methods

unit :: Base (a, b) -> (a, b) Source #

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

Defined in Data.FiberBundle.Trivial

Methods

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.

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

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.

Minimal complete definition

inverse

Methods

inverse :: a -> a Source #

Instances
(GroupBundle a, GroupBundle b) => GroupBundle (Either a b) Source # 
Instance details

Defined in Data.FiberBundle

Methods

inverse :: Either a b -> Either a b Source #

(GroupBundle a, GroupBundle b) => GroupBundle (a, b) Source # 
Instance details

Defined in Data.FiberBundle

Methods

inverse :: (a, b) -> (a, b) Source #

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

Defined in Data.FiberBundle.Trivial

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 FiberBundles is a pair BundleMorphism f g that preserves fibers. That is, the following diagram commute:

    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 BundleMorphisms to map between Sections.

Constructors

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 #

Checks that unit is a left unit for combine.

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

Checks that unit is a right unit for combine.

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 #

Check that inverse is a left inverse for combine.

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

Check that inverse is a right inverse for combine.

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_monoid :: (MonoidBundle a, MonoidBundle b, Eq b) => BundleMorphism a b -> Base a -> Bool Source #

Checks that the BundleMorphism preserves the unit of each fiber.