Safe Haskell | Safe-Infered |
---|
Internal representation of GenI configuration options, typically passed in through the command line or via the GUI.
We don't yet use the record based approach, or something like cmdargs because our use case involves
- sharing lots of options between different programs (batch processing, gui, server)
- supporting library users who want to build GenI-like applications that share a good chunk of our flag set, and add configuration options of their own.
What we have is fairly clunky, but it seems to be quite flexible for that need.
- data Optimisation
- = PolOpts
- | AdjOpts
- | Polarised
- | NoConstraints
- type Instruction = (FilePath, Maybe [Text])
- data BuilderType
- data GrammarType
- = GeniHand
- | PreCompiled
- | PreAnchored
- defaultGrammarType :: GrammarType
- getGrammarType :: [Flag] -> GrammarType
- hasOpt :: Optimisation -> [Flag] -> Bool
- data Flag = forall f x . (Eq f, Typeable f, Typeable x) => Flag (x -> f) x
- class HasFlags x where
- isFlag :: (Typeable f, Typeable x) => (x -> f) -> Flag -> Bool
- hasFlag :: (Typeable f, Typeable x, HasFlags flags) => (x -> f) -> flags -> Bool
- deleteFlag :: (Typeable f, Typeable x, HasFlags flags) => (x -> f) -> flags -> flags
- modifyFlag :: (Eq f, Typeable f, Typeable x, HasFlags flags) => (x -> f) -> (x -> x) -> flags -> flags
- setFlag :: (Eq f, Typeable f, Typeable x, HasFlags flags) => (x -> f) -> x -> flags -> flags
- getFlag :: (Typeable f, Typeable x, HasFlags flags) => (x -> f) -> flags -> Maybe x
- getAllFlags :: (Typeable f, Typeable x, HasFlags flags) => (x -> f) -> flags -> [x]
- getListFlag :: (Typeable f, Typeable x, HasFlags flags) => ([x] -> f) -> flags -> [x]
- updateFlags :: HasFlags flags => flags -> flags -> flags
- newtype BatchDirFlg = BatchDirFlg FilePath
- newtype DisableGuiFlg = DisableGuiFlg ()
- newtype DetectPolaritiesFlg = DetectPolaritiesFlg (Set PolarityAttr)
- newtype DumpDerivationFlg = DumpDerivationFlg ()
- newtype EarlyDeathFlg = EarlyDeathFlg ()
- newtype FromStdinFlg = FromStdinFlg ()
- newtype HelpFlg = HelpFlg ()
- newtype InstructionsFileFlg = InstructionsFileFlg FilePath
- newtype LexiconFlg = LexiconFlg FilePath
- newtype MacrosFlg = MacrosFlg FilePath
- newtype TracesFlg = TracesFlg FilePath
- newtype MaxStepsFlg = MaxStepsFlg Integer
- newtype MaxResultsFlg = MaxResultsFlg Integer
- newtype MetricsFlg = MetricsFlg [String]
- newtype MorphCmdFlg = MorphCmdFlg String
- newtype MorphInfoFlg = MorphInfoFlg FilePath
- newtype OptimisationsFlg = OptimisationsFlg [Optimisation]
- newtype OutputFileFlg = OutputFileFlg String
- newtype PartialFlg = PartialFlg ()
- newtype RankingConstraintsFlg = RankingConstraintsFlg FilePath
- newtype RootFeatureFlg = RootFeatureFlg (Flist GeniVal)
- newtype NoLoadTestSuiteFlg = NoLoadTestSuiteFlg ()
- newtype StatsFileFlg = StatsFileFlg FilePath
- newtype TestCaseFlg = TestCaseFlg Text
- newtype TestInstructionsFlg = TestInstructionsFlg [Instruction]
- newtype TestSuiteFlg = TestSuiteFlg FilePath
- newtype TimeoutFlg = TimeoutFlg Int
- newtype VerboseModeFlg = VerboseModeFlg ()
- newtype VersionFlg = VersionFlg ()
- newtype ViewCmdFlg = ViewCmdFlg String
- newtype BuilderFlg = BuilderFlg BuilderType
- newtype GrammarTypeFlg = GrammarTypeFlg GrammarType
- newtype WeirdFlg = WeirdFlg String
Documentation
data Optimisation
Requested optimisations
At the time of this writing (2012-08-21), this is fairly sparse as a lot of proposed optimisations have just been absorbed into GenI as mandatory things.
PolOpts | all polarity-related optimisations |
AdjOpts | all adjunction-related optimisations |
Polarised | polarity filtering |
NoConstraints | ignore literal constraints (pessimisation?) |
type Instruction = (FilePath, Maybe [Text])
A test suite and any test cases within that we want to pick out
data BuilderType
The tree assembly algorithm we want to use
data GrammarType
What kind of elementary trees we're getting. The typical use case is
to provide tree schemata with GeniHand
(which then get anchored into
the lexicon to give us elmentary trees). You can also have precompiled
trees hardcoded into your GenI-like program, or read preanchored
elementary trees from somewhere else.
GeniHand | geni's text format |
PreCompiled | built into geni, no parsing needed |
PreAnchored | lexical selection already done |
getGrammarType :: [Flag] -> GrammarType
hasOpt :: Optimisation -> [Flag] -> Bool
data Flag
Flags are GenI's internal representation of command line arguments. We use phantom existential types (?) for representing GenI flags. This makes it simpler to do things such as ``get the value of the MacrosFlg'' whilst preserving type safety (we always know that MacrosFlg is associated with String). The alternative would be writing getters and setters for each flag, and that gets really boring after a while.
class HasFlags x where
deleteFlag :: (Typeable f, Typeable x, HasFlags flags) => (x -> f) -> flags -> flags
:: (Eq f, Typeable f, Typeable x, HasFlags flags) | |
=> (x -> f) | flag constructor |
-> (x -> x) | |
-> flags | |
-> flags |
This only has an effect if the flag is set
getAllFlags :: (Typeable f, Typeable x, HasFlags flags) => (x -> f) -> flags -> [x]
getListFlag :: (Typeable f, Typeable x, HasFlags flags) => ([x] -> f) -> flags -> [x]
:: HasFlags flags | |
=> flags | new |
-> flags | old |
-> flags |
updateFlags new old
takes the flags from new
plus any from old
that
aren't mentioned in it
newtype DetectPolaritiesFlg
newtype InstructionsFileFlg
newtype OptimisationsFlg
newtype RankingConstraintsFlg
newtype TestInstructionsFlg