1{-# LANGUAGE DeriveDataTypeable #-}
2module SourceSyntax.Pattern where
4import Data.Char (isDigit)
5import Data.List (intercalate)
7import SourceSyntax.Helpers
8import qualified SourceSyntax.Literal as Literal
10data Pattern = PData String [Pattern]
12 | PAlias String Pattern
15 | PLiteral Literal.Literal
16 deriving (Eq, Ord, Data, Typeable)
18cons h t = PData "::" [h,t]
21tuple es = PData ("Tuple" ++ show (length es)) es
24instance Show Pattern where
28 PLiteral lit -> show lit
29 PRecord fs -> brkt (intercalate ", " fs)
30 PAlias x p -> show p ++ " as " ++ x
32 PData "::" [hd@(PData "::" _),tl] ->
33 parens (show hd) ++ " :: " ++ show tl
34 PData "::" [hd,tl] -> show hd ++ " :: " ++ show tl
37 if take 5 name == "Tuple" && all isDigit (drop 5 name) then
38 parens . intercalate ", " $ map show ps
39 else parensIf (not (null ps)) $ unwords (name : map show ps)
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