diff options
author | PhilFreeman <> | 2014-04-26 19:25:00 (GMT) |
---|---|---|
committer | hdiff <hdiff@hdiff.luite.com> | 2014-04-26 19:25:00 (GMT) |
commit | 4f5c6e6810eca03d0caf685b6f932cac676936be (patch) | |
tree | 88ee9ff28af92565d31ad196243990eb7e6b90a8 | |
parent | f6472f48d003d550de3ee5b5d9fbbfe6566658d5 (diff) |
version 0.4.200.4.20
-rw-r--r-- | docgen/Main.hs | 75 | ||||
-rw-r--r-- | psci/Main.hs | 4 | ||||
-rw-r--r-- | purescript.cabal | 4 | ||||
-rw-r--r-- | src/Language/PureScript/TypeChecker/Types.hs | 2 |
4 files changed, 50 insertions, 35 deletions
diff --git a/docgen/Main.hs b/docgen/Main.hs index a5d289c..8384dfa 100644 --- a/docgen/Main.hs +++ b/docgen/Main.hs @@ -26,16 +26,21 @@ import qualified System.IO.UTF8 as U import System.Console.CmdTheLine import System.Exit (exitSuccess, exitFailure) -docgen :: FilePath -> IO () -docgen input = do +docgen :: Bool -> [FilePath] -> IO () +docgen showHierarchy input = do + ms <- mapM parseFile (nub input) + U.putStrLn . runDocs $ (renderModules showHierarchy) (concat ms) + exitSuccess + +parseFile :: FilePath -> IO [P.Module] +parseFile input = do text <- U.readFile input case P.runIndentParser input P.parseModules text of Left err -> do U.print err exitFailure Right ms -> do - U.putStrLn . runDocs $ renderModules ms - exitSuccess + return ms type Docs = Writer [String] () @@ -53,37 +58,45 @@ atIndent indent text = let ls = lines text in forM_ ls $ \l -> tell [replicate indent ' ' ++ l] -renderModules :: [P.Module] -> Docs -renderModules ms = do +renderModules :: Bool -> [P.Module] -> Docs +renderModules showHierarchy ms = do headerLevel 1 "Module Documentation" - mapM_ renderModule ms + spacer + mapM_ (renderModule showHierarchy) ms -renderModule :: P.Module -> Docs -renderModule (P.Module moduleName ds exps) = +renderModule :: Bool -> P.Module -> Docs +renderModule showHierarchy (P.Module moduleName ds exps) = let exported = filter (isExported exps) ds + hasTypes = any isTypeDeclaration ds hasTypeclasses = any isTypeClassDeclaration ds + hasTypeclassInstances = any isTypeInstanceDeclaration ds + hasValues = any isValueDeclaration ds in do headerLevel 2 $ "Module " ++ P.runModuleName moduleName spacer - headerLevel 3 "Types" - spacer - renderTopLevel exps (filter isTypeDeclaration exported) - spacer - headerLevel 3 "Type Classes" - spacer + when hasTypes $ do + headerLevel 3 "Types" + spacer + renderTopLevel exps (filter isTypeDeclaration exported) + spacer when hasTypeclasses $ do - renderTypeclassImage moduleName + headerLevel 3 "Type Classes" + spacer + when showHierarchy $ do + renderTypeclassImage moduleName + spacer + renderTopLevel exps (filter isTypeClassDeclaration exported) + spacer + when hasTypeclassInstances $ do + headerLevel 3 "Type Class Instances" + spacer + renderTopLevel exps (filter isTypeInstanceDeclaration ds) + spacer + when hasValues $ do + headerLevel 3 "Values" + spacer + renderTopLevel exps (filter isValueDeclaration exported) spacer - renderTopLevel exps (filter isTypeClassDeclaration exported) - spacer - headerLevel 3 "Type Class Instances" - spacer - renderTopLevel exps (filter isTypeInstanceDeclaration ds) - spacer - headerLevel 3 "Values" - spacer - renderTopLevel exps (filter isValueDeclaration exported) - spacer isExported :: Maybe [P.DeclarationRef] -> P.Declaration -> Bool isExported Nothing _ = True @@ -98,6 +111,7 @@ isExported (Just exps) decl = any (matches decl) exps 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 d (P.PositionedDeclarationRef _ r) = d `matches` r matches _ _ = False isDctorExported :: P.ProperName -> Maybe [P.DeclarationRef] -> P.ProperName -> Bool @@ -182,11 +196,14 @@ isTypeInstanceDeclaration P.TypeInstanceDeclaration{} = True isTypeInstanceDeclaration (P.PositionedDeclaration _ d) = isTypeInstanceDeclaration d isTypeInstanceDeclaration _ = False -inputFile :: Term FilePath -inputFile = value $ pos 0 "input.ps" $ posInfo { posDoc = "The input .ps file" } +inputFiles :: Term [FilePath] +inputFiles = value $ posAny [] $ posInfo { posName = "file(s)", posDoc = "The input .purs file(s)" } + +includeHeirarcy :: Term Bool +includeHeirarcy = value $ flag $ (optInfo [ "h", "hierarchy-images" ]) { optDoc = "Include markdown for type class hierarchy images in the output." } term :: Term (IO ()) -term = docgen <$> inputFile +term = docgen <$> includeHeirarcy <*> inputFiles termInfo :: TermInfo termInfo = defTI diff --git a/psci/Main.hs b/psci/Main.hs index dc82c18..577679c 100644 --- a/psci/Main.hs +++ b/psci/Main.hs @@ -257,10 +257,10 @@ createTemporaryModule exec PSCiState{psciImportedModuleNames = imports, psciLetB P.Module moduleName ((importDecl `map` imports) ++ decls) Nothing modulesDir :: FilePath -modulesDir = "psci_modules" ++ pathSeparator : "node_modules" +modulesDir = ".psci_modules" ++ pathSeparator : "node_modules" indexFile :: FilePath -indexFile = "psci_modules" ++ pathSeparator : "index.js" +indexFile = ".psci_modules" ++ pathSeparator : "index.js" -- | -- Takes a value declaration and evaluates it with the current state. diff --git a/purescript.cabal b/purescript.cabal index 7e6ca1b..79ba8e4 100644 --- a/purescript.cabal +++ b/purescript.cabal @@ -1,5 +1,5 @@ name: purescript -version: 0.4.19.1 +version: 0.4.20 cabal-version: >=1.8 build-type: Custom license: MIT @@ -8,7 +8,7 @@ copyright: (c) 2013-14 Phil Freeman, (c) 2014 Gary Burgess, and other contributo maintainer: Phil Freeman <paf31@cantab.net> stability: experimental synopsis: PureScript Programming Language Compiler -description: A small compile-to-JS language with extensible records and type-safe blocks +description: A small strongly, statically typed programming language with expressive types, inspired by Haskell and compiling to Javascript. category: Language Homepage: http://www.purescript.org/ author: Phil Freeman <paf31@cantab.net>, diff --git a/src/Language/PureScript/TypeChecker/Types.hs b/src/Language/PureScript/TypeChecker/Types.hs index 89297d6..d2003df 100644 --- a/src/Language/PureScript/TypeChecker/Types.hs +++ b/src/Language/PureScript/TypeChecker/Types.hs @@ -421,8 +421,6 @@ pairwise p (x : xs) = all (p x) xs && pairwise p xs -- Check that two types unify -- unifiesWith :: Environment -> Type -> Type -> Bool -unifiesWith _ (TUnknown _) _ = True -unifiesWith _ _ (TUnknown _) = True unifiesWith _ (Skolem _ s1 _) (Skolem _ s2 _) | s1 == s2 = True unifiesWith _ (TypeVar v1) (TypeVar v2) | v1 == v2 = True unifiesWith _ (TypeConstructor c1) (TypeConstructor c2) | c1 == c2 = True |