mirror of
https://github.com/jgm/pandoc.git
synced 2026-09-24 15:44:59 +08:00
Text.Pandoc.Shared: remove findM [API change].
This was only used in one place, and can be replaced with simpler code.
This commit is contained in:
@@ -43,7 +43,6 @@ import Text.Pandoc.Options (TopLevelDivision (TopLevelDefault),
|
||||
import Text.Pandoc.Class (readFileStrict, fileExists, setVerbosity, report,
|
||||
PandocMonad(lookupEnv), getUserDataDir)
|
||||
import Text.Pandoc.Error (PandocError (PandocParseError, PandocSomeError))
|
||||
import Text.Pandoc.Shared (findM)
|
||||
import Data.Containers.ListUtils (nubOrd)
|
||||
import Text.Pandoc.Data (defaultUserDataDir)
|
||||
import qualified Text.Pandoc.Parsing as P
|
||||
@@ -802,7 +801,14 @@ fullDefaultsPath dataDir file = do
|
||||
else file
|
||||
defaultDataDir <- liftIO defaultUserDataDir
|
||||
let defaultFp = fromMaybe defaultDataDir dataDir </> "defaults" </> fp
|
||||
fromMaybe fp <$> findM fileExists [fp, defaultFp]
|
||||
fpExists <- fileExists fp
|
||||
if fpExists
|
||||
then return fp
|
||||
else do
|
||||
defaultFpExists <- fileExists defaultFp
|
||||
if defaultFpExists
|
||||
then return defaultFp
|
||||
else return fp
|
||||
|
||||
-- | In a list of lists, append another list in front of every list which
|
||||
-- starts with specific element.
|
||||
|
||||
@@ -22,7 +22,6 @@ module Text.Pandoc.Shared (
|
||||
splitBy,
|
||||
splitTextBy,
|
||||
splitTextByIndices,
|
||||
findM,
|
||||
-- * Text processing
|
||||
inquotes,
|
||||
tshow,
|
||||
@@ -153,18 +152,6 @@ splitAt' n xs | n <= 0 = ([],xs)
|
||||
splitAt' n (x:xs) = (x:ys,zs)
|
||||
where (ys,zs) = splitAt' (n - charWidth x) xs
|
||||
|
||||
-- | Returns the first element in a foldable structure for that the
|
||||
-- monadic predicate holds true, and @Nothing@ if no such element
|
||||
-- exists.
|
||||
findM :: forall m t a. (Monad m, Foldable t)
|
||||
=> (a -> m Bool) -> t a -> m (Maybe a)
|
||||
findM p = foldr go (pure Nothing)
|
||||
where
|
||||
go :: a -> m (Maybe a) -> m (Maybe a)
|
||||
go x acc = do
|
||||
b <- p x
|
||||
if b then pure (Just x) else acc
|
||||
|
||||
--
|
||||
-- Text processing
|
||||
--
|
||||
|
||||
Reference in New Issue
Block a user