Skip to content

Commit

Permalink
Make it possible to use qualified tags in pattern args
Browse files Browse the repository at this point in the history
  • Loading branch information
process-bot committed Apr 28, 2016
1 parent 328d79e commit f9fabf2
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions src/Parse/Pattern.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,21 @@ basic =
addLocation $
choice
[ char '_' >> return P.Anything
, stringToPattern <$> var
, P.Var <$> lowVar
, chunksToPatterns <$> dotSep1 capVar
, P.Literal <$> Literal.literal
]
where
stringToPattern str =
case str of
"True" ->
P.Literal (L.Boolean True)
chunksToPatterns chunks =
case List.intercalate "." chunks of
"True" ->
P.Literal (L.Boolean True)

"False" ->
P.Literal (L.Boolean False)
"False" ->
P.Literal (L.Boolean False)

c:_ | isUpper c ->
P.Data (Var.Raw str) []

_ ->
P.Var str
name ->
P.Data (Var.Raw name) []


asPattern :: IParser P.Raw -> IParser P.Raw
Expand Down Expand Up @@ -94,11 +92,16 @@ term =
patternConstructor :: IParser P.Raw
patternConstructor =
addLocation $
do v <- List.intercalate "." <$> dotSep1 capVar
case v of
"True" -> return $ P.Literal (L.Boolean True)
"False" -> return $ P.Literal (L.Boolean False)
_ -> P.Data (Var.Raw v) <$> spacePrefix term
do name <- List.intercalate "." <$> dotSep1 capVar
case name of
"True" ->
return $ P.Literal (L.Boolean True)

"False" ->
return $ P.Literal (L.Boolean False)

_ ->
P.Data (Var.Raw name) <$> spacePrefix term


expr :: IParser P.Raw
Expand Down

0 comments on commit f9fabf2

Please sign in to comment.