packages feed

purescript 0.6.9 → 0.6.9.1

raw patch · 2 files changed

+81/−1 lines, 2 files

Files

+ psci/Directive.hs view
@@ -0,0 +1,79 @@+-----------------------------------------------------------------------------+--+-- Module      :  Directive+-- Copyright   :+-- License     :  MIT+--+-- Maintainer  :+-- Stability   :  experimental+-- Portability :+--+-- |+-- Directives for PSCI.+--+-----------------------------------------------------------------------------++module Directive where++import Data.List (nub, isPrefixOf)++data Directive+  = Help+  | Quit+  | Reset+  | Browse+  | Load+  | Type+  | Kind+  | Show+  deriving Eq++-- |+-- Maps given directive to relating command strings.+--+commands :: Directive -> [String]+commands Help = ["?", "help"]+commands Quit = ["quit"]+commands Reset = ["reset"]+commands Browse = ["browse"]+commands Load = ["load", "module"]+commands Type = ["type"]+commands Kind = ["kind"]+commands Show = ["show"]++-- |+-- Tries to parse given string into a directive.+--+parseDirective :: String -> Maybe Directive+parseDirective cmd =+  case filter (matches . snd) mapping of+    [directive] -> Just $ fst directive+    _ -> Nothing+  where+  mapping :: [(Directive, [String])]+  mapping = zip directives (map commands directives)++  matches :: [String] -> Bool+  matches = any (cmd `isPrefixOf`)++-- |+-- The help menu.+--+help :: [(Directive, String, String)]+help =+  [ (Help,   "",         "Show this help menu")+  , (Quit,   "",         "Quit PSCi")+  , (Reset,  "",         "Reset")+  , (Browse, "<module>", "Browse <module>")+  , (Load,   "<file>",   "Load <file> for importing")+  , (Type,   "<expr>",   "Show the type of <expr>")+  , (Kind,   "<type>",   "Show the kind of <type>")+  , (Show,   "import",   "Show imported modules")+  , (Show,   "loaded",   "Show loaded modules")+  ]++-- |+-- List of all avaliable directives.+--+directives :: [Directive]+directives = nub . map (\(dir, _, _) -> dir) $ help
purescript.cabal view
@@ -1,5 +1,5 @@ name: purescript-version: 0.6.9+version: 0.6.9.1 cabal-version: >=1.8 build-type: Simple license: MIT@@ -151,6 +151,7 @@     hs-source-dirs: psci     other-modules: Commands                    Parser+                   Directive     ghc-options: -Wall -O2  executable psc-docs