I am interested in generalizing some computing tools for using a Cayley Table , which means a multiplication operation based on a lookup table.
I could create a minimal implementation as follows:
date CayleyTable = CayleyTable {
ct_name :: ByteString,
ct_products :: V.Vector (V.Vector Int)
} deriving (Read, Show)
instance Eq (CayleyTable) where
(==) a b = ct_name a == ct_name b
data CTElement = CTElement {
ct_cayleytable :: CayleyTable,
ct_index :: !Int
}
instance Eq (CTElement) where
(==) a b = assert (ct_cayleytable a == ct_cayleytable b) $
ct_index a == ct_index b
instance Show (CTElement) where
show = ("CTElement" ++) . show . ctp_index
a **** b = assert (ct_cayleytable a == ct_cayleytable b) $
((ct_cayleytable a) ! a) ! b
However, there are many problems with this approach, starting with checking the type of runtime using comparisons ByteString, but including the fact that readit is impossible to get it to work correctly. Any idea how I should do it right?CTElement1, CTElement2 .. Int CTElement, , , IO.
ct_cayleytable, , , ?cayleytable, ,
, , comonad. - comonad - , , ?