hsdev-0.3.3.5: Haskell development library

Safe HaskellNone
LanguageHaskell98

HsDev.Util

Contents

Synopsis

Documentation

withCurrentDirectory :: (MonadIO m, MonadMask m) => FilePath -> m a -> m a Source #

Run action with current directory set

directoryContents :: FilePath -> IO [FilePath] Source #

Get directory contents safely: no fail, ignoring symbolic links, also prepends paths with dir name

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

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

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

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

Returns Nothing when key doesn't exist or value is Null

(.::?!) :: FromJSON a => HashMap Text Value -> Text -> Parser [a] Source #

Same as .::? for list, returns empty list for non-existant key or Null value

objectUnion :: Value -> Value -> Value Source #

Union two JSON objects

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

No Nulls in JSON object

fromJSON' :: FromJSON a => Value -> Maybe a Source #

Try convert json to value

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

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

Run actions ignoring errors

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

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

Lift IO exceptions to ExceptT

logAll :: (MonadLog m, MonadCatch m) => m () -> m () Source #

Log exceptions and ignore

UTF-8

readFileUtf8 :: FilePath -> IO Text Source #

Read file in UTF8

IO

logIO :: MonadCatch m => String -> (String -> m ()) -> m () -> m () Source #

ignoreIO :: MonadCatch m => m () -> m () Source #

logAsync :: (MonadIO m, MonadCatch m) => (String -> m ()) -> m () -> m () Source #

Command line

class FromCmd a where Source #

Methods

cmdP :: Parser a Source #

Instances
FromCmd SearchQuery Source # 
Instance details

Defined in HsDev.Server.Types

FromCmd TargetFilter Source # 
Instance details

Defined in HsDev.Server.Types

FromCmd FileSource Source # 
Instance details

Defined in HsDev.Server.Types

FromCmd Command Source # 
Instance details

Defined in HsDev.Server.Types

FromCmd ClientOpts Source # 
Instance details

Defined in HsDev.Server.Types

FromCmd ServerOpts Source # 
Instance details

Defined in HsDev.Server.Types

FromCmd ServerCommand Source # 
Instance details

Defined in HsDev.Server.Types

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

Version stuff

version :: Maybe [Int] Source #

Get hsdev version as list of integers

Parse

parseDT :: (Monad m, Text a) => String -> String -> m a Source #

Parse Distribution.Text

Log utils

timer :: MonadLog m => Text -> m a -> m a Source #

Measure time of action

Reexportss

class Monad m => MonadIO (m :: Type -> Type) 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

Since: base-4.9.0.0

Instance details

Defined in Control.Monad.IO.Class

Methods

liftIO :: IO a -> IO a #

MonadIO Q 
Instance details

Defined in Language.Haskell.TH.Syntax

Methods

liftIO :: IO a -> Q a #

MonadIO Ghc 
Instance details

Defined in GhcMonad

Methods

liftIO :: IO a -> Ghc a #

MonadIO Hsc 
Instance details

Defined in HscTypes

Methods

liftIO :: IO a -> Hsc a #

MonadIO Q 
Instance details

Defined in Language.Haskell.TH.Syntax

Methods

liftIO :: IO a -> Q a #

MonadIO Sh 
Instance details

Defined in Shelly.Base

Methods

liftIO :: IO a -> Sh a #

MonadIO ErrMsgGhc 
Instance details

Defined in Haddock.Types

Methods

liftIO :: IO a -> ErrMsgGhc a #

MonadIO m => MonadIO (MaybeT m) 
Instance details

Defined in Control.Monad.Trans.Maybe

Methods

liftIO :: IO a -> MaybeT m a #

MonadIO m => MonadIO (ResourceT m) 
Instance details

Defined in Control.Monad.Trans.Resource.Internal

Methods

liftIO :: IO a -> ResourceT m a #

MonadIO m => MonadIO (GhcT m) 
Instance details

Defined in GhcMonad

Methods

liftIO :: IO a -> GhcT m a #

MonadIO m => MonadIO (ListT m) 
Instance details

Defined in Control.Monad.Trans.List

Methods

