{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-}
module Data.Matroid.Internal
(
fromRk
, namedFromRk
, fromIndep
, namedFromIndep
, fromBasisFilter
, namedFromBasisFilter
, RkMatroid
, IndepMatroid
, BasisFilterMatroid
) where
import Data.Matroid.Typeclass
import Data.Set (Set)
data RkMatroid a = RkM
String
(Set a)
(Set a -> Int)
instance Show a => Show (RkMatroid a) where
show :: RkMatroid a -> String
show (RkM String
name Set a
_ Set a -> Int
_) = String
name
instance (Ord a, Show a) => Matroid RkMatroid a where
groundset :: RkMatroid a -> Set a
groundset (RkM String
_ Set a
e Set a -> Int
_) = Set a
e
showName :: RkMatroid a -> String
showName (RkM String
name Set a
_ Set a -> Int
_) = String
name
rk :: RkMatroid a -> Set a -> Int
rk (RkM String
_ Set a
_ Set a -> Int
r) = Set a -> Int
r
fromRk :: (Show a) => (Set a) -> (Set a -> Int) -> (RkMatroid a)
fromRk :: Set a -> (Set a -> Int) -> RkMatroid a
fromRk Set a
g = String -> Set a -> (Set a -> Int) -> RkMatroid a
forall a. String -> Set a -> (Set a -> Int) -> RkMatroid a
namedFromRk (String
"fromRk (" String -> ShowS
forall a. [a] -> [a] -> [a]
++ (Set a -> String
forall a. Show a => a -> String
show Set a
g) String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
") (rk)") Set a
g
namedFromRk :: String -> (Set a) -> (Set a -> Int) -> (RkMatroid a)
namedFromRk :: String -> Set a -> (Set a -> Int) -> RkMatroid a
namedFromRk = String -> Set a -> (Set a -> Int) -> RkMatroid a
forall a. String -> Set a -> (Set a -> Int) -> RkMatroid a
RkM
data IndepMatroid a = IndepM
String
(Set a)
(Set a -> Bool)
instance Show a => Show (IndepMatroid a) where
show :: IndepMatroid a -> String
show (IndepM String
name Set a
_ Set a -> Bool
_) = String
name
instance (Ord a, Show a) => Matroid IndepMatroid a where
groundset :: IndepMatroid a -> Set a
groundset (IndepM String
_ Set a
e Set a -> Bool
_) = Set a
e
showName :: IndepMatroid a -> String
showName (IndepM String
name Set a
_ Set a -> Bool
_) = String
name
indep :: IndepMatroid a -> Set a -> Bool
indep (IndepM String
_ Set a
_ Set a -> Bool
i) = Set a -> Bool
i
fromIndep :: (Show a) => (Set a) -> (Set a -> Bool) -> (IndepMatroid a)
fromIndep :: Set a -> (Set a -> Bool) -> IndepMatroid a
fromIndep Set a
g = String -> Set a -> (Set a -> Bool) -> IndepMatroid a
forall a. String -> Set a -> (Set a -> Bool) -> IndepMatroid a
namedFromIndep (String
"fromIndep (" String -> ShowS
forall a. [a] -> [a] -> [a]
++ (Set a -> String
forall a. Show a => a -> String
show Set a
g) String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
") (indep)") Set a
g
namedFromIndep :: String -> (Set a) -> (Set a -> Bool) -> (IndepMatroid a)
namedFromIndep :: String -> Set a -> (Set a -> Bool) -> IndepMatroid a
namedFromIndep = String -> Set a -> (Set a -> Bool) -> IndepMatroid a
forall a. String -> Set a -> (Set a -> Bool) -> IndepMatroid a
IndepM
data BasisFilterMatroid a = BasisM
String
(Set a)
(Set a -> Set a)
instance Show a => Show (BasisFilterMatroid a) where
show :: BasisFilterMatroid a -> String
show (BasisM String
name Set a
_ Set a -> Set a
_) = String
name
instance (Ord a,Show a) => Matroid BasisFilterMatroid a where
groundset :: BasisFilterMatroid a -> Set a
groundset (BasisM String
_ Set a
e Set a -> Set a
_) = Set a
e
showName :: BasisFilterMatroid a -> String
showName (BasisM String
name Set a
_ Set a -> Set a
_) = String
name
basis :: BasisFilterMatroid a -> Set a -> Set a
basis (BasisM String
_ Set a
_ Set a -> Set a
b) = Set a -> Set a
b
fromBasisFilter :: (Show a) => (Set a) -> (Set a -> Set a) -> (BasisFilterMatroid a)
fromBasisFilter :: Set a -> (Set a -> Set a) -> BasisFilterMatroid a
fromBasisFilter Set a
g = String -> Set a -> (Set a -> Set a) -> BasisFilterMatroid a
forall a.
String -> Set a -> (Set a -> Set a) -> BasisFilterMatroid a
namedFromBasisFilter (String
"fromBasis (" String -> ShowS
forall a. [a] -> [a] -> [a]
++ (Set a -> String
forall a. Show a => a -> String
show Set a
g) String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
") (basis)") Set a
g
namedFromBasisFilter :: String -> (Set a) -> (Set a -> Set a) -> (BasisFilterMatroid a)
namedFromBasisFilter :: String -> Set a -> (Set a -> Set a) -> BasisFilterMatroid a
namedFromBasisFilter = String -> Set a -> (Set a -> Set a) -> BasisFilterMatroid a
forall a.
String -> Set a -> (Set a -> Set a) -> BasisFilterMatroid a
BasisM