Skip to content

Commit

Permalink
Drop Fold, simplify ToGraph, refactor testsuite (#205)
Browse files Browse the repository at this point in the history
This revision addresses a few issues:

* Improves the testsuite (#13) by switching to simpler graph `API` type class.

* Simplifies the `ToGraph` class, as discussed in #151.

* Removes `Algebra.Graph.Fold` which, while cool, appears to be useless in practice.

* Removes dependencies on `base-compat` and `base-orphans`, which are no longer critical.
  • Loading branch information
snowleopard authored May 27, 2019
1 parent c82eea5 commit c20d1b2
Show file tree
Hide file tree
Showing 42 changed files with 798 additions and 1,303 deletions.
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## 0.5

* #205: Drop dependencies on `base-compat` and `base-orphans`.
* #205: Remove `Algebra.Graph.Fold`.
* #151: Remove `ToGraph.size`. Demote `ToGraph.adjacencyMap`,
`ToGraph.adjacencyIntMap`, `ToGraph.adjacencyMapTranspose` and
`ToGraph.adjacencyIntMapTranspose` to functions.
* #204: Derive `Generic` and `NFData` for `Algebra.Graph` and `Algebra.Graph.Labelled`.
* #172: Stop supporting GHC 7.8.4.

## 0.4
Expand Down
11 changes: 3 additions & 8 deletions algebraic-graphs.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ description:
<http://hackage.haskell.org/package/algebraic-graphs/docs/Algebra-Graph-Class.html Algebra.Graph.Class>
and
<http://hackage.haskell.org/package/algebraic-graphs/docs/Algebra-Graph-HigherKinded-Class.html Algebra.Graph.HigherKinded.Class>
can be used for polymorphic construction and manipulation of graphs. Also see
<http://hackage.haskell.org/package/algebraic-graphs/docs/Algebra-Graph-Fold.html Algebra.Graph.Fold>
that defines the Boehm-Berarducci encoding of algebraic graphs.
can be used for polymorphic construction and manipulation of graphs.
.
This is an experimental library and the API is expected to remain unstable until version 1.0.0.
Please consider contributing to the on-going
Expand All @@ -77,7 +75,6 @@ library
Algebra.Graph.Class,
Algebra.Graph.Export,
Algebra.Graph.Export.Dot,
Algebra.Graph.Fold,
Algebra.Graph.HigherKinded.Class,
Algebra.Graph.Internal,
Algebra.Graph.Label,
Expand All @@ -101,7 +98,6 @@ library
Data.Graph.Typed
build-depends: array >= 0.4 && < 0.6,
base >= 4.7 && < 5,
base-compat >= 0.9.1 && < 0.11,
containers >= 0.5.5.1 && < 0.8,
deepseq >= 1.3.0.1 && < 1.5,
mtl >= 2.1 && < 2.3
Expand Down Expand Up @@ -137,7 +133,6 @@ test-suite test-alga
Algebra.Graph.Test.AdjacencyMap,
Algebra.Graph.Test.Arbitrary,
Algebra.Graph.Test.Export,
Algebra.Graph.Test.Fold,
Algebra.Graph.Test.Generic,
Algebra.Graph.Test.Graph,
Algebra.Graph.Test.Internal,
Expand All @@ -153,8 +148,6 @@ test-suite test-alga
build-depends: algebraic-graphs,
array >= 0.4 && < 0.6,
base >= 4.7 && < 5,
base-compat >= 0.9.1 && < 0.11,
base-orphans >= 0.5.4 && < 0.9,
containers >= 0.5.5.1 && < 0.8,
extra >= 1.4 && < 2,
QuickCheck >= 2.10 && < 2.14
Expand All @@ -180,5 +173,7 @@ test-suite test-alga
TypeFamilies
other-extensions: ConstrainedClassMethods
ConstraintKinds
CPP
MultiParamTypeClasses
RankNTypes
ViewPatterns
7 changes: 2 additions & 5 deletions src/Algebra/Graph.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
-----------------------------------------------------------------------------
-- |
-- Module : Algebra.Graph
-- Copyright : (c) Andrey Mokhov 2016-2018
-- Copyright : (c) Andrey Mokhov 2016-2019
-- License : MIT (see the file LICENSE)
-- Maintainer : [email protected]
-- Stability : experimental
Expand Down Expand Up @@ -50,12 +50,9 @@ module Algebra.Graph (
Context (..), context
) where

import Prelude ()
import Prelude.Compat

import Control.Applicative (Alternative)
import Control.DeepSeq (NFData (..))
import Control.Monad.Compat
import Control.Monad (MonadPlus (..))
import Control.Monad.State (runState, get, put)
import Data.Foldable (toList)
import Data.Maybe (fromMaybe)
Expand Down
12 changes: 4 additions & 8 deletions src/Algebra/Graph/AdjacencyIntMap/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
-----------------------------------------------------------------------------
-- |
-- Module : Algebra.Graph.AdjacencyIntMap.Internal
-- Copyright : (c) Andrey Mokhov 2016-2018
-- Copyright : (c) Andrey Mokhov 2016-2019
-- License : MIT (see the file LICENSE)
-- Maintainer : [email protected]
-- Stability : unstable
Expand All @@ -14,19 +14,15 @@
module Algebra.Graph.AdjacencyIntMap.Internal (
-- * Adjacency map implementation
AdjacencyIntMap (..), consistent
) where
) where

import Prelude ()
import Prelude.Compat hiding (null)

import Data.Monoid (Sum (..))
import Control.DeepSeq (NFData (..))
import Data.IntMap.Strict (IntMap, keysSet, fromSet)
import Data.IntSet (IntSet)
import Data.List
import Data.Monoid (Sum (..))
import GHC.Generics

import Control.DeepSeq (NFData (..))

import qualified Data.IntMap.Strict as IntMap
import qualified Data.IntSet as IntSet

Expand Down
7 changes: 2 additions & 5 deletions src/Algebra/Graph/AdjacencyMap/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
-----------------------------------------------------------------------------
-- |
-- Module : Algebra.Graph.AdjacencyMap.Internal
-- Copyright : (c) Andrey Mokhov 2016-2018
-- Copyright : (c) Andrey Mokhov 2016-2019
-- License : MIT (see the file LICENSE)
-- Maintainer : [email protected]
-- Stability : unstable
Expand All @@ -14,10 +14,7 @@
module Algebra.Graph.AdjacencyMap.Internal (
-- * Adjacency map implementation
AdjacencyMap (..), consistent, internalEdgeList, referredToVertexSet
) where

import Prelude ()
import Prelude.Compat hiding (null)
) where

