Copyright | (c) Miao ZhiCheng 2024 |
---|---|
License | MIT |
Maintainer | zhicheng.miao@gmail.com |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | GHC2021 |
THSH.Fn
Description
Synopsis
- class FnFunction f where
- data ContentFn (m :: Type -> Type) s = MkContentFn (s -> m s) (Handle -> m s) (Handle -> s -> m ())
- stringContentFn :: (String -> String) -> ContentFn IO String
- stringContentIOFn :: (String -> IO String) -> ContentFn IO String
- textContentFn :: (Text -> Text) -> ContentFn IO Text
- textContentIOFn :: (Text -> IO Text) -> ContentFn IO Text
- data LineReadFn (m :: Type -> Type) a b = Read a => MkLineReadFn (a -> b -> m (b, Maybe String)) (b -> m (Maybe String)) b
- lineReadFn :: Read a => (a -> b -> (b, Maybe String)) -> (b -> Maybe String) -> b -> LineReadFn IO a b
- data Fn f
- fn :: FnFunction f => f -> Fn f
Documentation
class FnFunction f where Source #
A FnFunction
is a function that, given a set of handles to communicate with it, it returns an exit code.
data ContentFn (m :: Type -> Type) s Source #
A FnFunction
that converts the entire input content to another as String
.
Constructors
MkContentFn (s -> m s) (Handle -> m s) (Handle -> s -> m ()) |
stringContentIOFn :: (String -> IO String) -> ContentFn IO String Source #
IO variant of stringContentFn
.
textContentIOFn :: (Text -> IO Text) -> ContentFn IO Text Source #
IO variant of textContentFn
.
data LineReadFn (m :: Type -> Type) a b Source #
A FnFunction
that reads line by line via Read
instances of a
and accumulates context b
.
Constructors
Read a => MkLineReadFn | |
lineReadFn :: Read a => (a -> b -> (b, Maybe String)) -> (b -> Maybe String) -> b -> LineReadFn IO a b Source #
Idiomatic wrapper for the MkLineReadFn
The new type wrapper of any FnFunction instance.
fn :: FnFunction f => f -> Fn f Source #
The marker for the thsh
quasi-quote to recognize a FnFunction
code block.