Merge branch 'replace-open' into dev

This commit is contained in:
Evan Czaplicki 2014-02-18 14:23:25 -05:00
commit 8aba726d22
11 changed files with 28 additions and 21 deletions

View file

@ -1,6 +1,7 @@
## next ## next
* Change syntax for "import open List" to "import List (..)"
* Support Trampolining (thanks to Max New and Tim Hobbs) * Support Trampolining (thanks to Max New and Tim Hobbs)
* Drastically improved performance on markdown parsing (thanks to @Dandandan) * Drastically improved performance on markdown parsing (thanks to @Dandandan)
* Improved JSON format for types generated by elm-doc * Improved JSON format for types generated by elm-doc

View file

@ -169,7 +169,8 @@ betwixt a b c = do char a ; out <- c
char b <?> "closing '" ++ [b] ++ "'" ; return out char b <?> "closing '" ++ [b] ++ "'" ; return out
surround a z name p = do surround a z name p = do
char a ; v <- padded p char a
v <- padded p
char z <?> unwords ["closing", name, show z] char z <?> unwords ["closing", name, show z]
return v return v

View file

@ -8,7 +8,7 @@ import Parse.Helpers
import SourceSyntax.Module (ImportMethod(..), Imports) import SourceSyntax.Module (ImportMethod(..), Imports)
varList :: IParser [String] varList :: IParser [String]
varList = parens $ commaSep1 (var <|> parens symOp) varList = commaSep1 (var <|> parens symOp)
getModuleName :: String -> Maybe String getModuleName :: String -> Maybe String
getModuleName source = getModuleName source =
@ -27,7 +27,7 @@ moduleDef = do
whitespace whitespace
names <- dotSep1 capVar <?> "name of module" names <- dotSep1 capVar <?> "name of module"
whitespace whitespace
exports <- option [] varList exports <- option [] (parens varList)
whitespace <?> "reserved word 'where'" whitespace <?> "reserved word 'where'"
reserved "where" reserved "where"
return (names, exports) return (names, exports)
@ -38,17 +38,22 @@ imports = option [] ((:) <$> import' <*> many (try (freshLine >> import')))
import' :: IParser (String, ImportMethod) import' :: IParser (String, ImportMethod)
import' = import' =
do reserved "import" do reserved "import"
whitespace
open <- optionMaybe (reserved "open")
whitespace whitespace
name <- intercalate "." <$> dotSep1 capVar name <- intercalate "." <$> dotSep1 capVar
case open of (,) name <$> option (As name) method
Just _ -> return (name, Hiding [])
Nothing -> let how = try (whitespace >> (as' <|> importing'))
in (,) name <$> option (As name) how
where where
method :: IParser ImportMethod
method = try $ do whitespace
as' <|> importing'
as' :: IParser ImportMethod as' :: IParser ImportMethod
as' = reserved "as" >> whitespace >> As <$> capVar <?> "alias for module" as' = do
reserved "as"
whitespace
As <$> capVar <?> "alias for module"
importing' :: IParser ImportMethod importing' :: IParser ImportMethod
importing' = Importing <$> varList <?> "listing of imported values (x,y,z)" importing' =
parens (choice [ const (Hiding []) <$> string ".."
, Importing <$> varList
] <?> "listing of imported values (x,y,z)")

View file

@ -31,8 +31,8 @@ Insert, remove, and query operations all take *O(log n)* time.
-} -}
import open Basics import Basics (..)
import open Maybe import Maybe (..)
import Native.Error import Native.Error
import List import List
import String import String

View file

@ -30,7 +30,7 @@ it as a single unit.
-} -}
import open Basics import Basics (..)
import List import List
import Either (Either, Left, Right) import Either (Either, Left, Right)
import Transform2D (Transform2D, identity) import Transform2D (Transform2D, identity)

View file

@ -37,12 +37,12 @@ If you need more precision, you can create custom positions.
midRightAt, topLeftAt, topRightAt, bottomLeftAt, bottomRightAt midRightAt, topLeftAt, topRightAt, bottomLeftAt, bottomRightAt
-} -}
import open Basics import Basics (..)
import Native.Utils import Native.Utils
import JavaScript as JS import JavaScript as JS
import JavaScript (JSString) import JavaScript (JSString)
import List as List import List as List
import open Color import Color (..)
import Maybe (Maybe, Just, Nothing) import Maybe (Maybe, Just, Nothing)
type Properties = { type Properties = {

View file

@ -14,7 +14,7 @@ you have very strict latency requirements.
@docs Response @docs Response
-} -}
import open Signal import Signal (..)
import Native.Http import Native.Http
{-| The datatype for responses. Success contains only the returned message. {-| The datatype for responses. Success contains only the returned message.

View file

@ -17,7 +17,7 @@ module Json where
-} -}
import open Basics import Basics (..)
import Dict import Dict
import Maybe (Maybe) import Maybe (Maybe)
import JavaScript as JS import JavaScript as JS

View file

@ -25,7 +25,7 @@ list must have the same type.
@docs sort, sortBy, sortWith @docs sort, sortBy, sortWith
-} -}
import open Basics import Basics (..)
import Native.List import Native.List
{-| Add an element to the front of a list `(1 :: [2,3] == [1,2,3])` -} {-| Add an element to the front of a list `(1 :: [2,3] == [1,2,3])` -}

View file

@ -16,7 +16,7 @@ module Text where
-} -}
import open Basics import Basics (..)
import Color (Color) import Color (Color)
import Graphics.Element (Element, Three, Pos, ElementPrim, Properties) import Graphics.Element (Element, Three, Pos, ElementPrim, Properties)
import Maybe (Maybe) import Maybe (Maybe)

View file

@ -14,7 +14,7 @@ module Time where
-} -}
import open Basics import Basics (..)
import Native.Time import Native.Time
import Signal (Signal) import Signal (Signal)