haskeline-class (empty) → 0.6
raw patch · 4 files changed
+156/−0 lines, 4 filesdep +basedep +haskelinedep +mtlsetup-changed
Dependencies added: base, haskeline, mtl
Files
- LICENSE +28/−0
- Setup.hs +2/−0
- System/Console/Haskeline/Class.hs +89/−0
- haskeline-class.cabal +37/−0
+ LICENSE view
@@ -0,0 +1,28 @@+Copyright (c) 2009, Antoine Latter++All rights reserved.++Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met:++ * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer.+ * Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution.+ * The names of the authors may not be used to endorse or promote +products derived from this software without specific prior written +permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ System/Console/Haskeline/Class.hs view
@@ -0,0 +1,89 @@+{-# 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++-- Also is 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.++-}++++module System.Console.Haskeline.Class+ (HaskelineT+ ,runHaskelineT+ ,runHaskelineTWithPrefs+ ,MonadHaskeline(..)+ ,H.Settings(..)+ ,H.defaultSettings+ ,H.setComplete+ ,H.Prefs()+ ,H.readPrefs+ ,H.defaultPrefs+ ,H.Interrupt(..)+ ,H.handleInterrupt+ ,module System.Console.Haskeline.Completion+ ,module System.Console.Haskeline.MonadException+ ) where++import qualified System.Console.Haskeline as H+import System.Console.Haskeline.Completion+import System.Console.Haskeline.MonadException++import Control.Applicative+import Control.Monad.State++newtype HaskelineT m a = HaskelineT {unHaskeline :: H.InputT m a}+ deriving (Monad, Functor, Applicative, MonadIO, MonadException, MonadTrans, MonadHaskeline)++runHaskelineT :: MonadException m => H.Settings m -> HaskelineT m a -> m a+runHaskelineT s m = H.runInputT s (unHaskeline m)++runHaskelineTWithPrefs :: MonadException m => H.Prefs -> H.Settings m -> HaskelineT m a -> m a+runHaskelineTWithPrefs p s m = H.runInputTWithPrefs p s (unHaskeline m)++class MonadException m => MonadHaskeline m where+ getInputLine :: String -> m (Maybe String)+ getInputChar :: String -> m (Maybe Char)+ outputStr :: String -> m ()+ outputStrLn :: String -> m ()+++instance MonadException m => MonadHaskeline (H.InputT m) where+ getInputLine = H.getInputLine+ getInputChar = H.getInputChar+ outputStr = H.outputStr+ outputStrLn = H.outputStrLn+++instance MonadState s m => MonadState s (HaskelineT m) where+ get = lift get+ put = lift . put++instance MonadHaskeline m => MonadHaskeline (StateT s m) where+ getInputLine = lift . getInputLine+ getInputChar = lift . getInputChar+ outputStr = lift . outputStr+ outputStrLn = lift . outputStrLn+
+ haskeline-class.cabal view
@@ -0,0 +1,37 @@+Name: haskeline-class+Version: 0.6+License: BSD3+License-File: LICENSE+Author: Antoine Latter+Maintainer: Antoine Latter <aslatter@gmail.com>+Category: User interfaces+Synopsis: Class interface for working with Haskeline+Description: + 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+ .+ * Also is 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.+ .+ Note on build-dependencies: If you've succesfully built this with+ any packages other than the ones noted, please let me know!++Homepage: http://community.haskell.org/~aslatter/code/haskeline-class+Build-Type: Simple+Cabal-Version: >= 1.2++Library+ Build-Depends: haskeline >= 0.6, haskeline < 0.7, base >= 3, base < 5, mtl >= 1.1, mtl < 1.2++ Exposed-modules: System.Console.Haskeline.Class