summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilFreeman <>2014-04-03 21:51:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2014-04-03 21:51:00 (GMT)
commit8add88b45a08ae3543798f11efa8d8d94e50447a (patch)
tree5b54feee031c81a78be51c95615ba8bdfe1fe97f
parent62d49513b34cd5f5d7f6418804f324b1a054d8b9 (diff)
version 0.4.140.4.14
-rw-r--r--docgen/Main.hs6
-rw-r--r--psci/Main.hs20
-rw-r--r--purescript.cabal2
3 files changed, 25 insertions, 3 deletions
diff --git a/docgen/Main.hs b/docgen/Main.hs
index 153096f..f34f748 100644
--- a/docgen/Main.hs
+++ b/docgen/Main.hs
@@ -93,6 +93,7 @@ isExported (Just exps) decl = any (matches decl) exps
matches (P.ExternDataDeclaration ident _) (P.TypeRef ident' _) = ident == ident'
matches (P.TypeSynonymDeclaration ident _ _) (P.TypeRef ident' _) = ident == ident'
matches (P.TypeClassDeclaration ident _ _) (P.TypeClassRef ident') = ident == ident'
+ matches (P.PositionedDeclaration _ d) r = d `matches` r
matches _ _ = False
isDctorExported :: P.ProperName -> Maybe [P.DeclarationRef] -> P.ProperName -> Bool
@@ -143,25 +144,30 @@ getName (P.ExternDataDeclaration name _) = P.runProperName name
getName (P.TypeSynonymDeclaration name _ _) = P.runProperName name
getName (P.TypeClassDeclaration name _ _) = P.runProperName name
getName (P.TypeInstanceDeclaration name _ _ _ _) = show name
+getName (P.PositionedDeclaration _ d) = getName d
getName _ = error "Invalid argument to getName"
isValueDeclaration :: P.Declaration -> Bool
isValueDeclaration P.TypeDeclaration{} = True
isValueDeclaration P.ExternDeclaration{} = True
+isValueDeclaration (P.PositionedDeclaration _ d) = isValueDeclaration d
isValueDeclaration _ = False
isTypeDeclaration :: P.Declaration -> Bool
isTypeDeclaration P.DataDeclaration{} = True
isTypeDeclaration P.ExternDataDeclaration{} = True
isTypeDeclaration P.TypeSynonymDeclaration{} = True
+isTypeDeclaration (P.PositionedDeclaration _ d) = isTypeDeclaration d
isTypeDeclaration _ = False
isTypeClassDeclaration :: P.Declaration -> Bool
isTypeClassDeclaration P.TypeClassDeclaration{} = True
+isTypeClassDeclaration (P.PositionedDeclaration _ d) = isTypeClassDeclaration d
isTypeClassDeclaration _ = False
isTypeInstanceDeclaration :: P.Declaration -> Bool
isTypeInstanceDeclaration P.TypeInstanceDeclaration{} = True
+isTypeInstanceDeclaration (P.PositionedDeclaration _ d) = isTypeInstanceDeclaration d
isTypeInstanceDeclaration _ = False
inputFile :: Term FilePath
diff --git a/psci/Main.hs b/psci/Main.hs
index 94e4df7..0480b05 100644
--- a/psci/Main.hs
+++ b/psci/Main.hs
@@ -27,13 +27,14 @@ import Control.Monad.Trans.State.Strict
import Data.List (intercalate, isPrefixOf, nub, sortBy)
import Data.Maybe (mapMaybe)
+import Data.Foldable (traverse_)
import Data.Traversable (traverse)
import Data.Version (showVersion)
import Parser
import System.Console.Haskeline
-import System.Directory (doesFileExist, findExecutable, getHomeDirectory)
+import System.Directory (doesFileExist, findExecutable, getHomeDirectory, getCurrentDirectory)
import System.Exit
import System.Environment.XDG.BaseDir
import System.FilePath ((</>), isPathSeparator)
@@ -45,7 +46,7 @@ import Text.Parsec (ParseError)
import qualified Data.Map as M
import qualified Language.PureScript as P
import qualified Paths_purescript as Paths
-import qualified System.IO.UTF8 as U (readFile)
+import qualified System.IO.UTF8 as U (print, readFile)
-- |
-- The PSCI state.
@@ -289,11 +290,25 @@ inputFiles :: Cmd.Term [FilePath]
inputFiles = Cmd.value $ Cmd.posAny [] $ Cmd.posInfo { Cmd.posName = "file(s)"
, Cmd.posDoc = "Optional .purs files to load on start" }
+loadUserConfig :: IO (Maybe [Command])
+loadUserConfig = do
+ configFile <- (</> ".psci") <$> getCurrentDirectory
+ exists <- doesFileExist configFile
+ if exists
+ then do
+ ls <- lines <$> U.readFile configFile
+ case mapM parseCommand ls of
+ Left err -> U.print err >> exitFailure
+ Right cs -> return $ Just cs
+ else
+ return Nothing
+
-- |
-- The PSCI main loop.
--
loop :: [FilePath] -> IO ()
loop files = do
+ config <- loadUserConfig
preludeFilename <- getPreludeFilename
modulesOrFirstError <- fmap concat . sequence <$> mapM loadModule (preludeFilename : files)
case modulesOrFirstError of
@@ -303,6 +318,7 @@ loop files = do
let settings = defaultSettings {historyFile = Just historyFilename}
flip evalStateT (PSCiState (preludeFilename : files) defaultImports modules []) . runInputT (setComplete completion settings) $ do
outputStrLn prologueMessage
+ traverse_ (mapM_ handleCommand) config
go
where
go :: InputT (StateT PSCiState IO) ()
diff --git a/purescript.cabal b/purescript.cabal
index feb2cf7..4d022f7 100644
--- a/purescript.cabal
+++ b/purescript.cabal
@@ -1,5 +1,5 @@
name: purescript
-version: 0.4.13.1
+version: 0.4.14
cabal-version: >=1.8
build-type: Custom
license: MIT