1
1
mirror of https://github.com/anoma/juvix.git synced 2024-11-23 08:18:43 +03:00

[pretty] improve parentheses wip

This commit is contained in:
Jan Mas Rovira 2022-02-03 13:47:43 +01:00
parent d6fd0ae4e0
commit aea7208d88
2 changed files with 27 additions and 1 deletions

View File

@ -3,7 +3,7 @@ module MiniJuvix.Syntax.Concrete.Fixity where
import Language.Haskell.TH.Syntax (Lift)
import MiniJuvix.Utils.Prelude
type Precedence = Natural
type Precedence = Int
data UnaryAssoc = AssocPrefix | AssocPostfix
deriving stock (Show, Eq, Ord, Lift)

View File

@ -543,6 +543,32 @@ ppPostfixApplication PostfixApplication {..} = do
postfixAppOperator' <- ppSName postfixAppOperator
return $ postfixAppParameter' <+> postfixAppOperator'
data Atomicity =
Atom
| NoAtom (Fixity, S.NameId)
atomicity :: Expression -> Atomicity
atomicity e = case e of
ExpressionIdentifier {} -> Atom
ExpressionApplication a -> goApplication a
ExpressionInfixApplication a -> goInfixApplication a
ExpressionPostfixApplication a -> goPostfixApplication a
ExpressionLambda {} -> Atom
ExpressionMatch {} -> Atom
ExpressionLetBlock {} -> Atom
ExpressionUniverse {} -> Atom
ExpressionFunction f -> goFunction f
where
goFunction :: Function 'Scoped -> Atomicity
goFunction = undefined
goApplication :: Application -> Atomicity
goApplication = undefined
goInfixApplication :: InfixApplication -> Atomicity
goInfixApplication = undefined
goPostfixApplication :: PostfixApplication -> Atomicity
goPostfixApplication = undefined
ppExpression :: forall r. Members '[Reader Options] r => Expression -> Sem r (Doc Ann)
ppExpression = go
where