Module

LineReader.Run

Package
purescript-line-reader
Repository
ChrisPenner/purescript-line-reader

This module provides an interface to read/write from a console interface using Run effects.

Example usage:

getEssay :: forall e. Aff (readline :: READLINE, console :: CONSOLE, exception :: EXCEPTION | e) (Array String)
getEssay = runLineReader Nothing (getWords 10)
  where
    getWords :: Int -> Run (aff :: AFF (readline :: READLINE, console :: CONSOLE, exception :: EXCEPTION | e), reader :: READER Interface) (Array String)
    getWords n
      | n <= 0 = pure []
      | otherwise = do
          newWords <- question $ ("Please enter at least " <> show n <> "words" :: String)
          let splitWords = words newWords
          (append splitWords <$> getWords (n - length splitWords))

#LineReaderF Source

#readLine Source

readLine :: forall r. Run (linereader :: LINEREADER | r) String

#question Source

question :: forall r. String -> Run (linereader :: LINEREADER | r) String

#runLineReader Source

runLineReader :: forall eff r. (Run (aff :: AFF (console :: CONSOLE, exception :: EXCEPTION, readline :: READLINE | eff), linereader :: LINEREADER, reader :: READER Interface | r)) ~> (Run (aff :: AFF (console :: CONSOLE, exception :: EXCEPTION, readline :: READLINE | eff), reader :: READER Interface | r))

#lineReaderToAff Source

lineReaderToAff :: forall e a r. Maybe (Tuple (Readable r (console :: CONSOLE, exception :: EXCEPTION, readline :: READLINE | e)) (Options InterfaceOptions)) -> Run (aff :: AFF (console :: CONSOLE, exception :: EXCEPTION, readline :: READLINE | e), reader :: READER Interface) a -> Aff (console :: CONSOLE, exception :: EXCEPTION, readline :: READLINE | e) a

Run a Line Reader computation from the Run Monad into the Aff Monad

Re-exports from Node.ReadLine.Aff

#READLINE Source

data READLINE :: Effect

The effect of interacting with a stream via an Interface

#InterfaceOptions Source

data InterfaceOptions

Options passed to readline's createInterface

#Completer Source

type Completer eff = String -> Eff eff { completions :: Array String, matched :: String }

A function which performs tab completion.

This function takes the partial command as input, and returns a collection of completions, as well as the matched portion of the input string.

#output Source

output :: forall eff w. Option InterfaceOptions (Writable w eff)

#noCompletion Source

noCompletion :: forall eff. Completer eff

A completion function which offers no completions.

#createInterface Source

createInterface :: forall eff r. Readable r (readline :: READLINE | eff) -> Options InterfaceOptions -> Eff (readline :: READLINE | eff) Interface

Builds an interface with the specified options.

#createConsoleInterface Source

createConsoleInterface :: forall eff. Completer (console :: CONSOLE, exception :: EXCEPTION, readline :: READLINE | eff) -> Eff (console :: CONSOLE, exception :: EXCEPTION, readline :: READLINE | eff) Interface

Create an interface with the specified completion function.

#completer Source