THSH-0.0.0.5: A "noDSL" approach to mixing shell scripting with Haskell programs using Template Haskell
Copyright(c) Miao ZhiCheng 2024
LicenseMIT
Maintainerzhicheng.miao@gmail.com
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageGHC2021

THSH.Fn

Description

 
Synopsis

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.

Methods

runFn :: f -> (Handle, Handle, Handle) -> IO ExitCode Source #

Instances

Instances details
FnFunction (ContentFn IO s) Source # 
Instance details

Defined in THSH.Fn

FnFunction (LineReadFn IO a b) Source # 
Instance details

Defined in THSH.Fn

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 ()) 

Instances

Instances details
FnFunction (ContentFn IO s) Source # 
Instance details

Defined in THSH.Fn

textContentFn :: (Text -> Text) -> ContentFn IO Text Source #

ContentFn for the Text type from the text package.

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 

Fields

  • (a -> b -> m (b, Maybe String))

    read an element; accumulate context; and maybe an output

  • (b -> m (Maybe String))

    final output

  • b

    initial context

Instances

Instances details
FnFunction (LineReadFn IO a b) Source # 
Instance details

Defined in THSH.Fn

lineReadFn :: Read a => (a -> b -> (b, Maybe String)) -> (b -> Maybe String) -> b -> LineReadFn IO a b Source #

Idiomatic wrapper for the MkLineReadFn

data Fn f Source #

The new type wrapper of any FnFunction instance.

Instances

Instances details
FnFunction f => Funclet (Fn f) Source #

The FnFunction instance of Funclet.

Instance details

Defined in THSH.Fn

Methods

runFunclet :: Fn f -> (ExitCode -> IO ()) -> IO (Handle, Handle, Handle) Source #

runFuncletWithHandles :: Fn f -> (ExitCode -> IO ()) -> (Handle, Handle, Handle) -> IO () Source #

fn :: FnFunction f => f -> Fn f Source #

The marker for the thsh quasi-quote to recognize a FnFunction code block.