1{-# OPTIONS_GHC -Wall #-}
2module Transform.Definition where
4import Control.Applicative ((<$>))
5import qualified SourceSyntax.Pattern as P
6import SourceSyntax.Expression
7import qualified Transform.Expression as Expr
9combineAnnotations :: [ParseDef] -> Either String [Def]
10combineAnnotations = go
12 msg x = "Syntax Error: The type annotation for '" ++ x ++
13 "' must be directly above its definition."
15 exprCombineAnnotations = Expr.crawlLet combineAnnotations
19 TypeAnnotation name tipe : Def pat@(P.PVar name') expr : rest | name == name' ->
20 do expr' <- exprCombineAnnotations expr
21 let def = Definition pat expr' (Just tipe)
24 TypeAnnotation name _ : _ -> Left (msg name)
26 Def pat expr : rest ->
27 do expr' <- exprCombineAnnotations expr
28 let def = Definition pat expr' Nothing
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list