ignore layout tokens during type parsing

This commit is contained in:
Paul Chiusano 2016-08-21 17:55:12 -04:00
parent 78c3cddef0
commit 632fc73cf9
3 changed files with 12 additions and 5 deletions

View File

@ -148,7 +148,7 @@ possiblyAnnotated p = f <$> p <*> optional ann''
f t Nothing = t
ann'' :: Var v => Parser (Type v)
ann'' = token (char ':') *> TypeParser.type_
ann'' = withoutLayout $ token (char ':') *> TypeParser.type_
--let server = _; blah = _ in _
let_ :: Var v => Parser (Term v) -> Parser (Term v)

View File

@ -3,12 +3,12 @@
module Unison.TypeParser where
import Control.Applicative ((<|>), some)
import Control.Applicative ((<|>), some, many)
import Data.Char (isUpper, isLower, isAlpha)
import Data.Foldable (asum)
import Data.Functor
import Data.List (foldl1')
import Unison.Parser
import Unison.Parser hiding (ignored, token)
import Unison.Type (Type)
import Unison.Var (Var)
import qualified Data.Text as Text
@ -17,6 +17,13 @@ import qualified Unison.Type as Type
type_ :: Var v => Parser (Type v)
type_ = forall type1 <|> type1
-- we ignore indentation markers { and }, but not semicolon
ignored :: Parser ()
ignored = void $ many (whitespace1 <|> haskellLineComment <|> (void $ one (\c -> c == '{' || c == '}')))
token :: Parser a -> Parser a
token p = (p <* ignored)
typeLeaf :: Var v => Parser (Type v)
typeLeaf =
asum [ literal

View File

@ -7,8 +7,8 @@ then f1 f2 x = f2 (f1 x)
Remote.transfer : Node -> Remote Unit
Remote.transfer node = Remote.at node unit
-- Apply a function to a `Remote`
Remote.map : ∀ a b . (a -> b) -> Remote a -> Remote b
Remote.map :
∀ a b . (a -> b) -> Remote a -> Remote b
Remote.map f =
Remote.bind (f `then` Remote.pure)