{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, UndecidableInstances, GeneralizedNewtypeDeriving #-}{- |
Module : System.Console.Haskeline.Class
Copyright : (c) Antoine Latter, 2009
License : BSD3
Maintainer : Antoine Latter <aslatter@gmail.com>
Stability : experimental
Portability : FlexibleInstances, MultiPatamTypeClasses, UndecidableInstances, GeneralizedNewtypeDeriving
Haskeline provides all of its functionality within the scope of a monad transformer.
This module adds two pieces to this:
- Introduced here is a type-class which defines the operations
supported by the Haskeline monad transformer - MonadHaskeline
- A newtype wrapper around Haskeline's InputT, called
HaskelineT. Sadly, InputT defines ints own instance of the
mtl MonadState, which is no good for folks wanting to use
InputT in an existing monad transformer stack.
HaskelineT also has an instance of MonadState, but it merely
lifts the functions further in the transformer stack.
Large portions of the Haskeline functionality are re-exported
here for convinience.
-}moduleSystem.Console.Haskeline.Class(HaskelineT,runHaskelineT,runHaskelineTWithPrefs,MonadHaskeline(..),H.Settings(..),H.defaultSettings,H.setComplete,H.Prefs(),H.readPrefs,H.defaultPrefs,H.Interrupt(..),H.handleInterrupt,moduleSystem.Console.Haskeline.Completion,moduleSystem.Console.Haskeline.MonadException)whereimportqualifiedSystem.Console.HaskelineasHimportSystem.Console.Haskeline.CompletionimportSystem.Console.Haskeline.MonadExceptionimportControl.ApplicativeimportControl.Monad.StatenewtypeHaskelineTma=HaskelineT{unHaskeline::H.InputTma}deriving(Monad,Functor,Applicative,MonadIO,MonadException,MonadTrans,MonadHaskeline)-- | Run a line-reading application, reading user 'Prefs' from -- @~/.haskeline@runHaskelineT::MonadExceptionm=>H.Settingsm->HaskelineTma->marunHaskelineTsm=H.runInputTs(unHaskelinem)runHaskelineTWithPrefs::MonadExceptionm=>H.Prefs->H.Settingsm->HaskelineTma->marunHaskelineTWithPrefspsm=H.runInputTWithPrefsps(unHaskelinem)classMonadExceptionm=>MonadHaskelinemwheregetInputLine::String->m(MaybeString)getInputChar::String->m(MaybeChar)outputStr::String->m()outputStrLn::String->m()instanceMonadExceptionm=>MonadHaskeline(H.InputTm)wheregetInputLine=H.getInputLinegetInputChar=H.getInputCharoutputStr=H.outputStroutputStrLn=H.outputStrLninstanceMonadStatesm=>MonadStates(HaskelineTm)whereget=liftgetput=lift.putinstanceMonadHaskelinem=>MonadHaskeline(StateTsm)wheregetInputLine=lift.getInputLinegetInputChar=lift.getInputCharoutputStr=lift.outputStroutputStrLn=lift.outputStrLn