Cleanup
This commit is contained in:
@@ -1,5 +1,3 @@
|
|||||||
{-# LANGUAGE LambdaCase #-}
|
|
||||||
|
|
||||||
module Dodge.Placement.Instance.Sensor (
|
module Dodge.Placement.Instance.Sensor (
|
||||||
lightSensor,
|
lightSensor,
|
||||||
damageSensor,
|
damageSensor,
|
||||||
|
|||||||
+10
-14
@@ -1,5 +1,4 @@
|
|||||||
{-# LANGUAGE LambdaCase #-}
|
{-# LANGUAGE LambdaCase #-}
|
||||||
{-# LANGUAGE TupleSections #-}
|
|
||||||
|
|
||||||
module Dodge.Terminal (
|
module Dodge.Terminal (
|
||||||
makeTermLine,
|
makeTermLine,
|
||||||
@@ -162,8 +161,8 @@ data TabCompletion a
|
|||||||
| TabMultiComplete [String]
|
| TabMultiComplete [String]
|
||||||
| TabFail
|
| TabFail
|
||||||
|
|
||||||
data RecCommands a =
|
newtype RecCommands a =
|
||||||
RCommands {_rCommands :: (PTE.TrieMap Char (Either (RecCommands a) a))}
|
RCommands {_rCommands :: PTE.TrieMap Char (Either (RecCommands a) a)}
|
||||||
|
|
||||||
-- assumes that each command Trie has at least one successful command
|
-- assumes that each command Trie has at least one successful command
|
||||||
recComFindMin :: RecCommands a -> Maybe ([String], a)
|
recComFindMin :: RecCommands a -> Maybe ([String], a)
|
||||||
@@ -207,9 +206,6 @@ recComFindPredecessor (s:ss) (RCommands m)
|
|||||||
Just (s',Left rm') -> recComFindMax rm' & _Just . _1 .:~ s'
|
Just (s',Left rm') -> recComFindMax rm' & _Just . _1 .:~ s'
|
||||||
Nothing -> Nothing
|
Nothing -> Nothing
|
||||||
recComFindPredecessor [] rm = recComFindMax rm
|
recComFindPredecessor [] rm = recComFindMax rm
|
||||||
--
|
|
||||||
--recComFindPredecessor :: [String] -> RecCommands a -> Maybe ([String],a)
|
|
||||||
--recComFindPredecessor (s:ss) (RCommands m) = Nothing
|
|
||||||
|
|
||||||
instance Semigroup (RecCommands a) where
|
instance Semigroup (RecCommands a) where
|
||||||
RCommands x <> RCommands y = RCommands $ x <> y
|
RCommands x <> RCommands y = RCommands $ x <> y
|
||||||
@@ -221,7 +217,7 @@ instance Monoid (RecCommands a) where
|
|||||||
tbComplete :: String -> PTE.TrieMap Char a -> TabCompletion a
|
tbComplete :: String -> PTE.TrieMap Char a -> TabCompletion a
|
||||||
tbComplete s t = case e of
|
tbComplete s t = case e of
|
||||||
[] | Just x <- mx -> TabMatch x
|
[] | Just x <- mx -> TabMatch x
|
||||||
[] -> case fmap fst $ PTE.toList t' of
|
[] -> case fst <$> PTE.toList t' of
|
||||||
[] -> TabFail
|
[] -> TabFail
|
||||||
ss -> TabMultiComplete ss
|
ss -> TabMultiComplete ss
|
||||||
_ -> TabComplete e
|
_ -> TabComplete e
|
||||||
@@ -229,14 +225,14 @@ tbComplete s t = case e of
|
|||||||
(e, mx, t') = PTE.splitPrefix $ PTE.deletePrefix s t
|
(e, mx, t') = PTE.splitPrefix $ PTE.deletePrefix s t
|
||||||
|
|
||||||
recTabComplete :: String -> TCommands -> TabCompletion [TerminalLine]
|
recTabComplete :: String -> TCommands -> TabCompletion [TerminalLine]
|
||||||
recTabComplete s (RCommands t) = fromMaybe (TabMultiComplete $ allstrings $ t) $ do
|
recTabComplete s (RCommands t) = fromMaybe (TabMultiComplete $ allstrings t) $ do
|
||||||
(s1,ss) <- stripHead $ words s
|
(s1,ss) <- stripHead $ words s
|
||||||
case tbComplete s1 t of
|
return $ case tbComplete s1 t of
|
||||||
TabComplete e -> return $ TabComplete e
|
TabComplete e -> TabComplete e
|
||||||
TabMultiComplete es -> return $ TabMultiComplete (fmap (s1 <>) es)
|
TabMultiComplete es -> TabMultiComplete (fmap (s1 <>) es)
|
||||||
TabFail -> return $ TabFail
|
TabFail -> TabFail
|
||||||
TabMatch (Right x) -> return $ TabMatch x
|
TabMatch (Right x) -> TabMatch x
|
||||||
TabMatch (Left rm) -> return $ recTabComplete (unwords ss) rm
|
TabMatch (Left rm) -> recTabComplete (unwords ss) rm
|
||||||
where
|
where
|
||||||
stripHead (x:xs) = Just (x,xs)
|
stripHead (x:xs) = Just (x,xs)
|
||||||
stripHead _ = Nothing
|
stripHead _ = Nothing
|
||||||
|
|||||||
Reference in New Issue
Block a user