hsdev-0.1.6.6: Haskell development library and tool with support of autocompletion, symbol info, go to declaration, find references etc.

Safe HaskellNone
LanguageHaskell98

HsDev.Util

Contents

Synopsis

Documentation

withCurrentDirectory :: FilePath -> IO a -> IO a Source

Run action with current directory set

directoryContents :: FilePath -> IO [FilePath] Source

Get directory contents safely

traverseDirectory :: FilePath -> IO [FilePath] Source

Collect all file names in directory recursively

searchPath :: (MonadIO m, MonadPlus m) => FilePath -> (FilePath -> m a) -> m a Source

Search something up

isParent :: FilePath -> FilePath -> Bool Source

Is one path parent of another

haskellSource :: FilePath -> Bool Source

Is haskell source?

cabalFile :: FilePath -> Bool Source

Is cabal file?

String utils

tab :: Int -> String -> String Source

Add N tabs to line

tabs :: Int -> String -> String Source

Add N tabs to multiline

trim :: String -> String Source

Trim string

split :: (a -> Bool) -> [a] -> [[a]] Source

Split list

Other utils

uniqueBy :: Ord b => (a -> b) -> [a] -> [a] Source

mapBy :: Ord b => (a -> b) -> [a] -> Map b a Source

Helper

(.::) :: FromJSON a => HashMap Text Value -> Text -> Parser a Source

Workaround, sometimes we get HM.lookup "foo" v == Nothing, but lookup "foo" (HM.toList v) == Just smth

objectUnion :: Value -> Value -> Value Source

Union two JSON objects

jsonUnion :: (ToJSON a, ToJSON b) => a -> b -> Value Source

Union two JSON objects

noNulls :: [Pair] -> [Pair] Source

No Nulls in JSON object

Exceptions

liftException :: MonadCatch m => m a -> ExceptT String m a Source

Lift IO exception to ExceptT

liftE :: MonadCatch m => m a -> ExceptT String m a Source

Same as liftException

liftEIO :: (MonadCatch m, MonadIO m) => IO a -> ExceptT String m a Source

liftE for IO

tries :: MonadPlus m => [m a] -> m [a] Source

Run actions ignoring errors

triesMap :: MonadPlus m => (a -> m b) -> [a] -> m [b] Source

liftExceptionM :: (MonadCatch m, MonadError String m) => m a -> m a Source

Lift IO exception to MonadError

liftIOErrors :: MonadCatch m => ExceptT String m a -> ExceptT String m a Source

Lift IO exceptions to ExceptT

liftThrow :: (Show e, MonadError e m, MonadCatch m) => m a -> m a Source

Throw error as exception

UTF-8

readFileUtf8 :: FilePath -> IO String Source

Read file in UTF8

IO

logException :: String -> (String -> IO ()) -> IO () -> IO () Source

logIO :: MonadCatchIO m => String -> (String -> m ()) -> m () -> m () Source

ignoreIO :: IO () -> IO () Source

logAsync :: MonadCatchIO m => (String -> m ()) -> m () -> m () Source

Async

Command line

withHelp :: Parser a -> Parser a Source

Add help command to parser

cmd :: String -> String -> Parser a -> Mod CommandFields a Source

Subcommand

parseArgs :: String -> ParserInfo a -> [String] -> Either String a Source

Parse arguments or return help

Reexportss

class Monad m => MonadIO m where

Monads in which IO computations may be embedded. Any monad built by applying a sequence of monad transformers to the IO monad will be an instance of this class.

Instances should satisfy the following laws, which state that liftIO is a transformer of monads:

Methods

liftIO :: IO a -> m a

Lift a computation from the IO monad.

Instances

MonadIO IO 
MonadIO Ghc 
MonadIO Hsc 
MonadIO m => MonadIO (Query m) 
MonadIO m => MonadIO (IdentityT m) 
MonadIO m => MonadIO (GhcT m) 
MonadIO m => MonadIO (ListT m) 
MonadIO m => MonadIO (MaybeT m) 
MonadIO m => MonadIO (ServerM m) 
MonadIO m => MonadIO (ClientM m) 
MonadIO m => MonadIO (UpdateM m) 
MonadIO m => MonadIO (RandT g m) 
MonadIO m => MonadIO (EitherT e m) 
(Error e, MonadIO m) => MonadIO (ErrorT e m) 
MonadIO m => MonadIO (ExceptT e m) 
MonadIO m => MonadIO (JournalT w m) 
MonadIO m => MonadIO (ContT r m) 
MonadIO m => MonadIO (ReaderT r m) 
MonadIO m => MonadIO (StateT s m) 
MonadIO m => MonadIO (StateT s m) 
(Monoid w, MonadIO m) => MonadIO (WriterT w m) 
(Monoid w, MonadIO m) => MonadIO (WriterT w m) 
(Monoid w, MonadIO m) => MonadIO (RWST r w s m) 
(Monoid w, MonadIO m) => MonadIO (RWST r w s m)