liftIO :: IO a -> ListT m a #

MonadIO m => MonadIO (LogT m) 
Instance details

Defined in System.Log.Simple.Monad

Methods

liftIO :: IO a -> LogT m a #

MonadIO m => MonadIO (ClientM m) Source # 
Instance details

Defined in HsDev.Server.Types

Methods

liftIO :: IO a -> ClientM m a #

MonadIO m => MonadIO (ServerM m) Source # 
Instance details

Defined in HsDev.Server.Types

Methods

liftIO :: IO a -> ServerM m a #

MonadIO m => MonadIO (UpdateM m) Source # 
Instance details

Defined in HsDev.Database.Update.Types

Methods

liftIO :: IO a -> UpdateM m a #

MonadIO m => MonadIO (IdentityT m) 
Instance details

Defined in Control.Monad.Trans.Identity

Methods

liftIO :: IO a -> IdentityT m a #

(Monoid w, MonadIO m) => MonadIO (WriterT w m) 
Instance details

Defined in Control.Monad.Trans.Writer.Strict

Methods

liftIO :: IO a -> WriterT w m a #

(Monoid w, MonadIO m) => MonadIO (WriterT w m) 
Instance details

Defined in Control.Monad.Trans.Writer.Lazy

Methods

liftIO :: IO a -> WriterT w m a #

MonadIO m => MonadIO (StateT s m) 
Instance details

Defined in Control.Monad.Trans.State.Strict

Methods

liftIO :: IO a -> StateT s m a #

MonadIO m => MonadIO (StateT s m) 
Instance details

Defined in Control.Monad.Trans.State.Lazy

Methods

liftIO :: IO a -> StateT s m a #

MonadIO m => MonadIO (ExceptT e m) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

liftIO :: IO a -> ExceptT e m a #

(Functor f, MonadIO m) => MonadIO (FreeT f m) 
Instance details

Defined in Control.Monad.Trans.Free

Methods

liftIO :: IO a -> FreeT f m a #

(Error e, MonadIO m) => MonadIO (ErrorT e m) 
Instance details

Defined in Control.Monad.Trans.Error

Methods

liftIO :: IO a -> ErrorT e m a #

(Monoid w, Functor m, MonadIO m) => MonadIO (AccumT w m) 
Instance details

Defined in Control.Monad.Trans.Accum

Methods

liftIO :: IO a -> AccumT w m a #

MonadIO m => MonadIO (SelectT r m) 
Instance details

Defined in Control.Monad.Trans.Select

Methods

liftIO :: IO a -> SelectT r m a #

MonadIO m => MonadIO (ReaderT r m) 
Instance details

Defined in Control.Monad.Trans.Reader

Methods

liftIO :: IO a -> ReaderT r m a #

MonadIO m => MonadIO (ConduitT i o m) 
Instance details

Defined in Data.Conduit.Internal.Conduit

Methods

liftIO :: IO a -> ConduitT i o m a #

MonadIO m => MonadIO (ContT r m) 
Instance details

Defined in Control.Monad.Trans.Cont

Methods

liftIO :: IO a -> ContT r m a #

MonadIO m => MonadIO (MGhcT s d m) Source # 
Instance details

Defined in HsDev.Tools.Ghc.MGhc

Methods

liftIO :: IO a -> MGhcT s d m a #

MonadIO m => MonadIO (InspectM k t m) Source # 
Instance details

Defined in HsDev.Symbols.Types

Methods

liftIO :: IO a -> InspectM k t m a #

(Monoid w, MonadIO m) => MonadIO (RWST r w s m) 
Instance details

Defined in Control.Monad.Trans.RWS.Strict

Methods

liftIO :: IO a -> RWST r w s m a #

(Monoid w, MonadIO m) => MonadIO (RWST r w s m) 
Instance details

Defined in Control.Monad.Trans.RWS.Lazy

Methods

liftIO :: IO a -> RWST r w s m a #

MonadIO m => MonadIO (Pipe l i o u m) 
Instance details

Defined in Data.Conduit.Internal.Pipe

Methods

liftIO :: IO a -> Pipe l i o u m a #