import Control.DeepSeq
import Data.List
Expand Down
14 changes: 1 addition & 13 deletions src/Algebra/Graph/Class.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
-- implemented fully polymorphically and require the use of an intermediate data
-- type are not included. For example, to compute the number of vertices in a
-- 'Graph' expression you will need to use a concrete data type, such as
-- "Algebra.Graph.Fold". Other useful 'Graph' instances are defined in
-- "Algebra.Graph", "Algebra.Graph.AdjacencyMap" and "Algebra.Graph.Relation".
-- "Algebra.Graph.Graph" or "Algebra.Graph.AdjacencyMap".
--
-- See "Algebra.Graph.HigherKinded.Class" for the higher-kinded version of the
-- core graph type class.
Expand Down Expand Up @@ -47,9 +46,6 @@ module Algebra.Graph.Class (
path, circuit, clique, biclique, star, tree, forest
) where

import Prelude ()
import Prelude.Compat

import Data.Tree

import Algebra.Graph.Label (Dioid, one)
Expand All @@ -58,7 +54,6 @@ import qualified Algebra.Graph as G
import qualified Algebra.Graph.AdjacencyMap as AM
import qualified Algebra.Graph.Labelled as LG
import qualified Algebra.Graph.Labelled.AdjacencyMap as LAM
import qualified Algebra.Graph.Fold as F
import qualified Algebra.Graph.AdjacencyIntMap as AIM
import qualified Algebra.Graph.Relation as R
import qualified Algebra.Graph.Relation.Symmetric as RS
Expand Down Expand Up @@ -136,13 +131,6 @@ instance Ord a => Graph (AM.AdjacencyMap a) where
overlay = AM.overlay
connect = AM.connect

instance Graph (F.Fold a) where
type Vertex (F.Fold a) = a
empty = F.empty
vertex = F.vertex
overlay = F.overlay
connect = F.connect

instance Graph AIM.AdjacencyIntMap where
type Vertex AIM.AdjacencyIntMap = Int
empty = AIM.empty
Expand Down
8 changes: 3 additions & 5 deletions src/Algebra/Graph/Export.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
-----------------------------------------------------------------------------
-- |
-- Module : Algebra.Graph.Export
-- Copyright : (c) Andrey Mokhov 2016-2018
-- Copyright : (c) Andrey Mokhov 2016-2019
-- License : MIT (see the file LICENSE)
-- Maintainer : [email protected]
-- Stability : experimental
Expand All @@ -23,14 +23,12 @@ module Algebra.Graph.Export (

-- * Generic graph export
export
) where

import Prelude ()
import Prelude.Compat hiding (unlines)
) where

import Data.Foldable (fold)
import Data.Semigroup
import Data.String hiding (unlines)
import Prelude hiding (unlines)

import Algebra.Graph.ToGraph (ToGraph, ToVertex, toAdjacencyMap)
import Algebra.Graph.AdjacencyMap (vertexList, edgeList)
Expand Down
2 changes: 1 addition & 1 deletion src/Algebra/Graph/Export/Dot.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module Algebra.Graph.Export.Dot (

-- * Export functions
export, exportAsIs, exportViaShow
) where
) where

import Data.List hiding (unlines)
import Data.Monoid
Expand Down
Loading

0 comments on commit c20d1b2

Please sign in to comment.