Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
janmasrovira committed Sep 29, 2023
1 parent 3487eee commit b64a388
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Juvix/Compiler/Concrete/Print/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,10 @@ instance (SingI s) => PrettyPrint (Argument s) where
ArgumentSymbol s -> ppSymbolType s
ArgumentWildcard w -> ppCode w

instance (SingI s) => PrettyPrint (ArgDefault s) where
ppCode ArgDefault {..} = do
ppCode _argDefaultAssign <+> ppExpressionType _argDefaultValue

instance (SingI s) => PrettyPrint (SigArg s) where
ppCode :: (Members '[ExactPrint, Reader Options] r) => SigArg s -> Sem r ()
ppCode SigArg {..} = do
Expand All @@ -919,9 +923,11 @@ instance (SingI s) => PrettyPrint (SigArg s) where
colon' = ppCode <$> _sigArgColon
ty = ppExpressionType <$> _sigArgType
arg = case _sigArgImplicit of
ImplicitInstance | isNothing colon' -> mempty <>? ty
ImplicitInstance
| isNothing colon' -> mempty <>? ty
_ -> names' <+?> colon' <+?> ty
ppCode l <> arg <> ppCode r
defaultVal = ppCode <$> _sigArgDefault
ppCode l <> arg <+?> defaultVal <> ppCode r

ppFunctionSignature :: (SingI s) => PrettyPrinting (FunctionDef s)
ppFunctionSignature FunctionDef {..} = do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Juvix.Compiler.Concrete.Keywords
import Juvix.Compiler.Concrete.Language
import Juvix.Compiler.Concrete.Translation.FromParsed.Analysis.Scoping.Error
import Juvix.Prelude
import Juvix.Compiler.Concrete.Pretty

data BuilderState = BuilderState
{ _stateRemainingArgs :: [ArgumentBlock 'Scoped],
Expand Down Expand Up @@ -67,6 +68,7 @@ helper loc = do
case remb of
[] -> return (Nothing, mempty)
b : bs -> do
traceM (ppTrace b)
let implNames = b ^. nameImplicit
defVal = b ^. nameDefault

Expand Down
20 changes: 20 additions & 0 deletions tests/positive/DefaultValues.juvix
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module DefaultValues;

import Stdlib.Data.Product open;

axiom A : Type;

axiom B : Type;

axiom C : Type;

axiom a : Type;

axiom b : Type;

axiom c : Type;

mk {f1 : A := a} {f2 : B} {f3 : C := c} (x : A) : A × B × C :=
f1, f2, f3;

x : A × B × C := mk (x := a);

0 comments on commit b64a388

Please sign in to comment.