1{-# OPTIONS_GHC -Wall #-}
9import qualified Data.List as List
11import qualified AST.Literal as L
12import qualified AST.Pattern as P
13import qualified AST.Variable as Var
14import qualified Reporting.Annotation as A
22 = Ctor Var.Canonical [Pattern]
28fromCanonicalPattern :: P.Canonical -> Pattern
29fromCanonicalPattern (A.A _ pattern) =
31 P.Data name patterns ->
32 Ctor name (map fromCanonicalPattern patterns)
37 P.Alias _ subPattern ->
38 fromCanonicalPattern subPattern
46 P.Literal (L.Boolean True) ->
47 Ctor (Var.builtin "True") []
49 P.Literal (L.Boolean False) ->
50 Ctor (Var.builtin "False") []
60toString :: Bool -> Pattern -> String
61toString needsParens pattern =
63 Ctor tag [first,rest] | Var.toString tag == "::" ->
64 toString (isCons first) first
66 ++ toString False rest
69 if Var.isTuple tag then
70 if null args then "()" else
71 "( " ++ List.intercalate ", " (map (toString False) args) ++ " )"
74 addParensIf (needsParens && not (null args)) $
75 List.intercalate " " (Var.toString tag : map (toString True) args)
84addParensIf :: Bool -> String -> String
85addParensIf needsParens str =
93isCons :: Pattern -> Bool
97 Var.toString tag == "::"
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