1
1
mirror of https://github.com/google/ormolu.git synced 2024-12-02 23:43:34 +03:00

Fix rendering of implicit bidirectional pattern synonyms

Previously we forgot to enable the extension, and apparently we were just
defining a function called ‘pattern’.
This commit is contained in:
mrkkrp 2019-07-08 21:25:05 +02:00 committed by Mark Karpov
parent 3d74f2fb53
commit 99619d681c
7 changed files with 28 additions and 4 deletions

View File

@ -1,6 +1,10 @@
{-# LANGUAGE PatternSynonyms #-}
pattern Arrow t1 t2 = App "->" [t1, t2]
pattern Int =
App "Int" []
pattern Maybe t =
App
"Maybe"

View File

@ -1,3 +1,5 @@
{-# LANGUAGE PatternSynonyms #-}
pattern Arrow t1 t2 = App "->" [t1, t2]
pattern Int =
App "Int" []

View File

@ -9,3 +9,9 @@ pattern HeadC' x <-
x : xs
where
HeadC' x = [x]
pattern Simple <-
"Simple"
where
Simple =
"Complicated"

View File

@ -7,3 +7,7 @@ pattern HeadC' x <-
x:xs
where
HeadC' x = [x]
pattern Simple <- "Simple"
where
Simple = "Complicated"

View File

@ -4,3 +4,5 @@ pattern Head x <- x : xs
pattern Head' x <-
x : xs
pattern Simple <- "Simple"

View File

@ -4,3 +4,5 @@ pattern Head x <- x:xs
pattern Head' x
<- x:xs
pattern Simple <- "Simple"

View File

@ -575,24 +575,28 @@ p_hsExpr = \case
p_patSynBind :: PatSynBind GhcPs GhcPs -> R ()
p_patSynBind PSB {..} = do
txt "pattern "
let nonEmptySynDetails = \case
PrefixCon (_:_) -> True
RecCon (_:_) -> True
_ -> False
case psb_dir of
Unidirectional -> do
p_rdrName psb_id
space
when (nonEmptySynDetails psb_args) space
p_patSynDetails psb_args
txt " <-"
breakpoint
inci (located psb_def p_pat)
ImplicitBidirectional -> do
p_rdrName psb_id
space
when (nonEmptySynDetails psb_args) space
p_patSynDetails psb_args
txt " ="
breakpoint
located psb_def p_pat
inci (located psb_def p_pat)
ExplicitBidirectional mgroup -> do
p_rdrName psb_id
space
when (nonEmptySynDetails psb_args) space
p_patSynDetails psb_args
txt " <-"
breakpoint