Commit ad9fad1b authored by Hans-Peter Deifel's avatar Hans-Peter Deifel 🐢

Replace even more instances of h1 with f1

parent d4204e70
......@@ -129,13 +129,13 @@ withEdges =
benchInit :: String -> [Bool] -> [(State, State)] -> Benchmark
benchInit name h1s transitions =
benchInit name f1s transitions =
env
(return (enc h1s transitions))
(return (enc f1s transitions))
(bench name . whnfIO . stToIO . initialize')
enc :: [Bool] -> [(State, State)] -> Encoding () Bool
enc h1s transitions = Encoding.new (V.fromList h1s) edges
enc f1s transitions = Encoding.new (V.fromList f1s) edges
where
edges = V.fromList (map mkEdge transitions)
mkEdge (from, to) = Encoding.Edge from () to
......
......@@ -39,33 +39,33 @@ import qualified Copar.Parser.Lexer as L
import Copar.Parser.Types
import Copar.Coalgebra.Parser.Class
newState :: MorphParser l h1 State
newState :: MorphParser l f1 State
newState = nextState <<%= succ
{-# INLINE newState #-}
defineSymbol :: Text -> MorphParser l h1 State
defineSymbol :: Text -> MorphParser l f1 State
defineSymbol sym = use (symbolTable . at sym) >>= \case
Just (_, Defined) -> fail $ T.unpack sym ++ "defined twice" -- TODO: Better error
Just (x, Undefined) -> define x
Nothing -> newState >>= define
where
define :: State -> MorphParser l h1 State
define :: State -> MorphParser l f1 State
define node = (symbolTable . at sym .= Just (node, Defined))
*> return node
{-# INLINE defineSymbol #-}
lookupSymbol :: Text -> MorphParser l h1 State
lookupSymbol :: Text -> MorphParser l f1 State
lookupSymbol sym = use (symbolTable . at sym) >>= \case
Nothing -> do { x <- newState; markUndefined x; return x }
Just (x, _) -> return x
where
markUndefined :: State -> MorphParser l h1 ()
markUndefined :: State -> MorphParser l f1 ()
markUndefined node = symbolTable . at sym .= Just (node, Undefined)
{-# INLINE lookupSymbol #-}
checkUndefinedRefs :: MorphParser l h1 ()
checkUndefinedRefs :: MorphParser l f1 ()
checkUndefinedRefs = use (symbolTable . to M.toList . to (filter isUndefined)) >>= \case
[] -> return ()
((sym,_):_) -> fail $ T.unpack sym ++ " is undefined"
......@@ -80,17 +80,17 @@ finalizeState :: forall f.
ParserState (Label f) (F1 f) -> (SymbolTable, Encoding (Label (Desorted f)) (F1 (Desorted f)))
finalizeState state =
let
h1s = state ^. h1Map
h1Vec = V.create $ do
v <- VM.unsafeNew (M.size h1s)
forM_ (M.toList h1s) $ \(i, h1) -> VM.unsafeWrite v i h1
f1s = state ^. f1Map
f1Vec = V.create $ do
v <- VM.unsafeNew (M.size f1s)
forM_ (M.toList f1s) $ \(i, f1) -> VM.unsafeWrite v i f1
return v
!edges = V.concat (state ^. graph)
!symTab = M.fromList (map swap (M.toList (fmap fst (state ^. symbolTable))))
in
( SymbolTable symTab
, bimap (mkDesortedLabel @f) id (Encoding.new h1Vec edges)
, bimap (mkDesortedLabel @f) id (Encoding.new f1Vec edges)
)
morphismsParser :: forall f.
......@@ -107,14 +107,14 @@ morphismsParser (Functor sort f) = finalizeState @f <$> (execStateT p initState)
parsePoint = do
from <- L.name >>= defineSymbol
void $ L.symbol ":"
(h1, succs) <- parseMorphismPoint (fmap wrapper f)
(f1, succs) <- parseMorphismPoint (fmap wrapper f)
L.newlinesOrEof
!succs' <- V.forM succs $ \(to, l) ->
return $! Encoding.Edge from (Sorted sort l) to
graph %= (succs':)
h1Map %= M.insert from (Sorted sort h1)
f1Map %= M.insert from (Sorted sort f1)
parseMorphisms ::
(Functor f, ParseMorphism f)
......@@ -132,11 +132,11 @@ wrapper ::
wrapper Variable = L.name >>= lookupSymbol
wrapper (Functor nextSort f) = do
from <- newState
(h1, succs) <- parseMorphismPoint (fmap wrapper f)
(f1, succs) <- parseMorphismPoint (fmap wrapper f)
!succs' <- V.forM succs $ \(to, l) ->
return $! Encoding.Edge from (Sorted nextSort l) to
graph %= (succs':)
h1Map %= M.insert from (Sorted nextSort h1)
f1Map %= M.insert from (Sorted nextSort f1)
return from
......@@ -10,10 +10,10 @@ import Copar.Coalgebra.Parser.Internal
import Copar.Coalgebra.RefinementTypes
import Copar.Parser.Types
type MorphParser l h1 = StateT (ParserState l h1) Parser
type MorphParser l f1 = StateT (ParserState l f1) Parser
class ParseMorphism f where
parseMorphismPoint
:: (Ord x)
=> f (MorphParser l h1 x)
-> MorphParser l h1 (F1 f, Vector (x, Label f))
=> f (MorphParser l f1 x)
-> MorphParser l f1 (F1 f, Vector (x, Label f))
......@@ -4,7 +4,7 @@
module Copar.Coalgebra.Parser.Internal
( ParserState(..)
, graph
, h1Map
, f1Map
, symbolTable
, nextState
, Symbol(..)
......@@ -22,18 +22,18 @@ import Copar.FunctorExpression.Sorts (Sorted)
data Symbol = Defined | Undefined
deriving (Eq)
data ParserState l h1 = ParserState
data ParserState l f1 = ParserState
{ _graph :: [Vector (Edge (Sorted l))]
, _h1Map :: M.HashMap State (Sorted h1)
, _f1Map :: M.HashMap State (Sorted f1)
, _symbolTable :: M.HashMap Text (State, Symbol)
, _nextState :: Int
}
makeLenses ''ParserState
initState :: ParserState l h1
initState :: ParserState l f1
initState = ParserState
{ _graph = []
, _h1Map = M.empty
, _f1Map = M.empty
, _symbolTable = M.empty
, _nextState = 0
}
......@@ -35,10 +35,10 @@ defaultDotConfig = DotConfig
}
printDot ::
(PrettyShow label, PrettyShow h1)
(PrettyShow label, PrettyShow f1)
=> DotConfig
-> SymbolTable
-> Encoding label (Sorted h1)
-> Encoding label (Sorted f1)
-> Maybe Partition
-> IO ()
printDot config symbolTable encoding maybePartition =
......@@ -46,11 +46,11 @@ printDot config symbolTable encoding maybePartition =
(Build.toLazyText (dot config symbolTable encoding maybePartition))
writeDot ::
(PrettyShow label, PrettyShow h1)
(PrettyShow label, PrettyShow f1)
=> FilePath
-> DotConfig
-> SymbolTable
-> Encoding label (Sorted h1)
-> Encoding label (Sorted f1)
-> Maybe Partition
-> IO ()
writeDot file config symbolTable encoding maybePartition =
......@@ -59,10 +59,10 @@ writeDot file config symbolTable encoding maybePartition =
(Build.toLazyText (dot config symbolTable encoding maybePartition)))
dot ::
(PrettyShow label, PrettyShow h1)
(PrettyShow label, PrettyShow f1)
=> DotConfig
-> SymbolTable
-> Encoding label (Sorted h1)
-> Encoding label (Sorted f1)
-> Maybe Partition
-> Builder
dot config symbolTable encoding maybePartition =
......@@ -82,10 +82,10 @@ dot config symbolTable encoding maybePartition =
"}\n"
cluster ::
PrettyShow h1
PrettyShow f1
=> DotConfig
-> SymbolTable
-> Vector (Sorted h1)
-> Vector (Sorted f1)
-> Int
-> [Int]
-> Builder
......@@ -95,10 +95,10 @@ cluster config symbolTable structure block states =
"}\n"
nodes ::
PrettyShow h1
PrettyShow f1
=> DotConfig
-> SymbolTable
-> Vector (Sorted h1)
-> Vector (Sorted f1)
-> [Int]
-> Builder
nodes config symbolTable structure =
......@@ -107,21 +107,21 @@ nodes config symbolTable structure =
getSymbol i = HM.lookup i (fromSymbolTable symbolTable)
node ::
PrettyShow h1 => DotConfig -> Int -> Maybe Text -> (Sorted h1) -> Builder
node config i name h1 =
PrettyShow f1 => DotConfig -> Int -> Maybe Text -> (Sorted f1) -> Builder
node config i name f1 =
let label =
case name of
Nothing -> h1text
Just n -> Build.fromText n <> "\\n" <> h1text
color = sortColor (sortedSort h1)
Nothing -> f1text
Just n -> Build.fromText n <> "\\n" <> f1text
color = sortColor (sortedSort f1)
in " s" <> Build.decimal i <> " [label=\"" <> label <> "\", " <>
"style=\"filled\", fillcolor=\"" <>
color <>
"\"]"
where
h1text =
f1text =
if nodeLabels config
then Build.fromText (escape (prettyShow (sortedElem h1)))
then Build.fromText (escape (prettyShow (sortedElem f1)))
else ""
transitions ::
......
......@@ -44,9 +44,9 @@ instance RefinementInterface f => RefinementInterface (Desorted f) where
{-# SPECIALIZE instance RefinementInterface (Desorted SomeFunctor) #-}
#ifdef RELEASE
init (Sorted sort h1) labels = init @f h1 labels
init (Sorted sort f1) labels = init @f f1 labels
#else
init (Sorted sort h1) labels = Sorted sort (init @f h1 (filterBySort sort labels))
init (Sorted sort f1) labels = Sorted sort (init @f f1 (filterBySort sort labels))
#endif
#ifdef RELEASE
......
......@@ -151,15 +151,15 @@ instance RefinementInterface AbsorbingPolynomial where
:: F1 AbsorbingPolynomial
-> [Label AbsorbingPolynomial]
-> Weight AbsorbingPolynomial
init h1 labels =
smallArrayFromListN (sizeofSmallArray (polyF1Variables h1)) $ map
init f1 labels =
smallArrayFromListN (sizeofSmallArray (polyF1Variables f1)) $ map
(\(i, x) -> (maybe PolyWeightToSub (PolyWeightWrapped . initInner i)) x)
(zip [0 ..] (toList (polyF1Variables h1)))
(zip [0 ..] (toList (polyF1Variables f1)))
where
initInner i innerF1 =
init @SomeFunctor innerF1 (catMaybes $ labelsByIndex V.! i)
labelsByIndex = V.create $ do
v <- VM.replicate (sizeofSmallArray (polyF1Variables h1)) []
v <- VM.replicate (sizeofSmallArray (polyF1Variables f1)) []
forM_ labels $ \(PolyLabel i l) -> VM.modify v (l :) i
return v
......@@ -211,18 +211,18 @@ instance RefinementInterface AbsorbingPolynomial where
-- | Parse morphism for inner functor
--
-- If the inner value is just a variable, return (Nothing, [(x, Nothing)]). If
-- the inner value is a wrapped functor, return (h1, labels) that the inner
-- the inner value is a wrapped functor, return (f1, labels) that the inner
-- parser returns, wrapped in 'Just' constructors.
parseInner
:: Ord x
=> Inner (MorphParser l h1 x)
=> Inner (MorphParser l f1 x)
-> MorphParser
l
h1
f1
(Maybe (F1 SomeFunctor), Vector (x, Maybe (Label SomeFunctor)))
parseInner (Absorbed inner) = do
(h1, labels) <- parseMorphismPoint inner
return (Just h1, V.map (second Just) labels)
(f1, labels) <- parseMorphismPoint inner
return (Just f1, V.map (second Just) labels)
parseInner (Direct inner) = do
x <- inner
return (Nothing, V.singleton (x, Nothing))
......@@ -238,10 +238,10 @@ instance ParseMorphism AbsorbingPolynomial where
-- on the number of co-factors.
parseSum1
:: Ord a
=> Sum (Inner (MorphParser l h1 a))
=> Sum (Inner (MorphParser l f1 a))
-> MorphParser
l
h1
f1
(F1 AbsorbingPolynomial, Vector (a, Label AbsorbingPolynomial))
parseSum1 sum@(Sum (_ :| [])) = do
-- only a single summand => parse product directly
......@@ -265,11 +265,11 @@ parseSumPrefix = L.symbol "inj" *> L.decimal
-- | Parse an injection into the coproduct with the syntax 'inj i _'
parseSum
:: Ord a
=> Sum (Inner (MorphParser l h1 a))
=> Sum (Inner (MorphParser l f1 a))
-> Int
-> MorphParser
l
h1
f1
(F1 AbsorbingPolynomial, Vector (a, Label AbsorbingPolynomial))
parseSum (Sum summands) i = do
when (i < 0 || i >= length summands)
......@@ -277,7 +277,7 @@ parseSum (Sum summands) i = do
(constants, successors) <- parseProduct1 (summands NonEmpty.!! i)
let
h1 = PolyF1
f1 = PolyF1
{ polyF1Summand = i
, polyF1Constants = constants
, polyF1Variables =
......@@ -285,7 +285,7 @@ parseSum (Sum summands) i = do
successors
}
return (h1, foldMap snd successors)
return (f1, foldMap snd successors)
----------- Products parser
......@@ -293,10 +293,10 @@ parseSum (Sum summands) i = do
-- | Parse either a single factor without parens or a tuple.
parseProduct1
:: Ord a
=> Product (Inner (MorphParser l h1 a))
=> Product (Inner (MorphParser l f1 a))
-> MorphParser
l
h1
f1
( VU.Vector Int
, Vector (Maybe (F1 SomeFunctor), Vector (a, PolyLabel))
)
......@@ -312,10 +312,10 @@ parseProduct1 other = parseProduct other
parseProduct
:: Ord a
=> Product (Inner (MorphParser l h1 a))
=> Product (Inner (MorphParser l f1 a))
-> MorphParser
l
h1
f1
( VU.Vector Int
, Vector (Maybe (F1 SomeFunctor), Vector (a, PolyLabel))
)
......@@ -334,14 +334,14 @@ parseProduct (Product l@(f :| fs)) =
----------- Factor parser
-- | Returns either the value of a constants, or (h1, successors) for every
-- | Returns either the value of a constants, or (f1, successors) for every
-- inner functor (There can be more than one because of exponentials).
parseFactor
:: Ord a
=> Factor (Inner (MorphParser l h1 a))
=> Factor (Inner (MorphParser l f1 a))
-> MorphParser
l
h1
f1
( Either
Int
( Vector
......@@ -351,8 +351,8 @@ parseFactor
)
)
parseFactor (Const (ExplicitSet names)) = do
!h1 <- Left <$> someName names
return h1 -- const has no successors
!f1 <- Left <$> someName names
return f1 -- const has no successors
parseFactor (Const IntSet) = do
x <- L.signed L.decimal <?> "integer"
return (Left x)
......
......@@ -54,9 +54,9 @@ instance ParseMorphism Bag where
parseMorphismPoint (Bag inner) = L.brackets $ do
successors <- V.fromList <$> inner `sepBy` L.comma
let h1 = length successors
let f1 = length successors
return (h1, V.map (,1) successors)
return (f1, V.map (,1) successors)
instance RefinementInterface Bag where
init = init @(GroupValued Int)
......
......@@ -48,12 +48,12 @@ deriving instance Show (Distribution ())
instance ParseMorphism Distribution where
parseMorphismPoint (Distribution inner) = do
(h1, succs) <- parseMorphismPoint (GroupValued @EqDouble inner)
(f1, succs) <- parseMorphismPoint (GroupValued @EqDouble inner)
when (h1 /= 1) $
when (f1 /= 1) $
fail "distribution: Sum of outgoing labels is not 1"
return (h1, succs)
return (f1, succs)
instance RefinementInterface Distribution where
init _ _ = mkGroupWeight 0 1
......
......@@ -172,14 +172,14 @@ parseMorphismPointHelper inner weightParser = do
when (V.hasDuplicates (fmap fst successors)) $
fail "group valued: Duplicate edges"
let !h1 = V.sum (V.map snd successors)
return (h1, successors)
let !f1 = V.sum (V.map snd successors)
return (f1, successors)
where
edge = (,) <$> inner <*> (L.colon *> weightParser)
{-# INLINE parseMorphismPointHelper #-}
{-# SPECIALIZE parseMorphismPointHelper :: MorphParser l h1 Int -> MorphParser l h1 Int -> MorphParser l h1 (Int, Vector (Int, Int)) #-}
{-# SPECIALIZE parseMorphismPointHelper :: MorphParser l h1 Int -> MorphParser l h1 EqDouble -> MorphParser l h1 (EqDouble, Vector (Int, EqDouble)) #-}
{-# SPECIALIZE parseMorphismPointHelper :: MorphParser l f1 Int -> MorphParser l f1 Int -> MorphParser l f1 (Int, Vector (Int, Int)) #-}
{-# SPECIALIZE parseMorphismPointHelper :: MorphParser l f1 Int -> MorphParser l f1 EqDouble -> MorphParser l f1 (EqDouble, Vector (Int, EqDouble)) #-}
instance ParseMorphism (GroupValued Int) where
parseMorphismPoint (GroupValued inner) = parseMorphismPointHelper inner (L.signed L.decimal)
......
......@@ -141,6 +141,6 @@ parseMorphismPointHelper inner weightParser = do
when (V.hasDuplicates (fmap fst successors))
$ fail "monoid valued: Duplicate edges"
let !h1 = fold (V.map snd successors)
return (h1, successors)
let !f1 = fold (V.map snd successors)
return (f1, successors)
where edge = (,) <$> inner <*> (L.colon *> weightParser)
......@@ -248,9 +248,9 @@ parseSum (Sum summands) i = do
when (i < 0 || i >= length summands) $
fail ("polynomial: injection " ++ show i ++ " is out of bounds")
(h1, successors) <- parseProduct1 (summands NonEmpty.!! i)
(f1, successors) <- parseProduct1 (summands NonEmpty.!! i)
return (uncurry (PolyF1 i) h1, successors)
return (uncurry (PolyF1 i) f1, successors)
----------- Products parser
......@@ -289,8 +289,8 @@ parseProduct (Product l@(f :| fs)) =
parseFactor :: MonadParser m => Factor (m a) -> m (Either Int (Vector (a, Int)))
parseFactor (Const (ExplicitSet names)) = do
!h1 <- Left <$> someName names
return h1 -- const has no successors
!f1 <- Left <$> someName names
return f1 -- const has no successors
parseFactor (Const IntSet) = do
x <- L.signed L.decimal <?> "integer"
return (Left x)
......@@ -342,7 +342,7 @@ someName v = do
instance RefinementInterface Polynomial where
init :: F1 Polynomial -> [Label Polynomial] -> Weight Polynomial
init h1 _ = VU.replicate (polyF1Variables h1) True
init f1 _ = VU.replicate (polyF1Variables f1) True
update ::
[Label Polynomial]
......
......@@ -71,9 +71,9 @@ instance ParseMorphism Powerset where
when (V.hasDuplicates successors) $
fail "powerset: Duplicate edges"
let h1 = not (null successors)
let f1 = not (null successors)
return (h1, fmap (,()) successors)
return (f1, fmap (,()) successors)
packWeight :: Bool -> Int -> Int
packWeight True edgesToC = (edgesToC `shift` 1) `setBit` 0
......
......@@ -165,12 +165,12 @@ type instance F1 SomeFunctor = SomeF1
type instance F3 SomeFunctor = SomeF3
instance RefinementInterface SomeFunctor where
init (SomeF1 (f :: TypeRep tf) h1) labels =
init (SomeF1 (f :: TypeRep tf) f1) labels =
#ifdef RELEASE
SomeWeight f (init @tf h1 (unsafeCoerce labels))
SomeWeight f (init @tf f1 (unsafeCoerce labels))
#else
let myLabels = mapMaybe isSameType labels
in SomeWeight f (init @tf h1 myLabels)
in SomeWeight f (init @tf f1 myLabels)
where
isSameType :: SomeLabel -> Maybe (Label tf)
......@@ -196,10 +196,10 @@ instance RefinementInterface SomeFunctor where
#endif
instance ParseMorphism SomeFunctor where
parseMorphismPoint (SomeFunctor (f :: tf (MorphParser l h1 x))) = do
(h1, succs) <- parseMorphismPoint f
parseMorphismPoint (SomeFunctor (f :: tf (MorphParser l f1 x))) = do
(f1, succs) <- parseMorphismPoint f
let fRep = typeRep @tf
newF1 = SomeF1 fRep h1
newF1 = SomeF1 fRep f1
#ifdef RELEASE
let newSuccs = V.map (\(x, y) -> (x, unsafeCoerce y)) succs
......
......@@ -29,30 +29,30 @@ import Copar.Coalgebra.Parser ( SymbolTable(..) )
import Copar.FunctorExpression.Sorts
restrictPartitionToSort1 :: Encoding a (Sorted h1) -> Partition -> [[State]]
restrictPartitionToSort1 :: Encoding a (Sorted f1) -> Partition -> [[State]]
restrictPartitionToSort1 encoding partition =
let blocks = Partition.toBlocks partition
sort1 = statesWithSort1 encoding
in restrictBlocks blocks sort1
printPartition :: Encoding a (Sorted h1) -> SymbolTable -> Partition -> IO ()
printPartition :: Encoding a (Sorted f1) -> SymbolTable -> Partition -> IO ()
printPartition enc symTab part =
TLazyIO.putStr (Build.toLazyText (formatPartition enc symTab part))
writePartition
:: FilePath -> Encoding a (Sorted h1) -> SymbolTable -> Partition -> IO ()
:: FilePath -> Encoding a (Sorted f1) -> SymbolTable -> Partition -> IO ()
writePartition file enc symTab part =
TLazyIO.writeFile file (Build.toLazyText (formatPartition enc symTab part))
showPartition :: Encoding a (Sorted h1) -> SymbolTable -> Partition -> Text
showPartition :: Encoding a (Sorted f1) -> SymbolTable -> Partition -> Text
showPartition enc symTab part =
TL.toStrict (Build.toLazyText (formatPartition enc symTab part))
formatPartition :: Encoding a (Sorted h1) -> SymbolTable -> Partition -> Builder
formatPartition :: Encoding a (Sorted f1) -> SymbolTable -> Partition -> Builder
formatPartition encoding symbolTable partition =
let blocks = Partition.toBlocks partition
sort1 = statesWithSort1 encoding
......@@ -77,7 +77,7 @@ formatBlock (SymbolTable symbolTable) num states =
Just name -> Build.fromText name
statesWithSort1 :: Encoding a (Sorted h1) -> IntSet
statesWithSort1 :: Encoding a (Sorted f1) -> IntSet
statesWithSort1 enc = S.filter ((1 ==) . sortedSort . Encoding.typeOf enc)
(S.fromList (Encoding.states enc))
......
......@@ -60,8 +60,8 @@ data Edge a = Edge
-- | A generic graph (automaton) structure with labeled nodes and edges.
--
-- Nodes (states) are always the set @[0..size-1]@.
data Encoding a h1 = Encoding
{ eStructure :: Vector h1
data Encoding a f1 = Encoding
{ eStructure :: Vector f1
, eEdgesFrom :: VU.Vector State
, eEdgesLabel :: Vector a
, eEdgesTo :: VU.Vector State
......@@ -77,10 +77,10 @@ instance Bifunctor Encoding where
--
-- Runtime: O(1)
new
:: Vector h1 -- ^ State labels.
:: Vector f1 -- ^ State labels.
-> Vector (Edge a) -- ^ Edges. An edge must only reference states that are
-- actually defined in the first vector.
-> Encoding a h1
-> Encoding a f1
new !eStructure !eEdges =
let eEdgesFrom = V.convert $ V.map from eEdges
eEdgesTo = V.convert $ V.map to eEdges
......@@ -91,40 +91,40 @@ new !eStructure !eEdges =
-- | The number of states in the encoding
--
-- Runtime: O(1)
size :: Encoding a h1 -> Int
size :: Encoding a f1 -> Int
size = length . eStructure
{-# INLINE size #-}
-- | A list of all states in the encoding. This is just @[0..size-1]@.
--
-- Runtime: O(size) (lazy)
states :: Encoding a h1 -> [State]
states :: Encoding a f1 -> [State]
states !self = [0..length (eStructure self)-1]
{-# INLINE states #-}
-- | A vector of all edges in this encoding.
--
-- Runtime: O(1)
edges :: Encoding a h1 -> Vector (Edge a)
edges :: Encoding a f1 -> Vector (Edge a)
edges !self = V.imap mkEdge (eEdgesLabel self)
where mkEdge i l = Edge ((eEdgesFrom self) VU.! i) l ((eEdgesTo self) VU.! i)
{-# INLINE edges #-}
edgeRefs :: Encoding a h1 -> [EdgeRef]
edgeRefs :: Encoding a f1 -> [EdgeRef]
edgeRefs !self = map EdgeRef [0..numEdges self-1]
{-# INLINE edgeRefs #-}
-- | The number of edges in the encoding
--
-- Runtime: O(1)
numEdges :: Encoding a h1 -> Int
numEdges :: Encoding a f1 -> Int
numEdges = V.length . eEdgesLabel
{-# INLINE numEdges #-}
-- | All state labels.
--
-- Runtime: O(1)
structure :: Encoding a h1 -> Vector h1
structure :: Encoding a f1 -> Vector f1
structure = eStructure
{-# INLINE structure #-}
......@@ -132,7 +132,7 @@ structure = eStructure
-- in @[0..size-1]@.
--
-- Runtime: O(1)
typeOf :: Encoding a h1 -> State -> h1
typeOf :: Encoding a f1 -> State -> f1
typeOf !self !x = eStructure self V.! x