mirror of
https://github.com/anoma/juvix.git
synced 2025-01-05 22:46:08 +03:00
parent
227a51a56d
commit
e8fa77a58d
@ -201,7 +201,19 @@ instance (SingI s) => PrettyPrint (PatternAtoms s) where
|
||||
ppCode (PatternAtoms ps _) = hsep (ppCode <$> ps)
|
||||
|
||||
instance (SingI s) => PrettyPrint (ExpressionAtoms s) where
|
||||
ppCode as = hsep (ppCode <$> as ^. expressionAtoms)
|
||||
ppCode ::
|
||||
forall r.
|
||||
(Members '[ExactPrint, Reader Options] r) =>
|
||||
ExpressionAtoms s ->
|
||||
Sem r ()
|
||||
ppCode as = go (toList $ as ^. expressionAtoms)
|
||||
where
|
||||
go :: [ExpressionAtom s] -> Sem r ()
|
||||
go = \case
|
||||
[] -> return ()
|
||||
[x] -> ppCode x
|
||||
(x : xs@(AtomRecordUpdate {} : _)) -> ppCode x >> go xs
|
||||
(x : xs) -> ppCode x >> space >> go xs
|
||||
|
||||
instance (SingI s) => PrettyPrint (Initializer s) where
|
||||
ppCode Initializer {..} = do
|
||||
|
@ -72,11 +72,16 @@ ppUChain (UChain opFix f links) = do
|
||||
pp <- asks (^. apePP)
|
||||
let f' = ppLinkExpr fx f
|
||||
args = hsep (fmap pp links)
|
||||
f' <+> args
|
||||
f' <> sp <> args
|
||||
where
|
||||
fx :: Precedence
|
||||
fx = opFix ^. fixityPrecedence
|
||||
|
||||
sp :: Sem r ()
|
||||
sp = case fx of
|
||||
PrecUpdate -> return ()
|
||||
_ -> space
|
||||
|
||||
ppLinkExpr ::
|
||||
(Members '[Reader (ApeParams a), ExactPrint] r) => Precedence -> Cape a -> Sem r ()
|
||||
ppLinkExpr opFix e = parensIf cond (ppCape e)
|
||||
|
@ -17,21 +17,20 @@ type Pair (A B : Type) :=
|
||||
};
|
||||
|
||||
mf : Pair (Pair Bool (List Nat)) (List Nat) → Bool
|
||||
| mkPair@{fst := mkPair@{fst; snd := nil}; snd := zero :: _} := fst
|
||||
| mkPair@{fst := mkPair@{fst; snd := nil};
|
||||
snd := zero :: _} := fst
|
||||
| _ := false;
|
||||
|
||||
main : Triple Nat Nat Nat :=
|
||||
let
|
||||
p : Triple Nat Nat Nat := mkTriple 2 2 2;
|
||||
p' :
|
||||
Triple Nat Nat Nat :=
|
||||
p @Triple{
|
||||
fst := fst + 1;
|
||||
snd := snd * 3 + thd + fst
|
||||
};
|
||||
f :
|
||||
Triple Nat Nat Nat -> Triple Nat Nat Nat :=
|
||||
(@Triple{fst := fst * 10});
|
||||
p' : Triple Nat Nat Nat :=
|
||||
p@Triple{
|
||||
fst := fst + 1;
|
||||
snd := snd * 3 + thd + fst
|
||||
};
|
||||
f : Triple Nat Nat Nat -> Triple Nat Nat Nat :=
|
||||
(@Triple{fst := fst * 10});
|
||||
in if
|
||||
(mf (mkPair (fst := mkPair true nil; snd := 0 :: nil)))
|
||||
(f p')
|
||||
|
Loading…
Reference in New Issue
Block a user