diff options
Diffstat (limited to 'src/Sequence/Utils.hs')
-rw-r--r-- | src/Sequence/Utils.hs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/Sequence/Utils.hs b/src/Sequence/Utils.hs index 929189e..ba6ce95 100644 --- a/src/Sequence/Utils.hs +++ b/src/Sequence/Utils.hs | |||
@@ -1,4 +1,4 @@ | |||
1 | {-# LANGUAGE ViewPatterns, FlexibleContexts, MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances, UndecidableInstances, OverloadedStrings, RankNTypes #-} | 1 | {-# LANGUAGE ViewPatterns, FlexibleContexts, MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances, UndecidableInstances, OverloadedStrings, OverloadedLists, RankNTypes #-} |
2 | 2 | ||
3 | module Sequence.Utils | 3 | module Sequence.Utils |
4 | ( withArg, withFocus, withFocus' | 4 | ( withArg, withFocus, withFocus' |
@@ -140,3 +140,16 @@ instance Argument DamageType GameState where | |||
140 | arg (CI.mk -> word) = return $ Map.lookup word types | 140 | arg (CI.mk -> word) = return $ Map.lookup word types |
141 | where | 141 | where |
142 | types = Map.fromList [(CI.mk $ show dType, dType) | dType <- [minBound .. maxBound]] | 142 | types = Map.fromList [(CI.mk $ show dType, dType) | dType <- [minBound .. maxBound]] |
143 | |||
144 | instance Completion (Formula Stats) GameState where | ||
145 | completableLabel _ = "<value>" | ||
146 | complete _ st (CI.foldCase -> prefix) = return . map CI.original . filter ((prefix `isPrefixOf`) . CI.foldedCase) . Map.keys $ Map.filter (isJust . (\a -> preview (gFocus' . eStats . folding a) st)) statAccessors | ||
147 | |||
148 | instance Argument (Formula Stats) GameState where | ||
149 | arg (CI.mk -> name) = runMaybeT $ do | ||
150 | accessor <- MaybeT . return $ Map.lookup name statAccessors | ||
151 | MaybeT . preuse $ gFocus' . eStats . folding accessor | ||
152 | |||
153 | statAccessors :: Map (CI String) (Stats -> Maybe (Formula Stats)) | ||
154 | statAccessors = [ | ||
155 | ] | ||