Skip to content

Commit

Permalink
write out todo plan for moving to generic test API
Browse files Browse the repository at this point in the history
  • Loading branch information
jitwit committed May 30, 2020
1 parent 88cb98a commit 95dd3f0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
7 changes: 2 additions & 5 deletions src/Algebra/Graph/NonEmpty/AdjacencyIntMap.hs
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,12 @@ import Prelude hiding (reverse)
import Control.DeepSeq
import Data.Coerce
import Data.List ((\\))
import Data.List.NonEmpty (NonEmpty (..), nonEmpty, toList, reverse)
import Data.Maybe
import Data.List.NonEmpty (NonEmpty (..), toList, reverse, fromList)
import Data.IntSet (IntSet)
import Data.Set (Set)
import Data.Tree
import GHC.Generics

import Algebra.Graph.Internal

import qualified Algebra.Graph.AdjacencyIntMap as AIM
import qualified Data.IntSet as IntSet

Expand Down Expand Up @@ -378,7 +375,7 @@ edgeCount = coerce AIM.edgeCount
-- vertexList1 . 'vertices1' == 'Data.List.NonEmpty.nub' . 'Data.List.NonEmpty.sort'
-- @
vertexList1 :: AdjacencyIntMap -> NonEmpty Int
vertexList1 = unsafeNonEmpty . coerce AIM.vertexList
vertexList1 = fromList . coerce AIM.vertexList

-- | The sorted list of edges of a graph.
-- Complexity: /O(n + m)/ time and /O(m)/ memory.
Expand Down
7 changes: 2 additions & 5 deletions src/Algebra/Graph/NonEmpty/AdjacencyMap.hs
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,12 @@ import Prelude hiding (reverse)
import Control.DeepSeq
import Data.Coerce
import Data.List ((\\))
import Data.List.NonEmpty (NonEmpty (..), nonEmpty, toList, reverse)
import Data.Maybe
import Data.List.NonEmpty (NonEmpty (..), toList, reverse, fromList)
import Data.Set (Set)
import Data.String
import Data.Tree
import GHC.Generics

import Algebra.Graph.Internal

import qualified Algebra.Graph.AdjacencyMap as AM
import qualified Data.Set as Set

Expand Down Expand Up @@ -375,7 +372,7 @@ edgeCount = coerce AM.edgeCount
-- vertexList1 . 'vertices1' == 'Data.List.NonEmpty.nub' . 'Data.List.NonEmpty.sort'
-- @
vertexList1 :: AdjacencyMap a -> NonEmpty a
vertexList1 = unsafeNonEmpty . coerce AM.vertexList
vertexList1 = fromList . coerce AM.vertexList

-- | The sorted list of edges of a graph.
-- Complexity: /O(n + m)/ time and /O(m)/ memory.
Expand Down
14 changes: 13 additions & 1 deletion test/Algebra/Graph/Test/API.hs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,19 @@ instance Show g => Show (Mono g a) where
toIntAPI :: API g Ord -> API g ((~) Int)
toIntAPI API{..} = API{..}

-- TODO: Add missing API entries for Acyclic, NonEmpty and Symmetric graphs.
-- TODO: Add missing API entries for Acyclic, NonEmpty and Symmetric
-- graphs. Here is a blueprint initially discussed in
-- https://github.com/snowleopard/alga/pull/250 (adding nonempty
-- aims):
-- 1. Extend data API g c with new fields that correspond to
-- missing methods (most of them end with the suffix 1).
-- 2. Add tests for missing methods to Test.Generic or
-- Test.Generic.NonEmpty -- whichever turns out to be
-- clearer/more convenient.
-- 3. Consider/decide whether or not ToGraph are useful or needed
-- 4. Tests for non-empty modules would need to import API,
-- Generic and perhaps also Generic.NonEmpty (if it turns out to
-- be convenient).
-- | The complete graph API dictionary. A graph data type, such as 'G.Graph',
-- typically implements only a part of the whole API.
data API g c where
Expand Down

0 comments on commit 95dd3f0

Please sign in to comment.