A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://wiki.haskell.org/Category_theory/Functor below:

Category theory/Functor - HaskellWiki

Definition of a Functor

Given that 𝒜 and ℬ are categories, a functor F : 𝒜 → ℬ is a pair of mappings ( F o b j e c t s : O b ( 𝒜 ) → O b ( ℬ ) , F a r r o w s : A r ( 𝒜 ) → A r ( ℬ ) ) (the subscripts are generally omitted in practice).

Axioms
  1. If f : A → B in 𝒜 , then F ( f ) : F ( A ) → F ( B ) in ℬ
  2. If f : B → C in 𝒜 and g : A → B in 𝒜 , then F ( f ) ∘ F ( g ) = F ( f ∘ g )
  3. For all objects A in 𝒜 , i d F ( A ) = F ( i d A )
Examples of functors Functor operations

These operations will be important in the definition of a monad.

The category Cat

The existence of identity and composition functors implies that, for any well-defined collection of categories E , there exists a category C a t E whose arrows are all functors between categories in E . Since no category can include itself as an object, there can be no category of all categories, but it is common and useful to designate a category small when the collection of objects is a set, and define Cat to be the category whose objects are all small categories and whose arrows are all functors on small categories.

Functors in Haskell

Properly speaking, a functor in the category Haskell is a pair of a set-theoretic function on Haskell types and a set-theoretic function on Haskell functions satisfying the axioms. However, Haskell being a functional language, Haskellers are only interested in functors where both the object and arrow mappings can be defined and named in Haskell; this effectively restricts them to functors where the object map is a Haskell data constructor and the arrow map is a polymorphic function, the same constraints imposed by the class Functor:

class Functor f where
  fmap :: (a -> b) -> (f a -> f b)
External links

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4