cabal-fmt-0.1.12: Format .cabal files

Copyright | Oleg Grenrus
License | GPL-3.0-or-later
Safe Haskell | None
Language | Haskell2010

CabalFmt.Monad

Contents

- Monad class
- Pure implementation
- IO implementation

Description

Synopsis

- class (HasOptions r, MonadReader r m, MonadError Error m) => MonadCabalFmt r (m :: Type -> Type) | m -> r where
  - listDirectory :: FilePath -> m [FilePath]
  - doesDirectoryExist :: FilePath -> m Bool
  - readFileBS :: FilePath -> m Contents
  - displayWarning :: String -> m ()
- getFiles :: MonadCabalFmt r m => FilePath -> m [FilePath]
- data Contents
  - = Contents ByteString
  - | NoIO
  - | IOError String
- data CabalFmt a
- runCabalFmt :: Map FilePath ByteString -> Options -> CabalFmt a -> Either Error (a, [String])
- data CabalFmtIO a
- runCabalFmtIO :: Maybe FilePath -> Options -> CabalFmtIO a -> IO (Either Error a)

# Monad class

class (HasOptions r, MonadReader r m, MonadError Error m) => MonadCabalFmt r (m :: Type -> Type) | m -> r where #

`cabal-fmt` interface.

- reader of `Options`
- errors of `Error`
- can list directories

Methods

listDirectory :: FilePath -> m [FilePath] #

doesDirectoryExist :: FilePath -> m Bool #

readFileBS :: FilePath -> m Contents #

displayWarning :: String -> m () #

#### Instances

Instances details

MonadCabalFmt Options CabalFmt # |
Instance details Defined in CabalFmt.Monad Methods listDirectory :: FilePath -> CabalFmt [FilePath] # doesDirectoryExist :: FilePath -> CabalFmt Bool # readFileBS :: FilePath -> CabalFmt Contents # displayWarning :: String -> CabalFmt () #

getFiles :: MonadCabalFmt r m => FilePath -> m [FilePath] #

data Contents #

Constructors

Contents ByteString |
NoIO |
IOError String |

# Pure implementation

data CabalFmt a #

Pure `MonadCabalFmt`.

`listDirectory` always return empty list.

#### Instances

Instances details

Applicative CabalFmt # |
Instance details Defined in CabalFmt.Monad Methods pure :: a -> CabalFmt a # (<*>) :: CabalFmt (a -> b) -> CabalFmt a -> CabalFmt b # liftA2 :: (a -> b -> c) -> CabalFmt a -> CabalFmt b -> CabalFmt c # (*>) :: CabalFmt a -> CabalFmt b -> CabalFmt b # (<*) :: CabalFmt a -> CabalFmt b -> CabalFmt a #
Functor CabalFmt # |
Instance details Defined in CabalFmt.Monad Methods fmap :: (a -> b) -> CabalFmt a -> CabalFmt b # (<$) :: a -> CabalFmt b -> CabalFmt a #
Monad CabalFmt # |
Instance details Defined in CabalFmt.Monad Methods (>>=) :: CabalFmt a -> (a -> CabalFmt b) -> CabalFmt b # (>>) :: CabalFmt a -> CabalFmt b -> CabalFmt b # return :: a -> CabalFmt a #
MonadCabalFmt Options CabalFmt # |
Instance details Defined in CabalFmt.Monad Methods listDirectory :: FilePath -> CabalFmt [FilePath] # doesDirectoryExist :: FilePath -> CabalFmt Bool # readFileBS :: FilePath -> CabalFmt Contents # displayWarning :: String -> CabalFmt () #
MonadError Error CabalFmt # |
Instance details Defined in CabalFmt.Monad Methods throwError :: Error -> CabalFmt a # catchError :: CabalFmt a -> (Error -> CabalFmt a) -> CabalFmt a #
MonadReader Options CabalFmt # |
Instance details Defined in CabalFmt.Monad Methods ask :: CabalFmt Options # local :: (Options -> Options) -> CabalFmt a -> CabalFmt a # reader :: (Options -> a) -> CabalFmt a #

runCabalFmt :: Map FilePath ByteString -> Options -> CabalFmt a -> Either Error (a, [String]) #

# IO implementation

data CabalFmtIO a #

#### Instances

Instances details

MonadIO CabalFmtIO # |
Instance details Defined in CabalFmt.Monad Methods liftIO :: IO a -> CabalFmtIO a #
Applicative CabalFmtIO # |
Instance details Defined in CabalFmt.Monad Methods pure :: a -> CabalFmtIO a # (<*>) :: CabalFmtIO (a -> b) -> CabalFmtIO a -> CabalFmtIO b # liftA2 :: (a -> b -> c) -> CabalFmtIO a -> CabalFmtIO b -> CabalFmtIO c # (*>) :: CabalFmtIO a -> CabalFmtIO b -> CabalFmtIO b # (<*) :: CabalFmtIO a -> CabalFmtIO b -> CabalFmtIO a #
Functor CabalFmtIO # |
Instance details Defined in CabalFmt.Monad Methods fmap :: (a -> b) -> CabalFmtIO a -> CabalFmtIO b # (<$) :: a -> CabalFmtIO b -> CabalFmtIO a #
Monad CabalFmtIO # |
Instance details Defined in CabalFmt.Monad Methods (>>=) :: CabalFmtIO a -> (a -> CabalFmtIO b) -> CabalFmtIO b # (>>) :: CabalFmtIO a -> CabalFmtIO b -> CabalFmtIO b # return :: a -> CabalFmtIO a #
MonadError Error CabalFmtIO # |
Instance details Defined in CabalFmt.Monad Methods throwError :: Error -> CabalFmtIO a # catchError :: CabalFmtIO a -> (Error -> CabalFmtIO a) -> CabalFmtIO a #

runCabalFmtIO :: Maybe FilePath -> Options -> CabalFmtIO a -> IO (Either Error a) #