mirror of
https://github.com/swarm-game/swarm.git
synced 2024-08-16 18:10:23 +03:00
parent
5f53082971
commit
669163384e
@ -30,7 +30,7 @@ import System.IO (hPrint, stderr)
|
||||
import Text.Read (readMaybe)
|
||||
|
||||
gitInfo :: Maybe GitInfo
|
||||
gitInfo = either (const Nothing) Just ($$tGitInfoCwdTry)
|
||||
gitInfo = either (const Nothing) Just $$tGitInfoCwdTry
|
||||
|
||||
commitInfo :: String
|
||||
commitInfo = case gitInfo of
|
||||
|
@ -202,7 +202,7 @@ truncatePath origPath entityLoc oldCache =
|
||||
oldCache {cachedPath = CachedPath truncPath $ mkTailMap truncPath}
|
||||
where
|
||||
truncPath = prependList truncPathExcludingEntityLoc $ pure entityLoc
|
||||
truncPathExcludingEntityLoc = fst $ NE.break (/= entityLoc) origPath
|
||||
truncPathExcludingEntityLoc = takeWhile (== entityLoc) $ NE.toList origPath
|
||||
|
||||
-- | Given an event that entails the modification of some cell,
|
||||
-- check whether a shortest-path previously computed for a
|
||||
|
@ -188,8 +188,9 @@ brackets = between (symbol "[") (symbol "]")
|
||||
parsePolytype :: Parser Polytype
|
||||
parsePolytype =
|
||||
join $
|
||||
quantify
|
||||
<$> (fromMaybe [] <$> optional (reserved "forall" *> some identifier <* symbol "."))
|
||||
( quantify . fromMaybe []
|
||||
<$> optional (reserved "forall" *> some identifier <* symbol ".")
|
||||
)
|
||||
<*> parseType
|
||||
where
|
||||
quantify :: [Var] -> Type -> Parser Polytype
|
||||
@ -288,8 +289,7 @@ parseTermAtom2 =
|
||||
*> ( ( TRequireDevice
|
||||
<$> (textLiteral <?> "device name in double quotes")
|
||||
)
|
||||
<|> ( TRequire
|
||||
<$> (fromIntegral <$> integer)
|
||||
<|> ( (TRequire . fromIntegral <$> integer)
|
||||
<*> (textLiteral <?> "entity name in double quotes")
|
||||
)
|
||||
)
|
||||
|
@ -43,7 +43,7 @@ import Control.Lens ((%~), (&), _head, _last)
|
||||
import Data.Char (isSpace)
|
||||
import Data.Functor.Identity (Identity (..))
|
||||
import Data.List.Split (chop)
|
||||
import Data.Maybe (catMaybes)
|
||||
import Data.Maybe (mapMaybe)
|
||||
import Data.Set (Set)
|
||||
import Data.Set qualified as Set
|
||||
import Data.Text (Text)
|
||||
@ -178,7 +178,7 @@ parseSyntax t = case readTerm t of
|
||||
Right _ -> Right s
|
||||
|
||||
findCode :: Document Syntax -> [Syntax]
|
||||
findCode = catMaybes . concatMap (map codeOnly . nodes) . paragraphs
|
||||
findCode = concatMap (mapMaybe codeOnly . nodes) . paragraphs
|
||||
where
|
||||
codeOnly = \case
|
||||
LeafCode s -> Just s
|
||||
|
@ -133,10 +133,8 @@ mkEntityLookup grids =
|
||||
mkValues neList = AutomatonInfo participatingEnts bounds sm
|
||||
where
|
||||
participatingEnts =
|
||||
S.fromList
|
||||
. map (view entityName)
|
||||
. catMaybes
|
||||
$ concatMap fst tuples
|
||||
(S.fromList . map (view entityName))
|
||||
(concatMap (catMaybes . fst) tuples)
|
||||
|
||||
tuples = M.toList $ M.mapWithKey mkSmValue groupedByUniqueRow
|
||||
|
||||
|
@ -237,7 +237,7 @@ instance Ord FoundStructure where
|
||||
-- are not included.
|
||||
genOccupiedCoords :: FoundStructure -> [Cosmic Location]
|
||||
genOccupiedCoords (FoundStructure swg loc) =
|
||||
catMaybes . concat . zipWith mkRow [0 ..] $ entityGrid swg
|
||||
concatMap catMaybes . zipWith mkRow [0 ..] $ entityGrid swg
|
||||
where
|
||||
mkCol y x ent = loc `offsetBy` V2 x (negate y) <$ ent
|
||||
mkRow rowIdx = zipWith (mkCol rowIdx) [0 ..]
|
||||
|
Loading…
Reference in New Issue
Block a user