Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Subsumed the `groupoids` package

  • Loading branch information...
commit b7c7f06241b6ee6bc3da245d787febd31f6d1d47 1 parent b99f4b7
@ekmett authored
View
4 CHANGELOG.markdown
@@ -1,3 +1,7 @@
+3.2
+---
+* Subsumed the `groupoids` package.
+
3.1
---
* Added the [rectangular band](http://en.wikipedia.org/wiki/Band_(mathematics)#Rectangular_bands) `Semigroupoid` for `(,)`. Would that make it a Bandoid?
View
15 semigroupoids.cabal
@@ -1,6 +1,6 @@
name: semigroupoids
category: Control, Comonads
-version: 3.1
+version: 3.2
license: BSD3
cabal-version: >= 1.6
license-file: LICENSE
@@ -9,18 +9,20 @@ maintainer: Edward A. Kmett <ekmett@gmail.com>
stability: provisional
homepage: http://github.com/ekmett/semigroupoids
bug-reports: http://github.com/ekmett/semigroupoids/issues
-copyright: Copyright (C) 2011 Edward A. Kmett
+copyright: Copyright (C) 2011-2013 Edward A. Kmett
build-type: Simple
-synopsis: Haskell 98 semigroupoids: Category sans id
+synopsis: Semigroupoids: Category sans id
extra-source-files:
.ghci
.travis.yml
.gitignore
.vim.custom
description:
- Provides a wide array of semigroupoids and operations for working with semigroupds.
+ Provides a wide array of (semi)groupoids and operations for working with them.
.
- A Semigroupoid is a Category without the requirement of identity arrows for every object in the category.
+ A 'Semigroupoid' is a 'Category' without the requirement of identity arrows for every object in the category.
+ .
+ A 'Category' is any 'Semigroupoid' for which the Yoneda lemma holds.
.
When working with comonads you often have the @\<*\>@ portion of an @Applicative@, but
not the @pure@. This was captured in Uustalu and Vene's \"Essence of Dataflow Programming\"
@@ -28,7 +30,6 @@ description:
.
Similarly many structures are nearly a comonad, but not quite, for instance lists provide a reasonable 'extend' operation in the form of 'tails', but do not always contain a value.
.
- .
Ideally the following relationships would hold:
.
> Traversable <---- Foldable <--- Functor ------> Alt ---------> Plus Semigroupoid
@@ -71,6 +72,8 @@ library
Data.Functor.Bind.Trans
Data.Functor.Plus
Data.Functor.Extend
+ Data.Groupoid
+ Data.Isomorphism
Data.Semigroup.Foldable
Data.Semigroup.Traversable
Data.Semigroupoid
View
18 src/Data/Groupoid.hs
@@ -0,0 +1,18 @@
+{-# LANGUAGE CPP #-}
+#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 702
+{-# LANGUAGE Trustworthy #-}
+#endif
+
+module Data.Groupoid
+ ( Groupoid(..)
+ ) where
+
+import Data.Semigroupoid
+import Data.Semigroupoid.Dual
+
+-- | semigroupoid with inverses. This technically should be a category with inverses, except we need to use Ob to define the valid objects for the category
+class Semigroupoid k => Groupoid k where
+ inv :: k a b -> k b a
+
+instance Groupoid k => Groupoid (Dual k) where
+ inv (Dual k) = Dual (inv k)
View
24 src/Data/Isomorphism.hs
@@ -0,0 +1,24 @@
+{-# LANGUAGE CPP #-}
+#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 702
+{-# LANGUAGE Trustworthy #-}
+#endif
+module Data.Isomorphism
+ ( Iso(..)
+ ) where
+
+import Data.Semigroupoid
+import Data.Groupoid
+import Control.Category
+import Prelude ()
+
+data Iso k a b = Iso { embed :: k a b, project :: k b a }
+
+instance Semigroupoid k => Semigroupoid (Iso k) where
+ Iso f g `o` Iso h i = Iso (f `o` h) (i `o` g)
+
+instance Semigroupoid k => Groupoid (Iso k) where
+ inv (Iso f g) = Iso g f
+
+instance Category k => Category (Iso k) where
+ Iso f g . Iso h i = Iso (f . h) (i . g)
+ id = Iso id id
Please sign in to comment.
Something went wrong with that request. Please try again.