Skip to content

Commit

Permalink
Closes #1697
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaprieto committed Jan 4, 2023
1 parent e928ae7 commit c5a2f5d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
4 changes: 1 addition & 3 deletions src/Juvix/Compiler/Concrete/Pretty/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,7 @@ instance SingI s => PrettyCode (InductiveDef s) where
ppConstructorBlock ::
NonEmpty (InductiveConstructorDef s) -> Sem r (Doc Ann)
ppConstructorBlock cs =
do
concatWith (\x y -> x <> softline <> kwPipe <+> y)
<$> mapM ppCode (toList cs)
vsep <$> mapM (fmap (kwPipe <+>) . ppCode) (toList cs)

dotted :: Foldable f => f (Doc Ann) -> Doc Ann
dotted = concatWith (surround kwDot)
Expand Down
4 changes: 3 additions & 1 deletion src/Juvix/Compiler/Concrete/Translation/FromSource.hs
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,9 @@ inductiveDef _inductiveBuiltin = do
P.<?> "<type annotation e.g. ': Type'>"
kw kwAssign P.<?> "<assignment symbol ':='>"
_inductiveConstructors <-
P.sepBy1 constructorDef (kw kwPipe) P.<?> "<constructor definition>"
optional (kw kwPipe)
>> P.sepBy1 constructorDef (kw kwPipe)
P.<?> "<constructor definition>"
return InductiveDef {..}

inductiveParam :: Members '[InfoTableBuilder, JudocStash, NameIdGen] r => ParsecS r (InductiveParameter 'Parsed)
Expand Down
4 changes: 4 additions & 0 deletions test/Scope/Positive.hs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ tests =
"Inductive"
$(mkRelDir ".")
$(mkRelFile "Inductive.juvix"),
PosTest
"Pipes symbol as possible prefix for each data constructor"
$(mkRelDir ".")
$(mkRelFile "InductivePipes.juvix"),
PosTest
"Imports and qualified names"
$(mkRelDir "Imports")
Expand Down
9 changes: 9 additions & 0 deletions tests/positive/InductivePipes.juvix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module InductivePipes;

type T := | t : T;
type T2 :=
| t1 : T2
| t2 : T2
| t3 : T2;

end ;

0 comments on commit c5a2f5d

Please sign in to comment.