Closed jvoigtlaender closed 5 months ago
Am I right that atLeastOccurring
just determines the minimal amount of unique atoms to be used in the tree?
Cutout from the tests:
it "should generate a random SyntaxTree from the given parament and use as many chars as it must use" $
forAll validBoundsSynTree $ \synTreeConfig@SynTreeConfig {..} ->
forAll (genSynTree synTreeConfig) $ \tree -> fromIntegral (length (nubOrd (collectLeaves tree))) >= atLeastOccurring
Yes, that’s the role of this parameter.
... instead of the current type taking all the config fields separately,
genSynTree :: (Integer, Integer) -> Integer -> [c] -> ... -> Gen (SynTree BinOp c)
.Yes, a bit of type-level information would be lost that way (the current polymorphism in
c
). It could be recovered by modifyingdata SynTreeConfig = ... usedLiterals :: String ...
todata SynTreeConfig c = ... usedLiterals :: [c] ...
, but it's probably not worth it.In any case, after the refactoring, with then probably much fewer places in the code where the field names are explicitly mentioned, some of the field names of
SynTreeConfig
could be reconsidered/clarified. For example,usedLiterals
andatLeastOccurring
are not very descriptive. PossiblyavailableAtoms
would be better for the former, and for the latter also some name mentioning what actually is occurring at least that many times.