mirror of
https://github.com/google/ormolu.git
synced 2024-12-11 08:44:45 +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:
parent
3d74f2fb53
commit
99619d681c
@ -1,6 +1,10 @@
|
|||||||
|
{-# LANGUAGE PatternSynonyms #-}
|
||||||
|
|
||||||
pattern Arrow t1 t2 = App "->" [t1, t2]
|
pattern Arrow t1 t2 = App "->" [t1, t2]
|
||||||
|
|
||||||
pattern Int =
|
pattern Int =
|
||||||
App "Int" []
|
App "Int" []
|
||||||
|
|
||||||
pattern Maybe t =
|
pattern Maybe t =
|
||||||
App
|
App
|
||||||
"Maybe"
|
"Maybe"
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
{-# LANGUAGE PatternSynonyms #-}
|
||||||
|
|
||||||
pattern Arrow t1 t2 = App "->" [t1, t2]
|
pattern Arrow t1 t2 = App "->" [t1, t2]
|
||||||
pattern Int =
|
pattern Int =
|
||||||
App "Int" []
|
App "Int" []
|
||||||
|
@ -9,3 +9,9 @@ pattern HeadC' x <-
|
|||||||
x : xs
|
x : xs
|
||||||
where
|
where
|
||||||
HeadC' x = [x]
|
HeadC' x = [x]
|
||||||
|
|
||||||
|
pattern Simple <-
|
||||||
|
"Simple"
|
||||||
|
where
|
||||||
|
Simple =
|
||||||
|
"Complicated"
|
||||||
|
@ -7,3 +7,7 @@ pattern HeadC' x <-
|
|||||||
x:xs
|
x:xs
|
||||||
where
|
where
|
||||||
HeadC' x = [x]
|
HeadC' x = [x]
|
||||||
|
|
||||||
|
pattern Simple <- "Simple"
|
||||||
|
where
|
||||||
|
Simple = "Complicated"
|
||||||
|
@ -4,3 +4,5 @@ pattern Head x <- x : xs
|
|||||||
|
|
||||||
pattern Head' x <-
|
pattern Head' x <-
|
||||||
x : xs
|
x : xs
|
||||||
|
|
||||||
|
pattern Simple <- "Simple"
|
||||||
|
@ -4,3 +4,5 @@ pattern Head x <- x:xs
|
|||||||
|
|
||||||
pattern Head' x
|
pattern Head' x
|
||||||
<- x:xs
|
<- x:xs
|
||||||
|
|
||||||
|
pattern Simple <- "Simple"
|
||||||
|
@ -575,24 +575,28 @@ p_hsExpr = \case
|
|||||||
p_patSynBind :: PatSynBind GhcPs GhcPs -> R ()
|
p_patSynBind :: PatSynBind GhcPs GhcPs -> R ()
|
||||||
p_patSynBind PSB {..} = do
|
p_patSynBind PSB {..} = do
|
||||||
txt "pattern "
|
txt "pattern "
|
||||||
|
let nonEmptySynDetails = \case
|
||||||
|
PrefixCon (_:_) -> True
|
||||||
|
RecCon (_:_) -> True
|
||||||
|
_ -> False
|
||||||
case psb_dir of
|
case psb_dir of
|
||||||
Unidirectional -> do
|
Unidirectional -> do
|
||||||
p_rdrName psb_id
|
p_rdrName psb_id
|
||||||
space
|
when (nonEmptySynDetails psb_args) space
|
||||||
p_patSynDetails psb_args
|
p_patSynDetails psb_args
|
||||||
txt " <-"
|
txt " <-"
|
||||||
breakpoint
|
breakpoint
|
||||||
inci (located psb_def p_pat)
|
inci (located psb_def p_pat)
|
||||||
ImplicitBidirectional -> do
|
ImplicitBidirectional -> do
|
||||||
p_rdrName psb_id
|
p_rdrName psb_id
|
||||||
space
|
when (nonEmptySynDetails psb_args) space
|
||||||
p_patSynDetails psb_args
|
p_patSynDetails psb_args
|
||||||
txt " ="
|
txt " ="
|
||||||
breakpoint
|
breakpoint
|
||||||
located psb_def p_pat
|
inci (located psb_def p_pat)
|
||||||
ExplicitBidirectional mgroup -> do
|
ExplicitBidirectional mgroup -> do
|
||||||
p_rdrName psb_id
|
p_rdrName psb_id
|
||||||
space
|
when (nonEmptySynDetails psb_args) space
|
||||||
p_patSynDetails psb_args
|
p_patSynDetails psb_args
|
||||||
txt " <-"
|
txt " <-"
|
||||||
breakpoint
|
breakpoint
|
||||||
|
Loading…
Reference in New Issue
Block a user