From 531ec3e2051b874acfc9143cb6a0870bda0fd13b Mon Sep 17 00:00:00 2001 From: Siddharth Krishna Date: Wed, 15 Nov 2023 07:02:04 +0200 Subject: [PATCH 01/16] Tighter pretty printer --- inferno-core/app/Main.hs | 28 ++++++++++++++------- inferno-types/src/Inferno/Types/Syntax.hs | 30 +++++++++++------------ 2 files changed, 33 insertions(+), 25 deletions(-) diff --git a/inferno-core/app/Main.hs b/inferno-core/app/Main.hs index ce3005f..e21e389 100644 --- a/inferno-core/app/Main.hs +++ b/inferno-core/app/Main.hs @@ -1,12 +1,15 @@ {-# LANGUAGE LambdaCase #-} {-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE ScopedTypeVariables #-} module Main where import qualified Data.Map as Map import qualified Data.Text.IO as Text import Inferno.Core (Interpreter (..), mkInferno) +import Inferno.Module (Prelude, baseOpsTable, moduleOpsTables) import Inferno.Module.Prelude (builtinPrelude) +import Inferno.Parse (parseExpr) import Inferno.Utils.Prettyprinter (showPretty) import System.Environment (getArgs) import System.Exit (exitFailure) @@ -18,13 +21,20 @@ main = do src <- Text.readFile file Interpreter {evalExpr, defaultEnv, parseAndInferTypeReps} <- mkInferno builtinPrelude [] :: IO (Interpreter IO ()) - case parseAndInferTypeReps src of - Left err -> do + let prelude :: Prelude IO () = builtinPrelude + case parseExpr (baseOpsTable prelude) (moduleOpsTables prelude) [] src of + Left err -> hPutStrLn stderr $ show err - exitFailure - Right ast -> - evalExpr defaultEnv Map.empty ast >>= \case - Left err -> do - hPutStrLn stderr $ show err - exitFailure - Right res -> showPretty res + Right (ast, comments) -> + showPretty ast + +-- case parseAndInferTypeReps src of +-- Left err -> do +-- hPutStrLn stderr $ show err +-- exitFailure +-- Right ast -> +-- evalExpr defaultEnv Map.empty ast >>= \case +-- Left err -> do +-- hPutStrLn stderr $ show err +-- exitFailure +-- Right res -> showPretty res diff --git a/inferno-types/src/Inferno/Types/Syntax.hs b/inferno-types/src/Inferno/Types/Syntax.hs index 2edb9e9..8e5294f 100644 --- a/inferno-types/src/Inferno/Types/Syntax.hs +++ b/inferno-types/src/Inferno/Types/Syntax.hs @@ -170,9 +170,8 @@ import Prettyprinter rbracket, rparen, sep, - vsep, - -- sep, -- tupled, + vsep, (<+>), ) import qualified Prettyprinter.Internal as Pretty @@ -408,18 +407,16 @@ instance Pretty TypeClassShape where instance Pretty TCScheme where pretty (ForallTC xs tcs (ImplType impl ty)) = - prettyXs xs - <+> prettyPrecondition - <+> pretty ty + group $ prettyXs xs <> prettyPrecondition <> pretty ty where prettyXs [] = mempty - prettyXs xs' = "forall" <+> sep (fmap pretty xs') <+> "." + prettyXs xs' = "forall" <+> sep (fmap pretty xs') <> "." <> line prettyTcs tcs' = map (("requires" <+>) . pretty) $ Set.toList tcs' prettyImpls impls = map (\(ExtIdent idt, t) -> "implicit" <+> case idt of { Left i -> "var$" <> pretty i; Right i -> pretty i } <+> ":" <+> align (pretty t)) $ Map.toList impls prettyPrecondition = case prettyTcs tcs ++ prettyImpls impl of [] -> mempty - precs -> encloseSep lbrace rbrace comma precs <+> "⇒" + precs -> encloseSep lbrace rbrace comma precs <+> "⇒" <> line newtype Subst = Subst (Map.Map TV InfernoType) deriving stock (Eq, Ord) @@ -1375,17 +1372,18 @@ prettyPrec isBracketed prec expr = [x] -> prettyAppAux x $ prettyPrec True 0 x (x : xs) -> (prettyAppAux x $ prettyPrec True 0 x) <> (if hasTrailingComment x then hardline else line) <> prettyApp xs Lam _ xs _ e -> - let fun = "fun" <+> align (sep $ map (fromMaybe "_" . fmap pretty . snd) $ toList xs) <+> "->" - body = align $ prettyPrec False 0 e - in group $ nest 2 $ vsep [fun, body] + let fun = "fun" <+> group (nest 2 (sep $ map (fromMaybe "_" . fmap pretty . snd) $ toList xs)) <+> "->" + body = group $ nest 2 $ prettyPrec False 0 e + in group $ nest 2 $ fun <> line <> body Let _ _ x _ e1 _ e2 -> - let letPretty = "let" <+> align (pretty x <+> "=" <+> align (prettyPrec False 0 e1)) - body = "in" <+> prettyPrec False 0 e2 - in letPretty <> (if hasTrailingComment e1 then hardline else line) <> body + let e1Pretty = group $ (nest 2 $ line <> prettyPrec False 0 e1) <> (if hasTrailingComment e1 then hardline else line) + letPretty = group $ "let" <+> pretty x <+> "=" <> e1Pretty <> "in" + in group $ letPretty <> line <> prettyPrec False 0 e2 LetAnnot _ _ x _ t _ e1 _ e2 -> - let letPretty = "let" <+> align (pretty x <+> ":" <+> pretty t <+> "=" <+> align (prettyPrec False 0 e1)) - body = "in" <+> prettyPrec False 0 e2 - in letPretty <> (if hasTrailingComment e1 then hardline else line) <> body + let e1Pretty = group $ (nest 2 $ line <> prettyPrec False 0 e1) <> (if hasTrailingComment e1 then hardline else line) + tPretty = group $ (nest 2 $ line <> pretty t) <> line + letPretty = group $ "let" <+> pretty x <+> ":" <> tPretty <> "=" <> e1Pretty <> "in" + in group $ letPretty <> line <> prettyPrec False 0 e2 Lit _ l -> pretty l InterpolatedString _ istr _ -> enclose "`" "`" $ group $ From 7294fd1572b9cb299b84536f70bf7d04c9fde9f8 Mon Sep 17 00:00:00 2001 From: Siddharth Krishna Date: Tue, 28 Nov 2023 09:19:59 +0530 Subject: [PATCH 02/16] Tighten if-then, fun --- inferno-types/src/Inferno/Types/Syntax.hs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/inferno-types/src/Inferno/Types/Syntax.hs b/inferno-types/src/Inferno/Types/Syntax.hs index 8e5294f..c24c7a2 100644 --- a/inferno-types/src/Inferno/Types/Syntax.hs +++ b/inferno-types/src/Inferno/Types/Syntax.hs @@ -1372,9 +1372,10 @@ prettyPrec isBracketed prec expr = [x] -> prettyAppAux x $ prettyPrec True 0 x (x : xs) -> (prettyAppAux x $ prettyPrec True 0 x) <> (if hasTrailingComment x then hardline else line) <> prettyApp xs Lam _ xs _ e -> - let fun = "fun" <+> group (nest 2 (sep $ map (fromMaybe "_" . fmap pretty . snd) $ toList xs)) <+> "->" - body = group $ nest 2 $ prettyPrec False 0 e - in group $ nest 2 $ fun <> line <> body + let xsPretty = sep $ map (fromMaybe "_" . fmap pretty . snd) $ toList xs + fun = group $ "fun" <> (group $ nest 2 $ line <> xsPretty) <> line <> "->" + body = group $ nest 2 $ line <> prettyPrec False 0 e + in group $ fun <> body Let _ _ x _ e1 _ e2 -> let e1Pretty = group $ (nest 2 $ line <> prettyPrec False 0 e1) <> (if hasTrailingComment e1 then hardline else line) letPretty = group $ "let" <+> pretty x <+> "=" <> e1Pretty <> "in" @@ -1422,10 +1423,10 @@ prettyPrec isBracketed prec expr = [] -> [] s : xs -> ("}" <> s) : xs If _ c _ t _ f -> - let ifPretty = "if" <+> align (prettyPrec False 0 c) - thenPretty = "then" <+> align (prettyPrec False 0 t) - elsePretty = "else" <+> align (prettyPrec False 0 f) - in nest 2 $ + let ifPretty = "if" <> (group $ nest 2 $ line <> prettyPrec False 0 c) + thenPretty = "then" <> (group $ nest 2 $ line <> prettyPrec False 0 t) + elsePretty = "else" <> (group $ nest 2 $ line <> prettyPrec False 0 f) + in group $ ifPretty <> (if hasTrailingComment c then hardline else line) <> thenPretty @@ -1464,11 +1465,11 @@ prettyPrec isBracketed prec expr = <> (if hasTrailingComment e then hardline else line') <> ", " <> prettyTuple False es - One _ e -> "Some" <+> align (prettyPrec False 0 e) + One _ e -> "Some" <+> nest 2 (prettyPrec False 0 e) Empty _ -> "None" Assert _ c _ e -> - let assertPretty = "assert" <+> align (prettyPrec False 0 c) - body = (flatAlt " in" "in") <+> align (prettyPrec False 0 e) + let assertPretty = "assert" <+> nest 2 (prettyPrec False 0 c) + body = (flatAlt " in" "in") <+> nest 2 (prettyPrec False 0 e) in assertPretty <> (if hasTrailingComment c then hardline else line) <> body Case _ e_case _ patExprs _ -> group $ From 938527e4de5027adc87a88bdec99b89d8ce5f053 Mon Sep 17 00:00:00 2001 From: Siddharth Krishna Date: Tue, 28 Nov 2023 09:20:21 +0530 Subject: [PATCH 03/16] Add a pretty-test exe to inferno-types --- inferno-types/inferno-types.cabal | 12 ++++++++++++ inferno-types/pretty-test/Main.hs | 18 ++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 inferno-types/pretty-test/Main.hs diff --git a/inferno-types/inferno-types.cabal b/inferno-types/inferno-types.cabal index c846b4b..be775e2 100644 --- a/inferno-types/inferno-types.cabal +++ b/inferno-types/inferno-types.cabal @@ -60,3 +60,15 @@ library , OverloadedStrings , TupleSections , RecordWildCards + +executable pretty-test + main-is: Main.hs + hs-source-dirs: pretty-test + ghc-options: -Wall -Wunused-packages -Wincomplete-uni-patterns -Wincomplete-record-updates + build-depends: + base >=4.7 && <5 + , containers + , inferno-types + , prettyprinter + , text + default-language: Haskell2010 diff --git a/inferno-types/pretty-test/Main.hs b/inferno-types/pretty-test/Main.hs new file mode 100644 index 0000000..1cae9d9 --- /dev/null +++ b/inferno-types/pretty-test/Main.hs @@ -0,0 +1,18 @@ +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE ScopedTypeVariables #-} + +module Main where + +import Data.List.NonEmpty (NonEmpty ((:|))) +import qualified Data.Map as M +import Data.Set (fromList) +import Inferno.Types.Syntax +import Inferno.Utils.Prettyprinter (showPretty) + +main :: IO () +main = do + let ast :: Expr () () = + Let () () (Impl (ExtIdent (Right "resolution"))) () (App (Var () () LocalScope (Expl (ExtIdent (Right "toResolution")))) (Lit () (LInt 64))) () (LetAnnot () () (ExtIdent (Right "latestBeforeWithArray")) () (ForallTC [TV {unTV = 0}] (fromList []) (ImplType (M.fromList []) (TArr (TArray (TTuple (TCons (TVar (TV {unTV = 0})) (TBase TTime) []))) (TArr (TBase TTime) (TOptional (TVar (TV {unTV = 0}))))))) () (Lam () (((), Just (ExtIdent (Right "arr"))) :| [((), Just (ExtIdent (Right "t")))]) () (Let () () (Expl (ExtIdent (Right "compareTimes"))) () (Lam () (((), Just (ExtIdent (Right "targetTime"))) :| [((), Just (ExtIdent (Right "testValAndTime"))), ((), Just (ExtIdent (Right "lastValAndTime")))]) () (If () (Op (Var () () LocalScope (Expl (ExtIdent (Right "targetTime")))) () () (7, NoFix) LocalScope (Ident {unIdent = "<"}) (Bracketed () (App (Var () () LocalScope (Expl (ExtIdent (Right "snd")))) (Var () () LocalScope (Expl (ExtIdent (Right "testValAndTime"))))) ())) () (Var () () LocalScope (Expl (ExtIdent (Right "lastValAndTime")))) () (Var () () LocalScope (Expl (ExtIdent (Right "testValAndTime")))))) () (Let () () (Expl (ExtIdent (Right "subValues"))) () (Lam () (((), Just (ExtIdent (Right "lastValAndTime"))) :| [((), Just (ExtIdent (Right "testValAndTime")))]) () (Case () (Var () () LocalScope (Expl (ExtIdent (Right "lastValAndTime")))) () (((), PEmpty (), (), If () (Op (Var () () LocalScope (Expl (ExtIdent (Right "t")))) () () (7, NoFix) LocalScope (Ident {unIdent = "<"}) (Bracketed () (App (Var () () LocalScope (Expl (ExtIdent (Right "snd")))) (Var () () LocalScope (Expl (ExtIdent (Right "testValAndTime"))))) ())) () (Empty ()) () (Bracketed () (One () (Var () () LocalScope (Expl (ExtIdent (Right "testValAndTime"))))) ())) :| [((), POne () (PVar () (Just (Ident {unIdent = "ltv"}))), (), One () (Bracketed () (App (App (App (Var () () LocalScope (Expl (ExtIdent (Right "compareTimes")))) (Var () () LocalScope (Expl (ExtIdent (Right "t"))))) (Var () () LocalScope (Expl (ExtIdent (Right "testValAndTime"))))) (Var () () LocalScope (Expl (ExtIdent (Right "ltv"))))) ()))]) ())) () (Bracketed () (App (App (Var () () (Scope (ModuleName {unModuleName = "Option"})) (Expl (ExtIdent (Right "map")))) (Var () () LocalScope (Expl (ExtIdent (Right "fst"))))) (Bracketed () (App (App (App (Var () () (Scope (ModuleName {unModuleName = "Array"})) (Expl (ExtIdent (Right "reduce")))) (Var () () LocalScope (Expl (ExtIdent (Right "subValues"))))) (Empty ())) (Var () () LocalScope (Expl (ExtIdent (Right "arr"))))) ())) ())))) () (Let () () (Expl (ExtIdent (Right "intervalStep"))) () (Bracketed () (App (Var () () LocalScope (Expl (ExtIdent (Right "resolutionToInt")))) (Var () () LocalScope (Impl (ExtIdent (Right "resolution"))))) ()) () (Let () () (Expl (ExtIdent (Right "startOfInterval"))) () (Bracketed () (Op (Var () () LocalScope (Impl (ExtIdent (Right "now")))) () () (9, LeftFix) LocalScope (Ident {unIdent = "-"}) (Bracketed () (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "hours")))) (Lit () (LInt 24))) ())) ()) () (LetAnnot () () (ExtIdent (Right "valueBeforeInterval")) () (ForallTC [] (fromList []) (ImplType (M.fromList []) (TBase TDouble))) () (App (App (App (Var () () (Scope (ModuleName {unModuleName = "Option"})) (Expl (ExtIdent (Right "reduce")))) (Var () () LocalScope (Expl (ExtIdent (Right "id"))))) (Lit () (LDouble 0.0))) (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "latestValueBefore")))) (Var () () LocalScope (Expl (ExtIdent (Right "startOfInterval"))))) (Var () () LocalScope (Expl (ExtIdent (Right "power"))))) ())) () (LetAnnot () () (ExtIdent (Right "bitfieldBeforeInterval")) () (ForallTC [] (fromList []) (ImplType (M.fromList []) (TBase TDouble))) () (App (App (App (Var () () (Scope (ModuleName {unModuleName = "Option"})) (Expl (ExtIdent (Right "reduce")))) (Var () () LocalScope (Expl (ExtIdent (Right "id"))))) (Lit () (LDouble 0.0))) (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "latestValueBefore")))) (Var () () LocalScope (Expl (ExtIdent (Right "startOfInterval"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bitParam"))))) ())) () (LetAnnot () () (ExtIdent (Right "allValuesDuringInterval")) () (ForallTC [] (fromList []) (ImplType (M.fromList []) (TArray (TTuple (TCons (TOptional (TBase TDouble)) (TBase TTime) []))))) () (ArrayComp () (Tuple () (TCons (App (App (Var () () LocalScope (Expl (ExtIdent (Right "valueAtOrAdjacent")))) (Var () () LocalScope (Expl (ExtIdent (Right "power"))))) (Var () () LocalScope (Expl (ExtIdent (Right "t")))), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "t"))), Nothing) []) ()) () (((), Ident {unIdent = "t"}, (), App (App (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "intervalEvery")))) (Bracketed () (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "seconds")))) (Var () () LocalScope (Expl (ExtIdent (Right "intervalStep"))))) ())) (Var () () LocalScope (Expl (ExtIdent (Right "startOfInterval"))))) (Var () () LocalScope (Impl (ExtIdent (Right "now")))), Nothing) :| []) Nothing ()) () (LetAnnot () () (ExtIdent (Right "bitfieldArray")) () (ForallTC [] (fromList []) (ImplType (M.fromList []) (TArray (TTuple (TCons (TBase TDouble) (TBase TTime) []))))) () (Let () () (Impl (ExtIdent (Right "resolution"))) () (App (Var () () LocalScope (Expl (ExtIdent (Right "toResolution")))) (Lit () (LInt 1))) () (App (Var () () (Scope (ModuleName {unModuleName = "Array"})) (Expl (ExtIdent (Right "keepSomes")))) (ArrayComp () (App (App (Var () () (Scope (ModuleName {unModuleName = "Option"})) (Expl (ExtIdent (Right "map")))) (Bracketed () (Lam () (((), Just (ExtIdent (Right "v"))) :| []) () (Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "v"))), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "t"))), Nothing) []) ())) ())) (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "valueAt")))) (Var () () LocalScope (Expl (ExtIdent (Right "bitParam"))))) (Var () () LocalScope (Expl (ExtIdent (Right "t"))))) ())) () (((), Ident {unIdent = "t"}, (), App (App (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "intervalEvery")))) (Bracketed () (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "seconds")))) (Lit () (LInt 1))) ())) (Bracketed () (Op (Var () () LocalScope (Impl (ExtIdent (Right "now")))) () () (9, LeftFix) LocalScope (Ident {unIdent = "-"}) (Bracketed () (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "hours")))) (Lit () (LInt 24))) ())) ())) (Var () () LocalScope (Impl (ExtIdent (Right "now")))), Nothing) :| []) Nothing ()))) () (Let () () (Expl (ExtIdent (Right "inPrimaryDischarge"))) () (Lam () (((), Just (ExtIdent (Right "word"))) :| []) () (If () (Bracketed () (Op (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "testBit")))) (Var () () LocalScope (Expl (ExtIdent (Right "word"))))) (Lit () (LInt 4))) ()) () () (3, RightFix) LocalScope (Ident {unIdent = "||"}) (Op (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "testBit")))) (Var () () LocalScope (Expl (ExtIdent (Right "word"))))) (Lit () (LInt 5))) ()) () () (3, RightFix) LocalScope (Ident {unIdent = "||"}) (Op (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "testBit")))) (Var () () LocalScope (Expl (ExtIdent (Right "word"))))) (Lit () (LInt 6))) ()) () () (3, RightFix) LocalScope (Ident {unIdent = "||"}) (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "testBit")))) (Var () () LocalScope (Expl (ExtIdent (Right "word"))))) (Lit () (LInt 7))) ())))) ()) () (Enum () () LocalScope (Ident {unIdent = "false"})) () (Enum () () LocalScope (Ident {unIdent = "true"})))) () (Let () () (Expl (ExtIdent (Right "isCharging"))) () (Lam () (((), Just (ExtIdent (Right "c"))) :| []) () (Op (Var () () LocalScope (Expl (ExtIdent (Right "c")))) () () (7, NoFix) LocalScope (Ident {unIdent = ">"}) (Lit () (LDouble 1.0)))) () (LetAnnot () () (ExtIdent (Right "chargeMappedValuesDuringInterval")) () (ForallTC [] (fromList []) (ImplType (M.fromList []) (TArray (TTuple (TCons (TBase TDouble) (TBase TTime) []))))) () (Let () () (Expl (ExtIdent (Right "replaceNoneWithLastKnown"))) () (Lam () (((), Just (ExtIdent (Right "ASuperLongVariableName"))) :| [((), Just (ExtIdent (Right "ASuperLongVariableName"))), ((), Just (ExtIdent (Right "ASuperLongVariableName"))), ((), Just (ExtIdent (Right "ASuperLongVariableName")))]) () (Case () (Var () () LocalScope (Expl (ExtIdent (Right "optVal")))) () (((), PTuple () (TCons (POne () (PVar () (Just (Ident {unIdent = "v"}))), Just ()) (PVar () (Just (Ident {unIdent = "t"})), Nothing) []) (), (), Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "v"))), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "t"))), Nothing) []) ()) :| [((), PTuple () (TCons (PEmpty (), Just ()) (PVar () (Just (Ident {unIdent = "t"})), Nothing) []) (), (), Let () () (Expl (ExtIdent (Right "val"))) () (Case () (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "latestBeforeWithArray")))) (Var () () LocalScope (Expl (ExtIdent (Right "allValuesDuringInterval"))))) (Var () () LocalScope (Expl (ExtIdent (Right "t"))))) ()) () (((), POne () (POne () (PVar () (Just (Ident {unIdent = "v"})))), (), Var () () LocalScope (Expl (ExtIdent (Right "v")))) :| [((), PVar () Nothing, (), Var () () LocalScope (Expl (ExtIdent (Right "valueBeforeInterval"))))]) ()) () (Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "val"))), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "t"))), Nothing) []) ()))]) ())) () (App (App (Var () () (Scope (ModuleName {unModuleName = "Array"})) (Expl (ExtIdent (Right "map")))) (Var () () LocalScope (Expl (ExtIdent (Right "replaceNoneWithLastKnown"))))) (Var () () LocalScope (Expl (ExtIdent (Right "allValuesDuringInterval")))))) () (Let () () (Expl (ExtIdent (Right "test"))) () (Lam () (((), Just (ExtIdent (Right "valueAndTime"))) :| []) () (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "latestBeforeWithArray")))) (Var () () LocalScope (Expl (ExtIdent (Right "bitfieldArray"))))) (Bracketed () (App (Var () () LocalScope (Expl (ExtIdent (Right "snd")))) (Var () () LocalScope (Expl (ExtIdent (Right "valueAndTime"))))) ())) ())) () (LetAnnot () () (ExtIdent (Right "bigTypeAnnot")) () (ForallTC [TV {unTV = 0}] (fromList [TypeClass {className = "addition", params = [TVar (TV {unTV = 0}), TVar (TV {unTV = 0}), TVar (TV {unTV = 0})]}, TypeClass {className = "numeric", params = [TVar (TV {unTV = 0})]}]) (ImplType (M.fromList [(ExtIdent (Right "now"), TBase TTime)]) (TArr (TArray (TTuple (TCons (TVar (TV {unTV = 0})) (TBase TTime) []))) (TArr (TBase TTime) (TOptional (TVar (TV {unTV = 0}))))))) () (Var () () LocalScope (Expl (ExtIdent (Right "bigThing")))) () (Let () () (Expl (ExtIdent (Right "bigThing"))) () (Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "ASuperLongVariableName"))), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "ASuperLongVariableNamet"))), Nothing) [(One () (App (Var () () LocalScope (Expl (ExtIdent (Right "snd")))) (App (Var () () LocalScope (Expl (ExtIdent (Right "snd")))) (Var () () LocalScope (Expl (ExtIdent (Right "ASuperLongVariableNametASuperLongVariableNametASuperLongVariableNametASuperLongVariableNametASuperLongVariableNametASuperLongVariableNamet")))))), Nothing), (Var () () LocalScope (Expl (ExtIdent (Right "ASuperLongVariableNamet"))), Nothing)]) ()) () (Lit () (LDouble 2.0))))))))))))))) + showPretty ast \ No newline at end of file From 48e13712a1d5c521d579c2787ea8e2e836515d36 Mon Sep 17 00:00:00 2001 From: Siddharth Krishna Date: Mon, 25 Mar 2024 11:16:01 +0200 Subject: [PATCH 04/16] Some more prettification --- inferno-types/pretty-test/Main.hs | 3 +- inferno-types/src/Inferno/Types/Syntax.hs | 66 +++++++++++++---------- 2 files changed, 39 insertions(+), 30 deletions(-) diff --git a/inferno-types/pretty-test/Main.hs b/inferno-types/pretty-test/Main.hs index 1cae9d9..e62784a 100644 --- a/inferno-types/pretty-test/Main.hs +++ b/inferno-types/pretty-test/Main.hs @@ -14,5 +14,6 @@ import Inferno.Utils.Prettyprinter (showPretty) main :: IO () main = do let ast :: Expr () () = - Let () () (Impl (ExtIdent (Right "resolution"))) () (App (Var () () LocalScope (Expl (ExtIdent (Right "toResolution")))) (Lit () (LInt 64))) () (LetAnnot () () (ExtIdent (Right "latestBeforeWithArray")) () (ForallTC [TV {unTV = 0}] (fromList []) (ImplType (M.fromList []) (TArr (TArray (TTuple (TCons (TVar (TV {unTV = 0})) (TBase TTime) []))) (TArr (TBase TTime) (TOptional (TVar (TV {unTV = 0}))))))) () (Lam () (((), Just (ExtIdent (Right "arr"))) :| [((), Just (ExtIdent (Right "t")))]) () (Let () () (Expl (ExtIdent (Right "compareTimes"))) () (Lam () (((), Just (ExtIdent (Right "targetTime"))) :| [((), Just (ExtIdent (Right "testValAndTime"))), ((), Just (ExtIdent (Right "lastValAndTime")))]) () (If () (Op (Var () () LocalScope (Expl (ExtIdent (Right "targetTime")))) () () (7, NoFix) LocalScope (Ident {unIdent = "<"}) (Bracketed () (App (Var () () LocalScope (Expl (ExtIdent (Right "snd")))) (Var () () LocalScope (Expl (ExtIdent (Right "testValAndTime"))))) ())) () (Var () () LocalScope (Expl (ExtIdent (Right "lastValAndTime")))) () (Var () () LocalScope (Expl (ExtIdent (Right "testValAndTime")))))) () (Let () () (Expl (ExtIdent (Right "subValues"))) () (Lam () (((), Just (ExtIdent (Right "lastValAndTime"))) :| [((), Just (ExtIdent (Right "testValAndTime")))]) () (Case () (Var () () LocalScope (Expl (ExtIdent (Right "lastValAndTime")))) () (((), PEmpty (), (), If () (Op (Var () () LocalScope (Expl (ExtIdent (Right "t")))) () () (7, NoFix) LocalScope (Ident {unIdent = "<"}) (Bracketed () (App (Var () () LocalScope (Expl (ExtIdent (Right "snd")))) (Var () () LocalScope (Expl (ExtIdent (Right "testValAndTime"))))) ())) () (Empty ()) () (Bracketed () (One () (Var () () LocalScope (Expl (ExtIdent (Right "testValAndTime"))))) ())) :| [((), POne () (PVar () (Just (Ident {unIdent = "ltv"}))), (), One () (Bracketed () (App (App (App (Var () () LocalScope (Expl (ExtIdent (Right "compareTimes")))) (Var () () LocalScope (Expl (ExtIdent (Right "t"))))) (Var () () LocalScope (Expl (ExtIdent (Right "testValAndTime"))))) (Var () () LocalScope (Expl (ExtIdent (Right "ltv"))))) ()))]) ())) () (Bracketed () (App (App (Var () () (Scope (ModuleName {unModuleName = "Option"})) (Expl (ExtIdent (Right "map")))) (Var () () LocalScope (Expl (ExtIdent (Right "fst"))))) (Bracketed () (App (App (App (Var () () (Scope (ModuleName {unModuleName = "Array"})) (Expl (ExtIdent (Right "reduce")))) (Var () () LocalScope (Expl (ExtIdent (Right "subValues"))))) (Empty ())) (Var () () LocalScope (Expl (ExtIdent (Right "arr"))))) ())) ())))) () (Let () () (Expl (ExtIdent (Right "intervalStep"))) () (Bracketed () (App (Var () () LocalScope (Expl (ExtIdent (Right "resolutionToInt")))) (Var () () LocalScope (Impl (ExtIdent (Right "resolution"))))) ()) () (Let () () (Expl (ExtIdent (Right "startOfInterval"))) () (Bracketed () (Op (Var () () LocalScope (Impl (ExtIdent (Right "now")))) () () (9, LeftFix) LocalScope (Ident {unIdent = "-"}) (Bracketed () (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "hours")))) (Lit () (LInt 24))) ())) ()) () (LetAnnot () () (ExtIdent (Right "valueBeforeInterval")) () (ForallTC [] (fromList []) (ImplType (M.fromList []) (TBase TDouble))) () (App (App (App (Var () () (Scope (ModuleName {unModuleName = "Option"})) (Expl (ExtIdent (Right "reduce")))) (Var () () LocalScope (Expl (ExtIdent (Right "id"))))) (Lit () (LDouble 0.0))) (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "latestValueBefore")))) (Var () () LocalScope (Expl (ExtIdent (Right "startOfInterval"))))) (Var () () LocalScope (Expl (ExtIdent (Right "power"))))) ())) () (LetAnnot () () (ExtIdent (Right "bitfieldBeforeInterval")) () (ForallTC [] (fromList []) (ImplType (M.fromList []) (TBase TDouble))) () (App (App (App (Var () () (Scope (ModuleName {unModuleName = "Option"})) (Expl (ExtIdent (Right "reduce")))) (Var () () LocalScope (Expl (ExtIdent (Right "id"))))) (Lit () (LDouble 0.0))) (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "latestValueBefore")))) (Var () () LocalScope (Expl (ExtIdent (Right "startOfInterval"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bitParam"))))) ())) () (LetAnnot () () (ExtIdent (Right "allValuesDuringInterval")) () (ForallTC [] (fromList []) (ImplType (M.fromList []) (TArray (TTuple (TCons (TOptional (TBase TDouble)) (TBase TTime) []))))) () (ArrayComp () (Tuple () (TCons (App (App (Var () () LocalScope (Expl (ExtIdent (Right "valueAtOrAdjacent")))) (Var () () LocalScope (Expl (ExtIdent (Right "power"))))) (Var () () LocalScope (Expl (ExtIdent (Right "t")))), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "t"))), Nothing) []) ()) () (((), Ident {unIdent = "t"}, (), App (App (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "intervalEvery")))) (Bracketed () (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "seconds")))) (Var () () LocalScope (Expl (ExtIdent (Right "intervalStep"))))) ())) (Var () () LocalScope (Expl (ExtIdent (Right "startOfInterval"))))) (Var () () LocalScope (Impl (ExtIdent (Right "now")))), Nothing) :| []) Nothing ()) () (LetAnnot () () (ExtIdent (Right "bitfieldArray")) () (ForallTC [] (fromList []) (ImplType (M.fromList []) (TArray (TTuple (TCons (TBase TDouble) (TBase TTime) []))))) () (Let () () (Impl (ExtIdent (Right "resolution"))) () (App (Var () () LocalScope (Expl (ExtIdent (Right "toResolution")))) (Lit () (LInt 1))) () (App (Var () () (Scope (ModuleName {unModuleName = "Array"})) (Expl (ExtIdent (Right "keepSomes")))) (ArrayComp () (App (App (Var () () (Scope (ModuleName {unModuleName = "Option"})) (Expl (ExtIdent (Right "map")))) (Bracketed () (Lam () (((), Just (ExtIdent (Right "v"))) :| []) () (Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "v"))), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "t"))), Nothing) []) ())) ())) (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "valueAt")))) (Var () () LocalScope (Expl (ExtIdent (Right "bitParam"))))) (Var () () LocalScope (Expl (ExtIdent (Right "t"))))) ())) () (((), Ident {unIdent = "t"}, (), App (App (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "intervalEvery")))) (Bracketed () (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "seconds")))) (Lit () (LInt 1))) ())) (Bracketed () (Op (Var () () LocalScope (Impl (ExtIdent (Right "now")))) () () (9, LeftFix) LocalScope (Ident {unIdent = "-"}) (Bracketed () (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "hours")))) (Lit () (LInt 24))) ())) ())) (Var () () LocalScope (Impl (ExtIdent (Right "now")))), Nothing) :| []) Nothing ()))) () (Let () () (Expl (ExtIdent (Right "inPrimaryDischarge"))) () (Lam () (((), Just (ExtIdent (Right "word"))) :| []) () (If () (Bracketed () (Op (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "testBit")))) (Var () () LocalScope (Expl (ExtIdent (Right "word"))))) (Lit () (LInt 4))) ()) () () (3, RightFix) LocalScope (Ident {unIdent = "||"}) (Op (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "testBit")))) (Var () () LocalScope (Expl (ExtIdent (Right "word"))))) (Lit () (LInt 5))) ()) () () (3, RightFix) LocalScope (Ident {unIdent = "||"}) (Op (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "testBit")))) (Var () () LocalScope (Expl (ExtIdent (Right "word"))))) (Lit () (LInt 6))) ()) () () (3, RightFix) LocalScope (Ident {unIdent = "||"}) (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "testBit")))) (Var () () LocalScope (Expl (ExtIdent (Right "word"))))) (Lit () (LInt 7))) ())))) ()) () (Enum () () LocalScope (Ident {unIdent = "false"})) () (Enum () () LocalScope (Ident {unIdent = "true"})))) () (Let () () (Expl (ExtIdent (Right "isCharging"))) () (Lam () (((), Just (ExtIdent (Right "c"))) :| []) () (Op (Var () () LocalScope (Expl (ExtIdent (Right "c")))) () () (7, NoFix) LocalScope (Ident {unIdent = ">"}) (Lit () (LDouble 1.0)))) () (LetAnnot () () (ExtIdent (Right "chargeMappedValuesDuringInterval")) () (ForallTC [] (fromList []) (ImplType (M.fromList []) (TArray (TTuple (TCons (TBase TDouble) (TBase TTime) []))))) () (Let () () (Expl (ExtIdent (Right "replaceNoneWithLastKnown"))) () (Lam () (((), Just (ExtIdent (Right "ASuperLongVariableName"))) :| [((), Just (ExtIdent (Right "ASuperLongVariableName"))), ((), Just (ExtIdent (Right "ASuperLongVariableName"))), ((), Just (ExtIdent (Right "ASuperLongVariableName")))]) () (Case () (Var () () LocalScope (Expl (ExtIdent (Right "optVal")))) () (((), PTuple () (TCons (POne () (PVar () (Just (Ident {unIdent = "v"}))), Just ()) (PVar () (Just (Ident {unIdent = "t"})), Nothing) []) (), (), Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "v"))), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "t"))), Nothing) []) ()) :| [((), PTuple () (TCons (PEmpty (), Just ()) (PVar () (Just (Ident {unIdent = "t"})), Nothing) []) (), (), Let () () (Expl (ExtIdent (Right "val"))) () (Case () (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "latestBeforeWithArray")))) (Var () () LocalScope (Expl (ExtIdent (Right "allValuesDuringInterval"))))) (Var () () LocalScope (Expl (ExtIdent (Right "t"))))) ()) () (((), POne () (POne () (PVar () (Just (Ident {unIdent = "v"})))), (), Var () () LocalScope (Expl (ExtIdent (Right "v")))) :| [((), PVar () Nothing, (), Var () () LocalScope (Expl (ExtIdent (Right "valueBeforeInterval"))))]) ()) () (Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "val"))), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "t"))), Nothing) []) ()))]) ())) () (App (App (Var () () (Scope (ModuleName {unModuleName = "Array"})) (Expl (ExtIdent (Right "map")))) (Var () () LocalScope (Expl (ExtIdent (Right "replaceNoneWithLastKnown"))))) (Var () () LocalScope (Expl (ExtIdent (Right "allValuesDuringInterval")))))) () (Let () () (Expl (ExtIdent (Right "test"))) () (Lam () (((), Just (ExtIdent (Right "valueAndTime"))) :| []) () (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "latestBeforeWithArray")))) (Var () () LocalScope (Expl (ExtIdent (Right "bitfieldArray"))))) (Bracketed () (App (Var () () LocalScope (Expl (ExtIdent (Right "snd")))) (Var () () LocalScope (Expl (ExtIdent (Right "valueAndTime"))))) ())) ())) () (LetAnnot () () (ExtIdent (Right "bigTypeAnnot")) () (ForallTC [TV {unTV = 0}] (fromList [TypeClass {className = "addition", params = [TVar (TV {unTV = 0}), TVar (TV {unTV = 0}), TVar (TV {unTV = 0})]}, TypeClass {className = "numeric", params = [TVar (TV {unTV = 0})]}]) (ImplType (M.fromList [(ExtIdent (Right "now"), TBase TTime)]) (TArr (TArray (TTuple (TCons (TVar (TV {unTV = 0})) (TBase TTime) []))) (TArr (TBase TTime) (TOptional (TVar (TV {unTV = 0}))))))) () (Var () () LocalScope (Expl (ExtIdent (Right "bigThing")))) () (Let () () (Expl (ExtIdent (Right "bigThing"))) () (Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "ASuperLongVariableName"))), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "ASuperLongVariableNamet"))), Nothing) [(One () (App (Var () () LocalScope (Expl (ExtIdent (Right "snd")))) (App (Var () () LocalScope (Expl (ExtIdent (Right "snd")))) (Var () () LocalScope (Expl (ExtIdent (Right "ASuperLongVariableNametASuperLongVariableNametASuperLongVariableNametASuperLongVariableNametASuperLongVariableNametASuperLongVariableNamet")))))), Nothing), (Var () () LocalScope (Expl (ExtIdent (Right "ASuperLongVariableNamet"))), Nothing)]) ()) () (Lit () (LDouble 2.0))))))))))))))) + Let () () (Expl (ExtIdent (Right "bigApp"))) () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig")))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) () (Let () () (Expl (ExtIdent (Right "null"))) () (Tuple () TNil ()) () (Let () () (Expl (ExtIdent (Right "smallTup"))) () (Tuple () (TCons (Lit () (LInt 12314314),Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "fadsfdfsadfa"))),Just ()) [(Lit () (LInt 13413241345),Nothing)]) ()) () (Let () () (Expl (ExtIdent (Right "mediumTup"))) () (Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()) [(Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "medi"))),Nothing)]) ()) () (Let () () (Expl (ExtIdent (Right "bigTup"))) () (Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))),Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))),Just ()) [(Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))),Just ()),(One () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig")))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))),Nothing)]) ()) () (Assert () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "thing"))))) (Var () () LocalScope (Expl (ExtIdent (Right "small"))))) () (Assert () (App (App (App (App (App (App (App (App (App (App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "thing"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) () (Assert () (App (App (App (App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "thing"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) () (Let () () (Expl (ExtIdent (Right "x"))) () (Case () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "thing"))))) (Var () () LocalScope (Expl (ExtIdent (Right "small"))))) () (((),PLit () (LInt 1),(),Lit () (LInt 2)) :| [((),PVar () Nothing,(),Lit () (LInt 3))]) ()) () (Let () () (Expl (ExtIdent (Right "x"))) () (Case () (App (App (App (App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "thing"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) () (((),PTuple () (TCons (PVar () (Just (Ident {unIdent = "biggbig"})),Just ()) (PVar () (Just (Ident {unIdent = "bigbigbig"})),Just ()) [(PVar () (Just (Ident {unIdent = "bigbigbigbig"})),Just ()),(PVar () (Just (Ident {unIdent = "bigbigbigbigbig"})),Just ()),(PVar () (Just (Ident {unIdent = "bigbigbigbigbigbigbig"})),Just ()),(PVar () (Just (Ident {unIdent = "bigbigbigbigbigbigbigbigbig"})),Nothing)]) (),(),Lit () (LInt 2)) :| [((),PVar () Nothing,(),Lit () (LInt 3))]) ()) () (Lit () (LDouble 1.1))))))))))) + -- Let () () (Impl (ExtIdent (Right "resolution"))) () (App (Var () () LocalScope (Expl (ExtIdent (Right "toResolution")))) (Lit () (LInt 64))) () (LetAnnot () () (ExtIdent (Right "latestBeforeWithArray")) () (ForallTC [TV {unTV = 0}] (fromList []) (ImplType (M.fromList []) (TArr (TArray (TTuple (TCons (TVar (TV {unTV = 0})) (TBase TTime) []))) (TArr (TBase TTime) (TOptional (TVar (TV {unTV = 0}))))))) () (Lam () (((), Just (ExtIdent (Right "arr"))) :| [((), Just (ExtIdent (Right "t")))]) () (Let () () (Expl (ExtIdent (Right "compareTimes"))) () (Lam () (((), Just (ExtIdent (Right "targetTime"))) :| [((), Just (ExtIdent (Right "testValAndTime"))), ((), Just (ExtIdent (Right "lastValAndTime")))]) () (If () (Op (Var () () LocalScope (Expl (ExtIdent (Right "targetTime")))) () () (7, NoFix) LocalScope (Ident {unIdent = "<"}) (Bracketed () (App (Var () () LocalScope (Expl (ExtIdent (Right "snd")))) (Var () () LocalScope (Expl (ExtIdent (Right "testValAndTime"))))) ())) () (Var () () LocalScope (Expl (ExtIdent (Right "lastValAndTime")))) () (Var () () LocalScope (Expl (ExtIdent (Right "testValAndTime")))))) () (Let () () (Expl (ExtIdent (Right "subValues"))) () (Lam () (((), Just (ExtIdent (Right "lastValAndTime"))) :| [((), Just (ExtIdent (Right "testValAndTime")))]) () (Case () (Var () () LocalScope (Expl (ExtIdent (Right "lastValAndTime")))) () (((), PEmpty (), (), If () (Op (Var () () LocalScope (Expl (ExtIdent (Right "t")))) () () (7, NoFix) LocalScope (Ident {unIdent = "<"}) (Bracketed () (App (Var () () LocalScope (Expl (ExtIdent (Right "snd")))) (Var () () LocalScope (Expl (ExtIdent (Right "testValAndTime"))))) ())) () (Empty ()) () (Bracketed () (One () (Var () () LocalScope (Expl (ExtIdent (Right "testValAndTime"))))) ())) :| [((), POne () (PVar () (Just (Ident {unIdent = "ltv"}))), (), One () (Bracketed () (App (App (App (Var () () LocalScope (Expl (ExtIdent (Right "compareTimes")))) (Var () () LocalScope (Expl (ExtIdent (Right "t"))))) (Var () () LocalScope (Expl (ExtIdent (Right "testValAndTime"))))) (Var () () LocalScope (Expl (ExtIdent (Right "ltv"))))) ()))]) ())) () (Bracketed () (App (App (Var () () (Scope (ModuleName {unModuleName = "Option"})) (Expl (ExtIdent (Right "map")))) (Var () () LocalScope (Expl (ExtIdent (Right "fst"))))) (Bracketed () (App (App (App (Var () () (Scope (ModuleName {unModuleName = "Array"})) (Expl (ExtIdent (Right "reduce")))) (Var () () LocalScope (Expl (ExtIdent (Right "subValues"))))) (Empty ())) (Var () () LocalScope (Expl (ExtIdent (Right "arr"))))) ())) ())))) () (Let () () (Expl (ExtIdent (Right "intervalStep"))) () (Bracketed () (App (Var () () LocalScope (Expl (ExtIdent (Right "resolutionToInt")))) (Var () () LocalScope (Impl (ExtIdent (Right "resolution"))))) ()) () (Let () () (Expl (ExtIdent (Right "startOfInterval"))) () (Bracketed () (Op (Var () () LocalScope (Impl (ExtIdent (Right "now")))) () () (9, LeftFix) LocalScope (Ident {unIdent = "-"}) (Bracketed () (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "hours")))) (Lit () (LInt 24))) ())) ()) () (LetAnnot () () (ExtIdent (Right "valueBeforeInterval")) () (ForallTC [] (fromList []) (ImplType (M.fromList []) (TBase TDouble))) () (App (App (App (Var () () (Scope (ModuleName {unModuleName = "Option"})) (Expl (ExtIdent (Right "reduce")))) (Var () () LocalScope (Expl (ExtIdent (Right "id"))))) (Lit () (LDouble 0.0))) (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "latestValueBefore")))) (Var () () LocalScope (Expl (ExtIdent (Right "startOfInterval"))))) (Var () () LocalScope (Expl (ExtIdent (Right "power"))))) ())) () (LetAnnot () () (ExtIdent (Right "bitfieldBeforeInterval")) () (ForallTC [] (fromList []) (ImplType (M.fromList []) (TBase TDouble))) () (App (App (App (Var () () (Scope (ModuleName {unModuleName = "Option"})) (Expl (ExtIdent (Right "reduce")))) (Var () () LocalScope (Expl (ExtIdent (Right "id"))))) (Lit () (LDouble 0.0))) (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "latestValueBefore")))) (Var () () LocalScope (Expl (ExtIdent (Right "startOfInterval"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bitParam"))))) ())) () (LetAnnot () () (ExtIdent (Right "allValuesDuringInterval")) () (ForallTC [] (fromList []) (ImplType (M.fromList []) (TArray (TTuple (TCons (TOptional (TBase TDouble)) (TBase TTime) []))))) () (ArrayComp () (Tuple () (TCons (App (App (Var () () LocalScope (Expl (ExtIdent (Right "valueAtOrAdjacent")))) (Var () () LocalScope (Expl (ExtIdent (Right "power"))))) (Var () () LocalScope (Expl (ExtIdent (Right "t")))), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "t"))), Nothing) []) ()) () (((), Ident {unIdent = "t"}, (), App (App (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "intervalEvery")))) (Bracketed () (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "seconds")))) (Var () () LocalScope (Expl (ExtIdent (Right "intervalStep"))))) ())) (Var () () LocalScope (Expl (ExtIdent (Right "startOfInterval"))))) (Var () () LocalScope (Impl (ExtIdent (Right "now")))), Nothing) :| []) Nothing ()) () (LetAnnot () () (ExtIdent (Right "bitfieldArray")) () (ForallTC [] (fromList []) (ImplType (M.fromList []) (TArray (TTuple (TCons (TBase TDouble) (TBase TTime) []))))) () (Let () () (Impl (ExtIdent (Right "resolution"))) () (App (Var () () LocalScope (Expl (ExtIdent (Right "toResolution")))) (Lit () (LInt 1))) () (App (Var () () (Scope (ModuleName {unModuleName = "Array"})) (Expl (ExtIdent (Right "keepSomes")))) (ArrayComp () (App (App (Var () () (Scope (ModuleName {unModuleName = "Option"})) (Expl (ExtIdent (Right "map")))) (Bracketed () (Lam () (((), Just (ExtIdent (Right "v"))) :| []) () (Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "v"))), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "t"))), Nothing) []) ())) ())) (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "valueAt")))) (Var () () LocalScope (Expl (ExtIdent (Right "bitParam"))))) (Var () () LocalScope (Expl (ExtIdent (Right "t"))))) ())) () (((), Ident {unIdent = "t"}, (), App (App (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "intervalEvery")))) (Bracketed () (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "seconds")))) (Lit () (LInt 1))) ())) (Bracketed () (Op (Var () () LocalScope (Impl (ExtIdent (Right "now")))) () () (9, LeftFix) LocalScope (Ident {unIdent = "-"}) (Bracketed () (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "hours")))) (Lit () (LInt 24))) ())) ())) (Var () () LocalScope (Impl (ExtIdent (Right "now")))), Nothing) :| []) Nothing ()))) () (Let () () (Expl (ExtIdent (Right "inPrimaryDischarge"))) () (Lam () (((), Just (ExtIdent (Right "word"))) :| []) () (If () (Bracketed () (Op (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "testBit")))) (Var () () LocalScope (Expl (ExtIdent (Right "word"))))) (Lit () (LInt 4))) ()) () () (3, RightFix) LocalScope (Ident {unIdent = "||"}) (Op (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "testBit")))) (Var () () LocalScope (Expl (ExtIdent (Right "word"))))) (Lit () (LInt 5))) ()) () () (3, RightFix) LocalScope (Ident {unIdent = "||"}) (Op (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "testBit")))) (Var () () LocalScope (Expl (ExtIdent (Right "word"))))) (Lit () (LInt 6))) ()) () () (3, RightFix) LocalScope (Ident {unIdent = "||"}) (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "testBit")))) (Var () () LocalScope (Expl (ExtIdent (Right "word"))))) (Lit () (LInt 7))) ())))) ()) () (Enum () () LocalScope (Ident {unIdent = "false"})) () (Enum () () LocalScope (Ident {unIdent = "true"})))) () (Let () () (Expl (ExtIdent (Right "isCharging"))) () (Lam () (((), Just (ExtIdent (Right "c"))) :| []) () (Op (Var () () LocalScope (Expl (ExtIdent (Right "c")))) () () (7, NoFix) LocalScope (Ident {unIdent = ">"}) (Lit () (LDouble 1.0)))) () (LetAnnot () () (ExtIdent (Right "chargeMappedValuesDuringInterval")) () (ForallTC [] (fromList []) (ImplType (M.fromList []) (TArray (TTuple (TCons (TBase TDouble) (TBase TTime) []))))) () (Let () () (Expl (ExtIdent (Right "replaceNoneWithLastKnown"))) () (Lam () (((), Just (ExtIdent (Right "ASuperLongVariableName"))) :| [((), Just (ExtIdent (Right "ASuperLongVariableName"))), ((), Just (ExtIdent (Right "ASuperLongVariableName"))), ((), Just (ExtIdent (Right "ASuperLongVariableName")))]) () (Case () (Var () () LocalScope (Expl (ExtIdent (Right "optVal")))) () (((), PTuple () (TCons (POne () (PVar () (Just (Ident {unIdent = "v"}))), Just ()) (PVar () (Just (Ident {unIdent = "t"})), Nothing) []) (), (), Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "v"))), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "t"))), Nothing) []) ()) :| [((), PTuple () (TCons (PEmpty (), Just ()) (PVar () (Just (Ident {unIdent = "t"})), Nothing) []) (), (), Let () () (Expl (ExtIdent (Right "val"))) () (Case () (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "latestBeforeWithArray")))) (Var () () LocalScope (Expl (ExtIdent (Right "allValuesDuringInterval"))))) (Var () () LocalScope (Expl (ExtIdent (Right "t"))))) ()) () (((), POne () (POne () (PVar () (Just (Ident {unIdent = "v"})))), (), Var () () LocalScope (Expl (ExtIdent (Right "v")))) :| [((), PVar () Nothing, (), Var () () LocalScope (Expl (ExtIdent (Right "valueBeforeInterval"))))]) ()) () (Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "val"))), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "t"))), Nothing) []) ()))]) ())) () (App (App (Var () () (Scope (ModuleName {unModuleName = "Array"})) (Expl (ExtIdent (Right "map")))) (Var () () LocalScope (Expl (ExtIdent (Right "replaceNoneWithLastKnown"))))) (Var () () LocalScope (Expl (ExtIdent (Right "allValuesDuringInterval")))))) () (Let () () (Expl (ExtIdent (Right "test"))) () (Lam () (((), Just (ExtIdent (Right "valueAndTime"))) :| []) () (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "latestBeforeWithArray")))) (Var () () LocalScope (Expl (ExtIdent (Right "bitfieldArray"))))) (Bracketed () (App (Var () () LocalScope (Expl (ExtIdent (Right "snd")))) (Var () () LocalScope (Expl (ExtIdent (Right "valueAndTime"))))) ())) ())) () (LetAnnot () () (ExtIdent (Right "bigTypeAnnot")) () (ForallTC [TV {unTV = 0}] (fromList [TypeClass {className = "addition", params = [TVar (TV {unTV = 0}), TVar (TV {unTV = 0}), TVar (TV {unTV = 0})]}, TypeClass {className = "numeric", params = [TVar (TV {unTV = 0})]}]) (ImplType (M.fromList [(ExtIdent (Right "now"), TBase TTime)]) (TArr (TArray (TTuple (TCons (TVar (TV {unTV = 0})) (TBase TTime) []))) (TArr (TBase TTime) (TOptional (TVar (TV {unTV = 0}))))))) () (Var () () LocalScope (Expl (ExtIdent (Right "bigThing")))) () (Let () () (Expl (ExtIdent (Right "bigThing"))) () (Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "ASuperLongVariableName"))), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "ASuperLongVariableNamet"))), Nothing) [(One () (App (Var () () LocalScope (Expl (ExtIdent (Right "snd")))) (App (Var () () LocalScope (Expl (ExtIdent (Right "snd")))) (Var () () LocalScope (Expl (ExtIdent (Right "ASuperLongVariableNametASuperLongVariableNametASuperLongVariableNametASuperLongVariableNametASuperLongVariableNametASuperLongVariableNamet")))))), Nothing), (Var () () LocalScope (Expl (ExtIdent (Right "ASuperLongVariableNamet"))), Nothing)]) ()) () (Lit () (LDouble 2.0))))))))))))))) showPretty ast \ No newline at end of file diff --git a/inferno-types/src/Inferno/Types/Syntax.hs b/inferno-types/src/Inferno/Types/Syntax.hs index ca0db42..2cc8eab 100644 --- a/inferno-types/src/Inferno/Types/Syntax.hs +++ b/inferno-types/src/Inferno/Types/Syntax.hs @@ -169,8 +169,6 @@ import Prettyprinter rbracket, rparen, sep, - -- tupled, - vsep, (<+>), ) import qualified Prettyprinter.Internal as Pretty @@ -1439,7 +1437,6 @@ prettyPrec isBracketed prec expr = InterpolatedString {} -> p Tuple {} -> p Empty _ -> p - -- TODO test that these do the right thing! Record {} -> p RecordField {} -> p Array {} -> p @@ -1453,16 +1450,16 @@ prettyPrec isBracketed prec expr = (x : xs) -> prettyAppAux x (prettyPrec True 0 x) <> (if hasTrailingComment x then hardline else line) <> prettyApp xs Lam _ xs _ e -> let xsPretty = sep $ map (maybe "_" pretty . snd) $ toList xs - fun = group $ "fun" <> (group $ nest 2 $ line <> xsPretty) <> line <> "->" + fun = group $ "fun" <> group (nest 2 $ line <> xsPretty) <> line <> "->" body = group $ nest 2 $ line <> prettyPrec False 0 e in group $ fun <> body Let _ _ x _ e1 _ e2 -> - let e1Pretty = group $ (nest 2 $ line <> prettyPrec False 0 e1) <> (if hasTrailingComment e1 then hardline else line) + let e1Pretty = group $ nest 2 (line <> prettyPrec False 0 e1) <> (if hasTrailingComment e1 then hardline else line) letPretty = group $ "let" <+> pretty x <+> "=" <> e1Pretty <> "in" in group $ letPretty <> line <> prettyPrec False 0 e2 LetAnnot _ _ x _ t _ e1 _ e2 -> - let e1Pretty = group $ (nest 2 $ line <> prettyPrec False 0 e1) <> (if hasTrailingComment e1 then hardline else line) - tPretty = group $ (nest 2 $ line <> pretty t) <> line + let e1Pretty = group $ nest 2 (line <> prettyPrec False 0 e1) <> (if hasTrailingComment e1 then hardline else line) + tPretty = group $ nest 2 (line <> pretty t) <> line letPretty = group $ "let" <+> pretty x <+> ":" <> tPretty <> "=" <> e1Pretty <> "in" in group $ letPretty <> line <> prettyPrec False 0 e2 Lit _ l -> pretty l @@ -1503,9 +1500,9 @@ prettyPrec isBracketed prec expr = [] -> [] s : xs -> ("}" <> s) : xs If _ c _ t _ f -> - let ifPretty = "if" <> (group $ nest 2 $ line <> prettyPrec False 0 c) - thenPretty = "then" <> (group $ nest 2 $ line <> prettyPrec False 0 t) - elsePretty = "else" <> (group $ nest 2 $ line <> prettyPrec False 0 f) + let ifPretty = "if" <> group (nest 2 $ line <> prettyPrec False 0 c) + thenPretty = "then" <> group (nest 2 $ line <> prettyPrec False 0 t) + elsePretty = "else" <> group (nest 2 $ line <> prettyPrec False 0 f) in group $ ifPretty <> (if hasTrailingComment c then hardline else line) @@ -1539,33 +1536,44 @@ prettyPrec isBracketed prec expr = <+> (if hasLeadingComment e then line else mempty) <> prettyOpAux (n + 1) e Tuple _ TNil _ -> "()" - Tuple _ xs _ -> group $ flatAlt "( " "(" <> prettyTuple True (tListToList xs) + Tuple _ xs _ -> + group $ flatAlt "( " "(" <> nest 2 xsPretty <> lastLine <> ")" where + (xsPretty, lastLine) = prettyTuple True (tListToList xs) prettyTuple firstElement = \case - [] -> mempty + [] -> (mempty, mempty) [(e, _)] -> - align (prettyPrec False 0 e) - <> (if hasTrailingComment e then hardline <> ")" else flatAlt " )" ")") + ( prettyPrec False 0 e <> flatAlt "," "", + if hasTrailingComment e then hardline else flatAlt line mempty + ) (e, _) : es -> - (if not firstElement && hasLeadingComment e then line else mempty) - <> align (prettyPrec False 0 e) - <> (if hasTrailingComment e then hardline else line') - <> ", " - <> prettyTuple False es - One _ e -> "Some" <+> nest 2 (prettyPrec False 0 e) + (res, lastLine') + where + (esPretty, lastLine') = prettyTuple False es + res = + (if not firstElement && hasLeadingComment e then line else mempty) + <> prettyPrec False 0 e + <> "," + <> (if hasTrailingComment e then hardline else line) + <> esPretty + One _ e -> + group $ nest 2 $ "Some" <> line <> prettyPrec False 0 e Empty _ -> "None" Assert _ c _ e -> - let assertPretty = "assert" <+> nest 2 (prettyPrec False 0 c) - body = flatAlt " in" "in" <+> nest 2 (prettyPrec False 0 e) - in assertPretty <> (if hasTrailingComment c then hardline else line) <> body + group $ assertPretty <> line <> prettyPrec False 0 e + where + assertPretty = group $ "assert" <> cPretty <> "in" + cPretty = group $ nest 2 (line <> prettyPrec False 0 c) <> cEnd + cEnd = if hasTrailingComment c then hardline else line Case _ e_case _ patExprs _ -> - group $ - nest 2 $ - vsep - [ "match" <+> align (prettyPrec False 0 e_case <> if hasTrailingComment e_case then hardline else mempty) <+> "with" <+> "{", - align (prettyCase True $ toList patExprs) <> flatAlt " }" "}" - ] + -- TODO lastLine before closing } + group $ prettyMatch <> prettyCases <> flatAlt " }" "}" where + prettyMatch = group $ "match" <> prettyE <> "with {" + prettyE = group $ nest 2 (line <> prettyPrec False 0 e_case) <> eEnd + eEnd = if hasTrailingComment e_case then hardline else line + + prettyCases = group $ nest 2 (line <> prettyCase True (toList patExprs)) prettyCase :: Bool -> [(a, Pat hash a, a, Expr hash a)] -> Doc ann prettyCase firstElement = \case [] -> mempty From 9c9f368136d3fe7ac77319e472c2693f1c8c6469 Mon Sep 17 00:00:00 2001 From: Siddharth Krishna Date: Mon, 25 Mar 2024 11:16:13 +0200 Subject: [PATCH 05/16] Add --parse to inferno exe --- inferno-core/app/Main.hs | 51 +++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 14 deletions(-) diff --git a/inferno-core/app/Main.hs b/inferno-core/app/Main.hs index 362d959..6734a9a 100644 --- a/inferno-core/app/Main.hs +++ b/inferno-core/app/Main.hs @@ -1,14 +1,17 @@ {-# LANGUAGE LambdaCase #-} -{-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TypeApplications #-} module Main where import Data.Bifunctor (bimap) import qualified Data.Map as Map import qualified Data.Text.IO as Text -import Inferno.Core (Interpreter (..), mkInferno) -import Inferno.Module.Prelude (builtinModules) +import Inferno.Eval (runEvalM) +import Inferno.Infer (inferExpr) +import Inferno.Infer.Pinned (pinExpr) +import Inferno.Module.Prelude (baseOpsTable, builtinModules, builtinModulesOpsTable, builtinModulesPinMap, builtinModulesTerms) +import Inferno.Parse (parseExpr) import Inferno.Types.VersionControl (pinnedToMaybe) import Inferno.Utils.Prettyprinter (showPretty) import Options.Applicative @@ -31,13 +34,14 @@ import Options.Applicative import System.Exit (exitFailure) import System.IO (hPrint, stderr) -data CliArgs = CliArgs {file :: String, typecheck :: Bool} +data CliArgs = CliArgs {file :: String, typecheck :: Bool, parse :: Bool} cliargs :: Parser CliArgs cliargs = CliArgs <$> argument str (metavar "FILE" <> help "Input file path") <*> switch (long "typecheck" <> short 't' <> help "Only run type inference") + <*> switch (long "parse" <> short 'p' <> help "Only run parser") main :: IO () main = do @@ -51,21 +55,40 @@ main = do args <- execParser opts src <- Text.readFile $ file args - Interpreter {evalExpr, defaultEnv, parseAndInfer} <- - mkInferno builtinModules [] :: IO (Interpreter IO ()) - case parseAndInfer src of + let customTypes = [] + let prelude = builtinModules @IO @() + let defaultEnv = builtinModulesTerms prelude + -- parse + case parseExpr (baseOpsTable prelude) (builtinModulesOpsTable prelude) customTypes src of Left err -> do hPrint stderr err exitFailure - Right (ast, ty, _, _) -> do - if typecheck args + Right (ast, _comments) -> + if parse args then do - putStrLn "Inferred type:" - showPretty ty + putStrLn "Parsed Expr:" + print $ bimap id (const ()) ast else do - let ast' = bimap pinnedToMaybe (const ()) ast - evalExpr defaultEnv Map.empty ast' >>= \case + -- pin free variables to builtin prelude function hashes + case pinExpr (builtinModulesPinMap prelude) ast of Left err -> do hPrint stderr err exitFailure - Right res -> showPretty res + Right pinnedAST -> + -- typecheck + case inferExpr prelude pinnedAST of + Left err -> do + hPrint stderr err + exitFailure + Right (ast', ty, _tyMap) -> + if typecheck args + then do + putStrLn "Inferred type:" + showPretty ty + else do + let ast'' = bimap pinnedToMaybe (const ()) ast' + runEvalM defaultEnv Map.empty ast'' >>= \case + Left err -> do + hPrint stderr err + exitFailure + Right res -> showPretty res From 790d0e9f4db7b07b4e1b6b048a8785bed48b983a Mon Sep 17 00:00:00 2001 From: Siddharth Krishna Date: Tue, 26 Mar 2024 11:31:53 +0200 Subject: [PATCH 06/16] Uniform handling of all multi-element Expr constructors --- inferno-types/pretty-test/Main.hs | 4 +- inferno-types/src/Inferno/Types/Syntax.hs | 198 +++++++++------------- 2 files changed, 86 insertions(+), 116 deletions(-) diff --git a/inferno-types/pretty-test/Main.hs b/inferno-types/pretty-test/Main.hs index e62784a..c8a5210 100644 --- a/inferno-types/pretty-test/Main.hs +++ b/inferno-types/pretty-test/Main.hs @@ -14,6 +14,6 @@ import Inferno.Utils.Prettyprinter (showPretty) main :: IO () main = do let ast :: Expr () () = - Let () () (Expl (ExtIdent (Right "bigApp"))) () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig")))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) () (Let () () (Expl (ExtIdent (Right "null"))) () (Tuple () TNil ()) () (Let () () (Expl (ExtIdent (Right "smallTup"))) () (Tuple () (TCons (Lit () (LInt 12314314),Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "fadsfdfsadfa"))),Just ()) [(Lit () (LInt 13413241345),Nothing)]) ()) () (Let () () (Expl (ExtIdent (Right "mediumTup"))) () (Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()) [(Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "medi"))),Nothing)]) ()) () (Let () () (Expl (ExtIdent (Right "bigTup"))) () (Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))),Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))),Just ()) [(Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))),Just ()),(One () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig")))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))),Nothing)]) ()) () (Assert () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "thing"))))) (Var () () LocalScope (Expl (ExtIdent (Right "small"))))) () (Assert () (App (App (App (App (App (App (App (App (App (App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "thing"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) () (Assert () (App (App (App (App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "thing"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) () (Let () () (Expl (ExtIdent (Right "x"))) () (Case () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "thing"))))) (Var () () LocalScope (Expl (ExtIdent (Right "small"))))) () (((),PLit () (LInt 1),(),Lit () (LInt 2)) :| [((),PVar () Nothing,(),Lit () (LInt 3))]) ()) () (Let () () (Expl (ExtIdent (Right "x"))) () (Case () (App (App (App (App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "thing"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) () (((),PTuple () (TCons (PVar () (Just (Ident {unIdent = "biggbig"})),Just ()) (PVar () (Just (Ident {unIdent = "bigbigbig"})),Just ()) [(PVar () (Just (Ident {unIdent = "bigbigbigbig"})),Just ()),(PVar () (Just (Ident {unIdent = "bigbigbigbigbig"})),Just ()),(PVar () (Just (Ident {unIdent = "bigbigbigbigbigbigbig"})),Just ()),(PVar () (Just (Ident {unIdent = "bigbigbigbigbigbigbigbigbig"})),Nothing)]) (),(),Lit () (LInt 2)) :| [((),PVar () Nothing,(),Lit () (LInt 3))]) ()) () (Lit () (LDouble 1.1))))))))))) - -- Let () () (Impl (ExtIdent (Right "resolution"))) () (App (Var () () LocalScope (Expl (ExtIdent (Right "toResolution")))) (Lit () (LInt 64))) () (LetAnnot () () (ExtIdent (Right "latestBeforeWithArray")) () (ForallTC [TV {unTV = 0}] (fromList []) (ImplType (M.fromList []) (TArr (TArray (TTuple (TCons (TVar (TV {unTV = 0})) (TBase TTime) []))) (TArr (TBase TTime) (TOptional (TVar (TV {unTV = 0}))))))) () (Lam () (((), Just (ExtIdent (Right "arr"))) :| [((), Just (ExtIdent (Right "t")))]) () (Let () () (Expl (ExtIdent (Right "compareTimes"))) () (Lam () (((), Just (ExtIdent (Right "targetTime"))) :| [((), Just (ExtIdent (Right "testValAndTime"))), ((), Just (ExtIdent (Right "lastValAndTime")))]) () (If () (Op (Var () () LocalScope (Expl (ExtIdent (Right "targetTime")))) () () (7, NoFix) LocalScope (Ident {unIdent = "<"}) (Bracketed () (App (Var () () LocalScope (Expl (ExtIdent (Right "snd")))) (Var () () LocalScope (Expl (ExtIdent (Right "testValAndTime"))))) ())) () (Var () () LocalScope (Expl (ExtIdent (Right "lastValAndTime")))) () (Var () () LocalScope (Expl (ExtIdent (Right "testValAndTime")))))) () (Let () () (Expl (ExtIdent (Right "subValues"))) () (Lam () (((), Just (ExtIdent (Right "lastValAndTime"))) :| [((), Just (ExtIdent (Right "testValAndTime")))]) () (Case () (Var () () LocalScope (Expl (ExtIdent (Right "lastValAndTime")))) () (((), PEmpty (), (), If () (Op (Var () () LocalScope (Expl (ExtIdent (Right "t")))) () () (7, NoFix) LocalScope (Ident {unIdent = "<"}) (Bracketed () (App (Var () () LocalScope (Expl (ExtIdent (Right "snd")))) (Var () () LocalScope (Expl (ExtIdent (Right "testValAndTime"))))) ())) () (Empty ()) () (Bracketed () (One () (Var () () LocalScope (Expl (ExtIdent (Right "testValAndTime"))))) ())) :| [((), POne () (PVar () (Just (Ident {unIdent = "ltv"}))), (), One () (Bracketed () (App (App (App (Var () () LocalScope (Expl (ExtIdent (Right "compareTimes")))) (Var () () LocalScope (Expl (ExtIdent (Right "t"))))) (Var () () LocalScope (Expl (ExtIdent (Right "testValAndTime"))))) (Var () () LocalScope (Expl (ExtIdent (Right "ltv"))))) ()))]) ())) () (Bracketed () (App (App (Var () () (Scope (ModuleName {unModuleName = "Option"})) (Expl (ExtIdent (Right "map")))) (Var () () LocalScope (Expl (ExtIdent (Right "fst"))))) (Bracketed () (App (App (App (Var () () (Scope (ModuleName {unModuleName = "Array"})) (Expl (ExtIdent (Right "reduce")))) (Var () () LocalScope (Expl (ExtIdent (Right "subValues"))))) (Empty ())) (Var () () LocalScope (Expl (ExtIdent (Right "arr"))))) ())) ())))) () (Let () () (Expl (ExtIdent (Right "intervalStep"))) () (Bracketed () (App (Var () () LocalScope (Expl (ExtIdent (Right "resolutionToInt")))) (Var () () LocalScope (Impl (ExtIdent (Right "resolution"))))) ()) () (Let () () (Expl (ExtIdent (Right "startOfInterval"))) () (Bracketed () (Op (Var () () LocalScope (Impl (ExtIdent (Right "now")))) () () (9, LeftFix) LocalScope (Ident {unIdent = "-"}) (Bracketed () (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "hours")))) (Lit () (LInt 24))) ())) ()) () (LetAnnot () () (ExtIdent (Right "valueBeforeInterval")) () (ForallTC [] (fromList []) (ImplType (M.fromList []) (TBase TDouble))) () (App (App (App (Var () () (Scope (ModuleName {unModuleName = "Option"})) (Expl (ExtIdent (Right "reduce")))) (Var () () LocalScope (Expl (ExtIdent (Right "id"))))) (Lit () (LDouble 0.0))) (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "latestValueBefore")))) (Var () () LocalScope (Expl (ExtIdent (Right "startOfInterval"))))) (Var () () LocalScope (Expl (ExtIdent (Right "power"))))) ())) () (LetAnnot () () (ExtIdent (Right "bitfieldBeforeInterval")) () (ForallTC [] (fromList []) (ImplType (M.fromList []) (TBase TDouble))) () (App (App (App (Var () () (Scope (ModuleName {unModuleName = "Option"})) (Expl (ExtIdent (Right "reduce")))) (Var () () LocalScope (Expl (ExtIdent (Right "id"))))) (Lit () (LDouble 0.0))) (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "latestValueBefore")))) (Var () () LocalScope (Expl (ExtIdent (Right "startOfInterval"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bitParam"))))) ())) () (LetAnnot () () (ExtIdent (Right "allValuesDuringInterval")) () (ForallTC [] (fromList []) (ImplType (M.fromList []) (TArray (TTuple (TCons (TOptional (TBase TDouble)) (TBase TTime) []))))) () (ArrayComp () (Tuple () (TCons (App (App (Var () () LocalScope (Expl (ExtIdent (Right "valueAtOrAdjacent")))) (Var () () LocalScope (Expl (ExtIdent (Right "power"))))) (Var () () LocalScope (Expl (ExtIdent (Right "t")))), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "t"))), Nothing) []) ()) () (((), Ident {unIdent = "t"}, (), App (App (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "intervalEvery")))) (Bracketed () (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "seconds")))) (Var () () LocalScope (Expl (ExtIdent (Right "intervalStep"))))) ())) (Var () () LocalScope (Expl (ExtIdent (Right "startOfInterval"))))) (Var () () LocalScope (Impl (ExtIdent (Right "now")))), Nothing) :| []) Nothing ()) () (LetAnnot () () (ExtIdent (Right "bitfieldArray")) () (ForallTC [] (fromList []) (ImplType (M.fromList []) (TArray (TTuple (TCons (TBase TDouble) (TBase TTime) []))))) () (Let () () (Impl (ExtIdent (Right "resolution"))) () (App (Var () () LocalScope (Expl (ExtIdent (Right "toResolution")))) (Lit () (LInt 1))) () (App (Var () () (Scope (ModuleName {unModuleName = "Array"})) (Expl (ExtIdent (Right "keepSomes")))) (ArrayComp () (App (App (Var () () (Scope (ModuleName {unModuleName = "Option"})) (Expl (ExtIdent (Right "map")))) (Bracketed () (Lam () (((), Just (ExtIdent (Right "v"))) :| []) () (Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "v"))), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "t"))), Nothing) []) ())) ())) (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "valueAt")))) (Var () () LocalScope (Expl (ExtIdent (Right "bitParam"))))) (Var () () LocalScope (Expl (ExtIdent (Right "t"))))) ())) () (((), Ident {unIdent = "t"}, (), App (App (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "intervalEvery")))) (Bracketed () (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "seconds")))) (Lit () (LInt 1))) ())) (Bracketed () (Op (Var () () LocalScope (Impl (ExtIdent (Right "now")))) () () (9, LeftFix) LocalScope (Ident {unIdent = "-"}) (Bracketed () (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "hours")))) (Lit () (LInt 24))) ())) ())) (Var () () LocalScope (Impl (ExtIdent (Right "now")))), Nothing) :| []) Nothing ()))) () (Let () () (Expl (ExtIdent (Right "inPrimaryDischarge"))) () (Lam () (((), Just (ExtIdent (Right "word"))) :| []) () (If () (Bracketed () (Op (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "testBit")))) (Var () () LocalScope (Expl (ExtIdent (Right "word"))))) (Lit () (LInt 4))) ()) () () (3, RightFix) LocalScope (Ident {unIdent = "||"}) (Op (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "testBit")))) (Var () () LocalScope (Expl (ExtIdent (Right "word"))))) (Lit () (LInt 5))) ()) () () (3, RightFix) LocalScope (Ident {unIdent = "||"}) (Op (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "testBit")))) (Var () () LocalScope (Expl (ExtIdent (Right "word"))))) (Lit () (LInt 6))) ()) () () (3, RightFix) LocalScope (Ident {unIdent = "||"}) (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "testBit")))) (Var () () LocalScope (Expl (ExtIdent (Right "word"))))) (Lit () (LInt 7))) ())))) ()) () (Enum () () LocalScope (Ident {unIdent = "false"})) () (Enum () () LocalScope (Ident {unIdent = "true"})))) () (Let () () (Expl (ExtIdent (Right "isCharging"))) () (Lam () (((), Just (ExtIdent (Right "c"))) :| []) () (Op (Var () () LocalScope (Expl (ExtIdent (Right "c")))) () () (7, NoFix) LocalScope (Ident {unIdent = ">"}) (Lit () (LDouble 1.0)))) () (LetAnnot () () (ExtIdent (Right "chargeMappedValuesDuringInterval")) () (ForallTC [] (fromList []) (ImplType (M.fromList []) (TArray (TTuple (TCons (TBase TDouble) (TBase TTime) []))))) () (Let () () (Expl (ExtIdent (Right "replaceNoneWithLastKnown"))) () (Lam () (((), Just (ExtIdent (Right "ASuperLongVariableName"))) :| [((), Just (ExtIdent (Right "ASuperLongVariableName"))), ((), Just (ExtIdent (Right "ASuperLongVariableName"))), ((), Just (ExtIdent (Right "ASuperLongVariableName")))]) () (Case () (Var () () LocalScope (Expl (ExtIdent (Right "optVal")))) () (((), PTuple () (TCons (POne () (PVar () (Just (Ident {unIdent = "v"}))), Just ()) (PVar () (Just (Ident {unIdent = "t"})), Nothing) []) (), (), Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "v"))), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "t"))), Nothing) []) ()) :| [((), PTuple () (TCons (PEmpty (), Just ()) (PVar () (Just (Ident {unIdent = "t"})), Nothing) []) (), (), Let () () (Expl (ExtIdent (Right "val"))) () (Case () (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "latestBeforeWithArray")))) (Var () () LocalScope (Expl (ExtIdent (Right "allValuesDuringInterval"))))) (Var () () LocalScope (Expl (ExtIdent (Right "t"))))) ()) () (((), POne () (POne () (PVar () (Just (Ident {unIdent = "v"})))), (), Var () () LocalScope (Expl (ExtIdent (Right "v")))) :| [((), PVar () Nothing, (), Var () () LocalScope (Expl (ExtIdent (Right "valueBeforeInterval"))))]) ()) () (Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "val"))), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "t"))), Nothing) []) ()))]) ())) () (App (App (Var () () (Scope (ModuleName {unModuleName = "Array"})) (Expl (ExtIdent (Right "map")))) (Var () () LocalScope (Expl (ExtIdent (Right "replaceNoneWithLastKnown"))))) (Var () () LocalScope (Expl (ExtIdent (Right "allValuesDuringInterval")))))) () (Let () () (Expl (ExtIdent (Right "test"))) () (Lam () (((), Just (ExtIdent (Right "valueAndTime"))) :| []) () (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "latestBeforeWithArray")))) (Var () () LocalScope (Expl (ExtIdent (Right "bitfieldArray"))))) (Bracketed () (App (Var () () LocalScope (Expl (ExtIdent (Right "snd")))) (Var () () LocalScope (Expl (ExtIdent (Right "valueAndTime"))))) ())) ())) () (LetAnnot () () (ExtIdent (Right "bigTypeAnnot")) () (ForallTC [TV {unTV = 0}] (fromList [TypeClass {className = "addition", params = [TVar (TV {unTV = 0}), TVar (TV {unTV = 0}), TVar (TV {unTV = 0})]}, TypeClass {className = "numeric", params = [TVar (TV {unTV = 0})]}]) (ImplType (M.fromList [(ExtIdent (Right "now"), TBase TTime)]) (TArr (TArray (TTuple (TCons (TVar (TV {unTV = 0})) (TBase TTime) []))) (TArr (TBase TTime) (TOptional (TVar (TV {unTV = 0}))))))) () (Var () () LocalScope (Expl (ExtIdent (Right "bigThing")))) () (Let () () (Expl (ExtIdent (Right "bigThing"))) () (Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "ASuperLongVariableName"))), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "ASuperLongVariableNamet"))), Nothing) [(One () (App (Var () () LocalScope (Expl (ExtIdent (Right "snd")))) (App (Var () () LocalScope (Expl (ExtIdent (Right "snd")))) (Var () () LocalScope (Expl (ExtIdent (Right "ASuperLongVariableNametASuperLongVariableNametASuperLongVariableNametASuperLongVariableNametASuperLongVariableNametASuperLongVariableNamet")))))), Nothing), (Var () () LocalScope (Expl (ExtIdent (Right "ASuperLongVariableNamet"))), Nothing)]) ()) () (Lit () (LDouble 2.0))))))))))))))) + Let () () (Expl (ExtIdent (Right "bigApp"))) () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig")))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) () (Let () () (Expl (ExtIdent (Right "null"))) () (Tuple () TNil ()) () (Let () () (Expl (ExtIdent (Right "smallTup"))) () (Tuple () (TCons (Lit () (LInt 12314314), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "fadsfdfsadfa"))), Just ()) [(Lit () (LInt 13413241345), Nothing)]) ()) () (Let () () (Expl (ExtIdent (Right "mediumTup"))) () (Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()) [(Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "mediu"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "mediu"))), Nothing)]) ()) () (Let () () (Expl (ExtIdent (Right "bigTup"))) () (Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))), Just ()) [(Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))), Just ()), (One () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig")))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))), Nothing)]) ()) () (Assert () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "thing"))))) (Var () () LocalScope (Expl (ExtIdent (Right "small"))))) () (Assert () (App (App (App (App (App (App (App (App (App (App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "thing"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) () (Assert () (App (App (App (App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "thing"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) () (Let () () (Expl (ExtIdent (Right "x"))) () (Case () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "thing"))))) (Var () () LocalScope (Expl (ExtIdent (Right "small"))))) () (((), PLit () (LInt 1), (), Lit () (LInt 2)) :| [((), PVar () Nothing, (), Lit () (LInt 3))]) ()) () (Let () () (Expl (ExtIdent (Right "x"))) () (Case () (App (App (App (App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "thing"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) () (((), PTuple () (TCons (PVar () (Just (Ident {unIdent = "biggbig"})), Just ()) (PVar () (Just (Ident {unIdent = "bigbigbig"})), Just ()) [(PVar () (Just (Ident {unIdent = "bigbigbigbig"})), Just ()), (PVar () (Just (Ident {unIdent = "bigbigbigbigbig"})), Just ()), (PVar () (Just (Ident {unIdent = "bigbigbigbigbigbigbig"})), Just ()), (PVar () (Just (Ident {unIdent = "bigbigbigbigbigbigbigbigbig"})), Nothing)]) (), (), Lit () (LInt 2)) :| [((), PVar () Nothing, (), Lit () (LInt 3))]) ()) () (Let () () (Expl (ExtIdent (Right "smallRec"))) () (Record () [(Ident {unIdent = "height"}, Lit () (LInt 2), Just ()), (Ident {unIdent = "weight"}, Tuple () (TCons (Lit () (LDouble 3.54), Just ()) (Lit () (LText "kgs"), Nothing) []) (), Nothing)] ()) () (Let () () (Expl (ExtIdent (Right "bigRec"))) () (Record () [(Ident {unIdent = "height"}, Tuple () (TCons (Lit () (LInt 12314314), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "fadsfdfsadfa"))), Just ()) [(Lit () (LInt 13413241345), Nothing)]) (), Just ()), (Ident {unIdent = "weight"}, Tuple () (TCons (Lit () (LDouble 3.54), Just ()) (Lit () (LText "kgs"), Nothing) []) (), Just ()), (Ident {unIdent = "name"}, Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "biggbig"))), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbig"))), Just ()) [(Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbig"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbig"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbig"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbig"))), Nothing)]) (), Nothing)] ()) () (Let () () (Expl (ExtIdent (Right "smallArr"))) () (Array () [(Lit () (LInt 12314314), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "fadsfdfsadfa"))), Just ()), (Lit () (LInt 13413241345), Just ())] ()) () (Let () () (Expl (ExtIdent (Right "mediumArr"))) () (Array () [(Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "mediu"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "mediu"))), Nothing)] ()) () (Let () () (Expl (ExtIdent (Right "bigArr"))) () (Array () [(Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))), Just ()), (One () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig")))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))), Nothing)] ()) () (Let () () (Expl (ExtIdent (Right "arrayComp"))) () (ArrayComp () (App (App (App (App (Var () () LocalScope (Expl (ExtIdent (Right "bigFun")))) (Var () () LocalScope (Expl (ExtIdent (Right "one"))))) (Var () () LocalScope (Expl (ExtIdent (Right "two"))))) (Var () () LocalScope (Expl (ExtIdent (Right "three"))))) (Var () () LocalScope (Expl (ExtIdent (Right "four"))))) () (((), Ident {unIdent = "one"}, (), App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "thing")))), Just ()) :| []) (Just ((), App (Var () () LocalScope (Expl (ExtIdent (Right "one")))) (Var () () LocalScope (Expl (ExtIdent (Right "two")))))) ()) () (Let () () (Expl (ExtIdent (Right "arrayComp"))) () (ArrayComp () (App (App (App (App (App (App (Var () () LocalScope (Expl (ExtIdent (Right "getBitValAndTime")))) (Var () () LocalScope (Expl (ExtIdent (Right "t"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) () (((), Ident {unIdent = "t"}, (), App (App (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "intervalEvery")))) (Bracketed () (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "seconds")))) (Var () () LocalScope (Expl (ExtIdent (Right "intervalStep"))))) ())) (Var () () LocalScope (Expl (ExtIdent (Right "startOfInterval"))))) (Var () () LocalScope (Impl (ExtIdent (Right "now")))), Just ()) :| [((), Ident {unIdent = "one"}, (), App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "thing")))), Just ()), ((), Ident {unIdent = "two"}, (), App (App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "other"))))) (Var () () LocalScope (Expl (ExtIdent (Right "thing")))), Just ()), ((), Ident {unIdent = "three"}, (), One () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig")))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))), Just ())]) (Just ((), Bracketed () (App (App (App (App (Var () () LocalScope (Expl (ExtIdent (Right "one")))) (Var () () LocalScope (Expl (ExtIdent (Right "two"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) ())) ()) () (RenameModule () (ModuleName {unModuleName = "mSmall"}) () (ModuleName {unModuleName = "Number"}) () (RenameModule () (ModuleName {unModuleName = "bigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbig"}) () (ModuleName {unModuleName = "Array"}) () (OpenModule () () (ModuleName {unModuleName = "Array"}) [] () (OpenModule () () (ModuleName {unModuleName = "Array"}) [(IVar () (Ident {unIdent = "foo"}), Just ()), (IVar () (Ident {unIdent = "bar"}), Just ()), (IVar () (Ident {unIdent = "baz"}), Just ()), (IVar () (Ident {unIdent = "bar"}), Just ()), (IVar () (Ident {unIdent = "baz"}), Just ()), (IVar () (Ident {unIdent = "bar"}), Just ()), (IVar () (Ident {unIdent = "baz"}), Nothing)] () (OpenModule () () (ModuleName {unModuleName = "Array"}) [(IVar () (Ident {unIdent = "foo"}), Just ()), (IVar () (Ident {unIdent = "bar"}), Just ()), (IVar () (Ident {unIdent = "baz"}), Just ()), (IVar () (Ident {unIdent = "bar"}), Just ()), (IVar () (Ident {unIdent = "baz"}), Just ()), (IVar () (Ident {unIdent = "bar"}), Just ()), (IVar () (Ident {unIdent = "baz"}), Just ()), (IVar () (Ident {unIdent = "bar"}), Just ()), (IVar () (Ident {unIdent = "baz"}), Just ()), (IVar () (Ident {unIdent = "bar"}), Just ()), (IVar () (Ident {unIdent = "baz"}), Just ()), (IVar () (Ident {unIdent = "bar"}), Just ()), (IVar () (Ident {unIdent = "baz"}), Just ()), (IVar () (Ident {unIdent = "bar"}), Just ()), (IVar () (Ident {unIdent = "baz"}), Just ()), (IVar () (Ident {unIdent = "bar"}), Just ()), (IVar () (Ident {unIdent = "baz"}), Just ()), (IVar () (Ident {unIdent = "bar"}), Just ()), (IVar () (Ident {unIdent = "baz"}), Nothing)] () (Lit () (LDouble 1.1))))))))))))))))))))))) + -- Let () () (Impl (ExtIdent (Right "resolution"))) () (App (Var () () LocalScope (Expl (ExtIdent (Right "toResolution")))) (Lit () (LInt 64))) () (LetAnnot () () (ExtIdent (Right "latestBeforeWithArray")) () (ForallTC [TV {unTV = 0}] (fromList []) (ImplType (M.fromList []) (TArr (TArray (TTuple (TCons (TVar (TV {unTV = 0})) (TBase TTime) []))) (TArr (TBase TTime) (TOptional (TVar (TV {unTV = 0}))))))) () (Lam () (((), Just (ExtIdent (Right "arr"))) :| [((), Just (ExtIdent (Right "t")))]) () (Let () () (Expl (ExtIdent (Right "compareTimes"))) () (Lam () (((), Just (ExtIdent (Right "targetTime"))) :| [((), Just (ExtIdent (Right "testValAndTime"))), ((), Just (ExtIdent (Right "lastValAndTime")))]) () (If () (Op (Var () () LocalScope (Expl (ExtIdent (Right "targetTime")))) () () (7, NoFix) LocalScope (Ident {unIdent = "<"}) (Bracketed () (App (Var () () LocalScope (Expl (ExtIdent (Right "snd")))) (Var () () LocalScope (Expl (ExtIdent (Right "testValAndTime"))))) ())) () (Var () () LocalScope (Expl (ExtIdent (Right "lastValAndTime")))) () (Var () () LocalScope (Expl (ExtIdent (Right "testValAndTime")))))) () (Let () () (Expl (ExtIdent (Right "subValues"))) () (Lam () (((), Just (ExtIdent (Right "lastValAndTime"))) :| [((), Just (ExtIdent (Right "testValAndTime")))]) () (Case () (Var () () LocalScope (Expl (ExtIdent (Right "lastValAndTime")))) () (((), PEmpty (), (), If () (Op (Var () () LocalScope (Expl (ExtIdent (Right "t")))) () () (7, NoFix) LocalScope (Ident {unIdent = "<"}) (Bracketed () (App (Var () () LocalScope (Expl (ExtIdent (Right "snd")))) (Var () () LocalScope (Expl (ExtIdent (Right "testValAndTime"))))) ())) () (Empty ()) () (Bracketed () (One () (Var () () LocalScope (Expl (ExtIdent (Right "testValAndTime"))))) ())) :| [((), POne () (PVar () (Just (Ident {unIdent = "ltv"}))), (), One () (Bracketed () (App (App (App (Var () () LocalScope (Expl (ExtIdent (Right "compareTimes")))) (Var () () LocalScope (Expl (ExtIdent (Right "t"))))) (Var () () LocalScope (Expl (ExtIdent (Right "testValAndTime"))))) (Var () () LocalScope (Expl (ExtIdent (Right "ltv"))))) ()))]) ())) () (Bracketed () (App (App (Var () () (Scope (ModuleName {unModuleName = "Option"})) (Expl (ExtIdent (Right "map")))) (Var () () LocalScope (Expl (ExtIdent (Right "fst"))))) (Bracketed () (App (App (App (Var () () (Scope (ModuleName {unModuleName = "Array"})) (Expl (ExtIdent (Right "reduce")))) (Var () () LocalScope (Expl (ExtIdent (Right "subValues"))))) (Empty ())) (Var () () LocalScope (Expl (ExtIdent (Right "arr"))))) ())) ())))) () (Let () () (Expl (ExtIdent (Right "intervalStep"))) () (Bracketed () (App (Var () () LocalScope (Expl (ExtIdent (Right "resolutionToInt")))) (Var () () LocalScope (Impl (ExtIdent (Right "resolution"))))) ()) () (Let () () (Expl (ExtIdent (Right "startOfInterval"))) () (Bracketed () (Op (Var () () LocalScope (Impl (ExtIdent (Right "now")))) () () (9, LeftFix) LocalScope (Ident {unIdent = "-"}) (Bracketed () (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "hours")))) (Lit () (LInt 24))) ())) ()) () (LetAnnot () () (ExtIdent (Right "valueBeforeInterval")) () (ForallTC [] (fromList []) (ImplType (M.fromList []) (TBase TDouble))) () (App (App (App (Var () () (Scope (ModuleName {unModuleName = "Option"})) (Expl (ExtIdent (Right "reduce")))) (Var () () LocalScope (Expl (ExtIdent (Right "id"))))) (Lit () (LDouble 0.0))) (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "latestValueBefore")))) (Var () () LocalScope (Expl (ExtIdent (Right "startOfInterval"))))) (Var () () LocalScope (Expl (ExtIdent (Right "power"))))) ())) () (LetAnnot () () (ExtIdent (Right "bitfieldBeforeInterval")) () (ForallTC [] (fromList []) (ImplType (M.fromList []) (TBase TDouble))) () (App (App (App (Var () () (Scope (ModuleName {unModuleName = "Option"})) (Expl (ExtIdent (Right "reduce")))) (Var () () LocalScope (Expl (ExtIdent (Right "id"))))) (Lit () (LDouble 0.0))) (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "latestValueBefore")))) (Var () () LocalScope (Expl (ExtIdent (Right "startOfInterval"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bitParam"))))) ())) () (LetAnnot () () (ExtIdent (Right "allValuesDuringInterval")) () (ForallTC [] (fromList []) (ImplType (M.fromList []) (TArray (TTuple (TCons (TOptional (TBase TDouble)) (TBase TTime) []))))) () (ArrayComp () (Tuple () (TCons (App (App (Var () () LocalScope (Expl (ExtIdent (Right "valueAtOrAdjacent")))) (Var () () LocalScope (Expl (ExtIdent (Right "power"))))) (Var () () LocalScope (Expl (ExtIdent (Right "t")))), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "t"))), Nothing) []) ()) () (((), Ident {unIdent = "t"}, (), App (App (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "intervalEvery")))) (Bracketed () (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "seconds")))) (Var () () LocalScope (Expl (ExtIdent (Right "intervalStep"))))) ())) (Var () () LocalScope (Expl (ExtIdent (Right "startOfInterval"))))) (Var () () LocalScope (Impl (ExtIdent (Right "now")))), Nothing) :| []) Nothing ()) () (LetAnnot () () (ExtIdent (Right "bitfieldArray")) () (ForallTC [] (fromList []) (ImplType (M.fromList []) (TArray (TTuple (TCons (TBase TDouble) (TBase TTime) []))))) () (Let () () (Impl (ExtIdent (Right "resolution"))) () (App (Var () () LocalScope (Expl (ExtIdent (Right "toResolution")))) (Lit () (LInt 1))) () (App (Var () () (Scope (ModuleName {unModuleName = "Array"})) (Expl (ExtIdent (Right "keepSomes")))) (ArrayComp () (App (App (Var () () (Scope (ModuleName {unModuleName = "Option"})) (Expl (ExtIdent (Right "map")))) (Bracketed () (Lam () (((), Just (ExtIdent (Right "v"))) :| []) () (Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "v"))), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "t"))), Nothing) []) ())) ())) (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "valueAt")))) (Var () () LocalScope (Expl (ExtIdent (Right "bitParam"))))) (Var () () LocalScope (Expl (ExtIdent (Right "t"))))) ())) () (((), Ident {unIdent = "t"}, (), App (App (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "intervalEvery")))) (Bracketed () (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "seconds")))) (Lit () (LInt 1))) ())) (Bracketed () (Op (Var () () LocalScope (Impl (ExtIdent (Right "now")))) () () (9, LeftFix) LocalScope (Ident {unIdent = "-"}) (Bracketed () (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "hours")))) (Lit () (LInt 24))) ())) ())) (Var () () LocalScope (Impl (ExtIdent (Right "now")))), Nothing) :| []) Nothing ()))) () (Let () () (Expl (ExtIdent (Right "inPrimaryDischarge"))) () (Lam () (((), Just (ExtIdent (Right "word"))) :| []) () (If () (Bracketed () (Op (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "testBit")))) (Var () () LocalScope (Expl (ExtIdent (Right "word"))))) (Lit () (LInt 4))) ()) () () (3, RightFix) LocalScope (Ident {unIdent = "||"}) (Op (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "testBit")))) (Var () () LocalScope (Expl (ExtIdent (Right "word"))))) (Lit () (LInt 5))) ()) () () (3, RightFix) LocalScope (Ident {unIdent = "||"}) (Op (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "testBit")))) (Var () () LocalScope (Expl (ExtIdent (Right "word"))))) (Lit () (LInt 6))) ()) () () (3, RightFix) LocalScope (Ident {unIdent = "||"}) (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "testBit")))) (Var () () LocalScope (Expl (ExtIdent (Right "word"))))) (Lit () (LInt 7))) ())))) ()) () (Enum () () LocalScope (Ident {unIdent = "false"})) () (Enum () () LocalScope (Ident {unIdent = "true"})))) () (Let () () (Expl (ExtIdent (Right "isCharging"))) () (Lam () (((), Just (ExtIdent (Right "c"))) :| []) () (Op (Var () () LocalScope (Expl (ExtIdent (Right "c")))) () () (7, NoFix) LocalScope (Ident {unIdent = ">"}) (Lit () (LDouble 1.0)))) () (LetAnnot () () (ExtIdent (Right "chargeMappedValuesDuringInterval")) () (ForallTC [] (fromList []) (ImplType (M.fromList []) (TArray (TTuple (TCons (TBase TDouble) (TBase TTime) []))))) () (Let () () (Expl (ExtIdent (Right "replaceNoneWithLastKnown"))) () (Lam () (((), Just (ExtIdent (Right "ASuperLongVariableName"))) :| [((), Just (ExtIdent (Right "ASuperLongVariableName"))), ((), Just (ExtIdent (Right "ASuperLongVariableName"))), ((), Just (ExtIdent (Right "ASuperLongVariableName")))]) () (Case () (Var () () LocalScope (Expl (ExtIdent (Right "optVal")))) () (((), PTuple () (TCons (POne () (PVar () (Just (Ident {unIdent = "v"}))), Just ()) (PVar () (Just (Ident {unIdent = "t"})), Nothing) []) (), (), Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "v"))), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "t"))), Nothing) []) ()) :| [((), PTuple () (TCons (PEmpty (), Just ()) (PVar () (Just (Ident {unIdent = "t"})), Nothing) []) (), (), Let () () (Expl (ExtIdent (Right "val"))) () (Case () (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "latestBeforeWithArray")))) (Var () () LocalScope (Expl (ExtIdent (Right "allValuesDuringInterval"))))) (Var () () LocalScope (Expl (ExtIdent (Right "t"))))) ()) () (((), POne () (POne () (PVar () (Just (Ident {unIdent = "v"})))), (), Var () () LocalScope (Expl (ExtIdent (Right "v")))) :| [((), PVar () Nothing, (), Var () () LocalScope (Expl (ExtIdent (Right "valueBeforeInterval"))))]) ()) () (Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "val"))), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "t"))), Nothing) []) ()))]) ())) () (App (App (Var () () (Scope (ModuleName {unModuleName = "Array"})) (Expl (ExtIdent (Right "map")))) (Var () () LocalScope (Expl (ExtIdent (Right "replaceNoneWithLastKnown"))))) (Var () () LocalScope (Expl (ExtIdent (Right "allValuesDuringInterval")))))) () (Let () () (Expl (ExtIdent (Right "test"))) () (Lam () (((), Just (ExtIdent (Right "valueAndTime"))) :| []) () (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "latestBeforeWithArray")))) (Var () () LocalScope (Expl (ExtIdent (Right "bitfieldArray"))))) (Bracketed () (App (Var () () LocalScope (Expl (ExtIdent (Right "snd")))) (Var () () LocalScope (Expl (ExtIdent (Right "valueAndTime"))))) ())) ())) () (LetAnnot () () (ExtIdent (Right "bigTypeAnnot")) () (ForallTC [TV {unTV = 0}] (fromList [TypeClass {className = "addition", params = [TVar (TV {unTV = 0}), TVar (TV {unTV = 0}), TVar (TV {unTV = 0})]}, TypeClass {className = "numeric", params = [TVar (TV {unTV = 0})]}]) (ImplType (M.fromList [(ExtIdent (Right "now"), TBase TTime)]) (TArr (TArray (TTuple (TCons (TVar (TV {unTV = 0})) (TBase TTime) []))) (TArr (TBase TTime) (TOptional (TVar (TV {unTV = 0}))))))) () (Var () () LocalScope (Expl (ExtIdent (Right "bigThing")))) () (Let () () (Expl (ExtIdent (Right "bigThing"))) () (Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "ASuperLongVariableName"))), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "ASuperLongVariableNamet"))), Nothing) [(One () (App (Var () () LocalScope (Expl (ExtIdent (Right "snd")))) (App (Var () () LocalScope (Expl (ExtIdent (Right "snd")))) (Var () () LocalScope (Expl (ExtIdent (Right "ASuperLongVariableNametASuperLongVariableNametASuperLongVariableNametASuperLongVariableNametASuperLongVariableNametASuperLongVariableNamet")))))), Nothing), (Var () () LocalScope (Expl (ExtIdent (Right "ASuperLongVariableNamet"))), Nothing)]) ()) () (Lit () (LDouble 2.0))))))))))))))) showPretty ast \ No newline at end of file diff --git a/inferno-types/src/Inferno/Types/Syntax.hs b/inferno-types/src/Inferno/Types/Syntax.hs index 2cc8eab..aa6c2dd 100644 --- a/inferno-types/src/Inferno/Types/Syntax.hs +++ b/inferno-types/src/Inferno/Types/Syntax.hs @@ -160,13 +160,11 @@ import Prettyprinter hsep, indent, lbrace, - lbracket, line, line', lparen, nest, rbrace, - rbracket, rparen, sep, (<+>), @@ -1386,6 +1384,28 @@ instance Pretty (Import a) where ICommentAfter e c -> pretty e <+> pretty c ICommentBelow e c -> pretty e <> line <> pretty c +prettyContainer :: BlockUtils f => (t -> Doc ann1) -> (t -> f pos) -> Doc ann1 -> [t] -> (Doc ann1, Doc ann2) +prettyContainer prettyElem trailingElem sepr = + prettyElems True + where + prettyElems firstElement = \case + [] -> (mempty, mempty) + [x] -> + ( prettyElem x <> flatAlt sepr mempty, + if hasTrailingComment (trailingElem x) then hardline else flatAlt line mempty + ) + x : xs -> + (res, lastLine') + where + (xsPretty, lastLine') = prettyElems False xs + res = + (if not firstElement && hasLeadingComment (trailingElem x) then hardline else mempty) + <> prettyElem x + <> sepr + <> (if hasTrailingComment (trailingElem x) then hardline else line) + <> xsPretty + +-- TODO fix these instance Pretty (Pat hash a) where pretty = \case PVar _ (Just (Ident x)) -> pretty x @@ -1454,9 +1474,11 @@ prettyPrec isBracketed prec expr = body = group $ nest 2 $ line <> prettyPrec False 0 e in group $ fun <> body Let _ _ x _ e1 _ e2 -> - let e1Pretty = group $ nest 2 (line <> prettyPrec False 0 e1) <> (if hasTrailingComment e1 then hardline else line) - letPretty = group $ "let" <+> pretty x <+> "=" <> e1Pretty <> "in" - in group $ letPretty <> line <> prettyPrec False 0 e2 + group $ letPretty <> line <> prettyPrec False 0 e2 + where + letPretty = group $ "let" <+> pretty x <+> "=" <> e1Pretty <> "in" + e1Pretty = group $ nest 2 (line <> prettyPrec False 0 e1) <> e1End + e1End = if hasTrailingComment e1 then hardline else line LetAnnot _ _ x _ t _ e1 _ e2 -> let e1Pretty = group $ nest 2 (line <> prettyPrec False 0 e1) <> (if hasTrailingComment e1 then hardline else line) tPretty = group $ nest 2 (line <> pretty t) <> line @@ -1539,23 +1561,8 @@ prettyPrec isBracketed prec expr = Tuple _ xs _ -> group $ flatAlt "( " "(" <> nest 2 xsPretty <> lastLine <> ")" where - (xsPretty, lastLine) = prettyTuple True (tListToList xs) - prettyTuple firstElement = \case - [] -> (mempty, mempty) - [(e, _)] -> - ( prettyPrec False 0 e <> flatAlt "," "", - if hasTrailingComment e then hardline else flatAlt line mempty - ) - (e, _) : es -> - (res, lastLine') - where - (esPretty, lastLine') = prettyTuple False es - res = - (if not firstElement && hasLeadingComment e then line else mempty) - <> prettyPrec False 0 e - <> "," - <> (if hasTrailingComment e then hardline else line) - <> esPretty + (xsPretty, lastLine) = + prettyContainer (\(e, _) -> prettyPrec False 0 e) fst "," (tListToList xs) One _ e -> group $ nest 2 $ "Some" <> line <> prettyPrec False 0 e Empty _ -> "None" @@ -1566,118 +1573,81 @@ prettyPrec isBracketed prec expr = cPretty = group $ nest 2 (line <> prettyPrec False 0 c) <> cEnd cEnd = if hasTrailingComment c then hardline else line Case _ e_case _ patExprs _ -> - -- TODO lastLine before closing } - group $ prettyMatch <> prettyCases <> flatAlt " }" "}" + group $ prettyMatch <> group (nest 2 (flatAlt line mempty <> prettyCases)) <> lastLine <> "}" where prettyMatch = group $ "match" <> prettyE <> "with {" prettyE = group $ nest 2 (line <> prettyPrec False 0 e_case) <> eEnd eEnd = if hasTrailingComment e_case then hardline else line - prettyCases = group $ nest 2 (line <> prettyCase True (toList patExprs)) - prettyCase :: Bool -> [(a, Pat hash a, a, Expr hash a)] -> Doc ann - prettyCase firstElement = \case - [] -> mempty - [(_, pat, _, e)] -> - group - ( "|" - <+> align - ( pretty pat - <> (if hasTrailingComment pat then hardline else mempty) - <+> "->" - <> line - <> prettyPrec False 0 e - ) - ) - <> (if hasTrailingComment e then hardline else mempty) - (_, pat, _, e) : es -> - (if not firstElement && hasLeadingComment pat then hardline else mempty) - <> group ("|" <+> align (pretty pat <> (if hasTrailingComment pat then hardline else mempty) <+> "->" <> line <> prettyPrec False 0 e)) - <> (if hasTrailingComment e then hardline else line) - <> prettyCase False es + (prettyCases, lastLine) = + prettyContainer prettyPat (\(_, _, _, e) -> e) mempty (toList patExprs) + + prettyPat (_, pat, _, e) = + group $ + "|" -- TODO not on first elem + <+> align + ( pretty pat + <> (if hasTrailingComment pat then hardline else mempty) + <+> "->" + <> line + <> prettyPrec False 0 e + ) Record _ [] _ -> "{}" - Record _ xs _ -> group $ flatAlt "{ " "{" <> prettyRecord True xs + Record _ xs _ -> + group $ flatAlt "{ " "{" <> nest 2 xsPretty <> lastLine <> "}" where - prettyRecord firstElement = \case - [] -> mempty - [(Ident f, e, _)] -> - pretty f - <+> "=" - <+> align (prettyPrec False 0 e) - <> (if hasTrailingComment e then hardline <> "}" else flatAlt " }" "}") - (Ident f, e, _) : es -> - (if not firstElement && hasLeadingComment e then line else mempty) - <> pretty f - <+> "=" - <+> align (prettyPrec False 0 e) - <> (if hasTrailingComment e then hardline else line') - <> "; " - <> prettyRecord False es + (xsPretty, lastLine) = + prettyContainer prettyElem (\(_, e, _) -> e) ";" xs + prettyElem (Ident f, e, _) = + group $ pretty f <+> "=" <> group (nest 2 (line <> prettyPrec False 0 e)) RecordField _ (Ident r) (Ident f) -> pretty r <> "." <> pretty f Array _ [] _ -> "[]" - Array _ xs _ -> group $ flatAlt "[ " "[" <> prettyArray True xs + Array _ xs _ -> + group $ flatAlt "[ " "[" <> nest 2 xsPretty <> lastLine <> "]" where - prettyArray firstElement = \case - [] -> mempty - [(e, _)] -> - align (prettyPrec False 0 e) - <> (if hasTrailingComment e then hardline <> "]" else flatAlt " ]" "]") - (e, _) : es -> - (if not firstElement && hasLeadingComment e then line else mempty) - <> align (prettyPrec False 0 e) - <> (if hasTrailingComment e then hardline else line') - <> ", " - <> prettyArray False es + (xsPretty, lastLine) = + prettyContainer prettyElem fst "," xs + prettyElem (e, _) = align (prettyPrec False 0 e) ArrayComp _ e_body _ args e_cond _ -> - enclose lbracket rbracket $ - align $ - align (prettyPrec False 0 e_body <> if hasTrailingComment e_body then hardline else mempty) <+> align ("|" <+> argsPretty (toList args)) + group $ flatAlt "[ " "[" <> nest 2 bodyPretty <> bodyEnd <> "| " <> nest 2 argsPretty <> lastLine <> "]" where - argsPretty = \case - [] -> mempty - [(_, Ident n, _, e, _)] -> - pretty n - <+> "<-" - <+> align (prettyPrec False 0 e) - <> case e_cond of - Just (_, c) -> (if hasTrailingComment e then hardline else line') <> "," <+> "if" <+> align (prettyPrec False 0 c) <> (if hasTrailingComment c then hardline else mempty) - Nothing -> if hasTrailingComment e then hardline else mempty - (_, Ident n, _, e, _) : xs -> - pretty n - <+> "<-" - <+> align (prettyPrec False 0 e) - <> (if hasTrailingComment e then hardline else line') - <> ", " - <> argsPretty xs + bodyPretty = prettyPrec False 0 e_body + bodyEnd = if hasTrailingComment e_body then hardline else line + (argsPretty, lastLine) = + prettyContainer prettyElem trailingElem "," $ + -- Make all the args Left, and if there's a cond, add it as a Right to the end + map Left (toList args) ++ maybe [] (\x -> [Right x]) e_cond + prettyElem (Left (_, Ident n, _, e, _)) = + pretty n <+> "<-" <> group (nest 2 $ line <> prettyPrec False 0 e) + prettyElem (Right (_, c)) = + "if" <> group (nest 2 $ line <> prettyPrec False 0 c) + trailingElem (Left (_, _, _, e, _)) = e + trailingElem (Right (_, c)) = c CommentAbove c e -> pretty c <> hardline <> prettyPrec isBracketed prec e CommentAfter e c -> prettyPrec isBracketed prec e <+> pretty c CommentBelow e c -> prettyPrec isBracketed prec e <> line <> pretty c - Bracketed _ e _ -> enclose lparen rparen $ if hasTrailingComment e then prettyPrec True prec e <> hardline else prettyPrec True prec e + Bracketed _ e _ -> + group $ flatAlt "( " "(" <> nest 2 (prettyPrec True prec e) <> end <> ")" + where + end = if hasTrailingComment e then hardline else mempty RenameModule _ (ModuleName nNew) _ (ModuleName nOld) _ e -> - let letPretty = "let" <+> align ("module" <+> pretty nNew <+> "=" <+> pretty nOld) - body = flatAlt " in" "in" <+> align (prettyPrec False 0 e) - in letPretty <> line <> body + group $ letPretty <> line <> prettyPrec False 0 e + where + letPretty = group $ "let" <+> "module" <> mPretty <> line <> "in" + mPretty = group $ nest 2 $ line <> pretty nNew <+> "=" <+> pretty nOld OpenModule _ _ (ModuleName n) ns _ e -> - "open" - <+> pretty n - <> ( case ns of - [] -> line - _ -> align (group $ flatAlt "( " "(" <> prettyImports True (map fst ns)) <> (if hasTrailingComment $ fst (last ns) then hardline else line) - ) - <> flatAlt " in" "in" - <+> align (prettyPrec False 0 e) + group $ openPretty <> line <> prettyPrec False 0 e where - prettyImports firstElement = \case + openPretty = group $ "open" <+> pretty n <+> prettyImports <> iEnd + prettyImports = case ns of [] -> mempty - [i] -> - align (pretty i) - <> (if hasTrailingComment i then hardline <> ")" else flatAlt " )" ")") - i : is -> - (if not firstElement && hasLeadingComment i then line else mempty) - <> align (pretty i) - <> (if hasTrailingComment i then hardline else line') - <> ", " - <> prettyImports False is + _ -> "(" <> nest 2 (flatAlt line mempty <> nsPretty) <> lastLine + (nsPretty, lastLine) = + prettyContainer pretty id "," $ map fst ns + iEnd = case ns of + [] -> "in" + _ -> ") in" where indentE e = flatAlt (indent 2 e) e From a9246262762045be9965cb90287c539598c051af Mon Sep 17 00:00:00 2001 From: Siddharth Krishna Date: Mon, 1 Apr 2024 11:15:09 +0200 Subject: [PATCH 07/16] Allow trailing commas in ArrayComp and OpenMod --- inferno-core/src/Inferno/Parse.hs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/inferno-core/src/Inferno/Parse.hs b/inferno-core/src/Inferno/Parse.hs index de8d68c..ac78331 100644 --- a/inferno-core/src/Inferno/Parse.hs +++ b/inferno-core/src/Inferno/Parse.hs @@ -310,6 +310,7 @@ arrayComprE = label "array builder\nfor example: [n * 2 + 1 | n <- range 0 10, i symbol "|" (sels, cond) <- rhsE endPos <- getSourcePos + _ <- optional $ symbol "," char ']' return $ ArrayComp startPos e midPos (NEList.fromList sels) cond endPos where @@ -448,6 +449,7 @@ openModArgs :: ModuleName -> Parser ([(Import SourcePos, Maybe SourcePos)], Sour openModArgs modNm = do symbol "(" is <- go + _ <- optional $ symbol "," symbol ")" (opsTable, modOpsTables, customTypes) <- ask opsTable' <- From 9d1942d60a4be46d2b71fb197fa909a8becdc923 Mon Sep 17 00:00:00 2001 From: Siddharth Krishna Date: Mon, 1 Apr 2024 11:15:27 +0200 Subject: [PATCH 08/16] Switch back to comma-first style of lists/tuples/etc --- inferno-types/src/Inferno/Types/Syntax.hs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/inferno-types/src/Inferno/Types/Syntax.hs b/inferno-types/src/Inferno/Types/Syntax.hs index aa6c2dd..3bd2ba9 100644 --- a/inferno-types/src/Inferno/Types/Syntax.hs +++ b/inferno-types/src/Inferno/Types/Syntax.hs @@ -1386,12 +1386,13 @@ instance Pretty (Import a) where prettyContainer :: BlockUtils f => (t -> Doc ann1) -> (t -> f pos) -> Doc ann1 -> [t] -> (Doc ann1, Doc ann2) prettyContainer prettyElem trailingElem sepr = + -- TODO endBracket? prettyElems True where prettyElems firstElement = \case [] -> (mempty, mempty) [x] -> - ( prettyElem x <> flatAlt sepr mempty, + ( prettyElem x, if hasTrailingComment (trailingElem x) then hardline else flatAlt line mempty ) x : xs -> @@ -1401,9 +1402,9 @@ prettyContainer prettyElem trailingElem sepr = res = (if not firstElement && hasLeadingComment (trailingElem x) then hardline else mempty) <> prettyElem x + <> (if hasTrailingComment (trailingElem x) then hardline else line') <> sepr - <> (if hasTrailingComment (trailingElem x) then hardline else line) - <> xsPretty + <+> xsPretty -- TODO fix these instance Pretty (Pat hash a) where @@ -1559,7 +1560,7 @@ prettyPrec isBracketed prec expr = <> prettyOpAux (n + 1) e Tuple _ TNil _ -> "()" Tuple _ xs _ -> - group $ flatAlt "( " "(" <> nest 2 xsPretty <> lastLine <> ")" + group $ flatAlt "( " "(" <> xsPretty <> lastLine <> ")" where (xsPretty, lastLine) = prettyContainer (\(e, _) -> prettyPrec False 0 e) fst "," (tListToList xs) @@ -1594,7 +1595,7 @@ prettyPrec isBracketed prec expr = ) Record _ [] _ -> "{}" Record _ xs _ -> - group $ flatAlt "{ " "{" <> nest 2 xsPretty <> lastLine <> "}" + group $ flatAlt "{ " "{" <> xsPretty <> lastLine <> "}" where (xsPretty, lastLine) = prettyContainer prettyElem (\(_, e, _) -> e) ";" xs @@ -1604,13 +1605,13 @@ prettyPrec isBracketed prec expr = pretty r <> "." <> pretty f Array _ [] _ -> "[]" Array _ xs _ -> - group $ flatAlt "[ " "[" <> nest 2 xsPretty <> lastLine <> "]" + group $ flatAlt "[ " "[" <> xsPretty <> lastLine <> "]" where (xsPretty, lastLine) = prettyContainer prettyElem fst "," xs prettyElem (e, _) = align (prettyPrec False 0 e) ArrayComp _ e_body _ args e_cond _ -> - group $ flatAlt "[ " "[" <> nest 2 bodyPretty <> bodyEnd <> "| " <> nest 2 argsPretty <> lastLine <> "]" + group $ flatAlt "[ " "[" <> nest 2 bodyPretty <> bodyEnd <> "| " <> argsPretty <> lastLine <> "]" where bodyPretty = prettyPrec False 0 e_body bodyEnd = if hasTrailingComment e_body then hardline else line From 6eb82e7574aa62561daf6ab62f40d09e48ea24f4 Mon Sep 17 00:00:00 2001 From: Siddharth Krishna Date: Mon, 1 Apr 2024 11:15:57 +0200 Subject: [PATCH 09/16] CLI: print expr with comments; pretty print also --- inferno-core/app/Main.hs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/inferno-core/app/Main.hs b/inferno-core/app/Main.hs index 6734a9a..60f0f67 100644 --- a/inferno-core/app/Main.hs +++ b/inferno-core/app/Main.hs @@ -4,7 +4,7 @@ module Main where -import Data.Bifunctor (bimap) +import Data.Bifunctor (bimap, second) import qualified Data.Map as Map import qualified Data.Text.IO as Text import Inferno.Eval (runEvalM) @@ -12,6 +12,7 @@ import Inferno.Infer (inferExpr) import Inferno.Infer.Pinned (pinExpr) import Inferno.Module.Prelude (baseOpsTable, builtinModules, builtinModulesOpsTable, builtinModulesPinMap, builtinModulesTerms) import Inferno.Parse (parseExpr) +import Inferno.Parse.Commented (insertCommentsIntoExpr) import Inferno.Types.VersionControl (pinnedToMaybe) import Inferno.Utils.Prettyprinter (showPretty) import Options.Applicative @@ -66,8 +67,11 @@ main = do Right (ast, _comments) -> if parse args then do + let ast' = insertCommentsIntoExpr _comments ast putStrLn "Parsed Expr:" - print $ bimap id (const ()) ast + print $ second (const ()) ast' + putStrLn "Pretty:" + showPretty ast' else do -- pin free variables to builtin prelude function hashes case pinExpr (builtinModulesPinMap prelude) ast of From 4463a7ef1590c9dd319cb3f7cebc7e84e4b13b30 Mon Sep 17 00:00:00 2001 From: Siddharth Krishna Date: Mon, 1 Apr 2024 11:45:13 +0200 Subject: [PATCH 10/16] Fix Case and OpenModule --- inferno-types/src/Inferno/Types/Syntax.hs | 24 ++++++++++------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/inferno-types/src/Inferno/Types/Syntax.hs b/inferno-types/src/Inferno/Types/Syntax.hs index 3bd2ba9..36a5130 100644 --- a/inferno-types/src/Inferno/Types/Syntax.hs +++ b/inferno-types/src/Inferno/Types/Syntax.hs @@ -1574,25 +1574,21 @@ prettyPrec isBracketed prec expr = cPretty = group $ nest 2 (line <> prettyPrec False 0 c) <> cEnd cEnd = if hasTrailingComment c then hardline else line Case _ e_case _ patExprs _ -> - group $ prettyMatch <> group (nest 2 (flatAlt line mempty <> prettyCases)) <> lastLine <> "}" + group $ prettyMatch <> group (nest 2 (flatAlt (line <> "| ") mempty <> prettyCases)) <> lastLine <> "}" where prettyMatch = group $ "match" <> prettyE <> "with {" prettyE = group $ nest 2 (line <> prettyPrec False 0 e_case) <> eEnd eEnd = if hasTrailingComment e_case then hardline else line (prettyCases, lastLine) = - prettyContainer prettyPat (\(_, _, _, e) -> e) mempty (toList patExprs) + prettyContainer prettyPat (\(_, _, _, e) -> e) (flatAlt "|" " |") (toList patExprs) prettyPat (_, pat, _, e) = group $ - "|" -- TODO not on first elem - <+> align - ( pretty pat - <> (if hasTrailingComment pat then hardline else mempty) - <+> "->" - <> line - <> prettyPrec False 0 e - ) + nest 2 (pretty pat) + <> (if hasTrailingComment pat then hardline else flatAlt line " ") + <> "->" + <> nest 2 (line <> prettyPrec False 0 e) Record _ [] _ -> "{}" Record _ xs _ -> group $ flatAlt "{ " "{" <> xsPretty <> lastLine <> "}" @@ -1640,15 +1636,15 @@ prettyPrec isBracketed prec expr = OpenModule _ _ (ModuleName n) ns _ e -> group $ openPretty <> line <> prettyPrec False 0 e where - openPretty = group $ "open" <+> pretty n <+> prettyImports <> iEnd + openPretty = group $ "open" <+> pretty n <> prettyImports <> iEnd prettyImports = case ns of [] -> mempty - _ -> "(" <> nest 2 (flatAlt line mempty <> nsPretty) <> lastLine + _ -> nest 2 $ flatAlt line " " <> "(" <> flatAlt " " mempty <> nsPretty <> lastLine <> ")" (nsPretty, lastLine) = prettyContainer pretty id "," $ map fst ns iEnd = case ns of - [] -> "in" - _ -> ") in" + [] -> " in" + _ -> line <> "in" where indentE e = flatAlt (indent 2 e) e From 0d1d2aaf3480b1c0de10dfdcc38aeb6bcef7bc54 Mon Sep 17 00:00:00 2001 From: Siddharth Krishna Date: Mon, 1 Apr 2024 12:03:19 +0200 Subject: [PATCH 11/16] Fix NonExhaustive error pretty print --- inferno-core/src/Inferno/Infer/Exhaustiveness.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inferno-core/src/Inferno/Infer/Exhaustiveness.hs b/inferno-core/src/Inferno/Infer/Exhaustiveness.hs index 6c44181..782e835 100644 --- a/inferno-core/src/Inferno/Infer/Exhaustiveness.hs +++ b/inferno-core/src/Inferno/Infer/Exhaustiveness.hs @@ -59,8 +59,8 @@ instance Ord Con where compare a b = compare (mkOrd a) (mkOrd b) where mkOrd = \case - COne -> "one" - CEmpty -> "empty" + COne -> "Some" + CEmpty -> "None" CTuple n -> show n CInf v -> show v CEnum _ e -> show e From 041179645bd23f72b6fc849e60c4c7236ca6e779 Mon Sep 17 00:00:00 2001 From: Siddharth Krishna Date: Mon, 1 Apr 2024 12:03:59 +0200 Subject: [PATCH 12/16] Fix Case some more --- inferno-types/src/Inferno/Types/Syntax.hs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/inferno-types/src/Inferno/Types/Syntax.hs b/inferno-types/src/Inferno/Types/Syntax.hs index 8cc3d65..6b2a5cc 100644 --- a/inferno-types/src/Inferno/Types/Syntax.hs +++ b/inferno-types/src/Inferno/Types/Syntax.hs @@ -1606,8 +1606,7 @@ prettyPrec isBracketed prec expr = prettyPat (_, pat, _, e) = group $ - nest 2 (pretty pat) - <> (if hasTrailingComment pat then hardline else flatAlt line " ") + group (nest 2 (pretty pat) <> (if hasTrailingComment pat then hardline else flatAlt line " ")) <> "->" <> nest 2 (line <> prettyPrec False 0 e) Record _ [] _ -> "{}" From efe08349c4584a93ca113818cd8b49dd01cc17c9 Mon Sep 17 00:00:00 2001 From: Siddharth Krishna Date: Mon, 1 Apr 2024 12:08:42 +0200 Subject: [PATCH 13/16] Update pretty-test --- inferno-types/pretty-test/Main.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inferno-types/pretty-test/Main.hs b/inferno-types/pretty-test/Main.hs index c8a5210..b96fdfc 100644 --- a/inferno-types/pretty-test/Main.hs +++ b/inferno-types/pretty-test/Main.hs @@ -14,6 +14,6 @@ import Inferno.Utils.Prettyprinter (showPretty) main :: IO () main = do let ast :: Expr () () = - Let () () (Expl (ExtIdent (Right "bigApp"))) () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig")))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) () (Let () () (Expl (ExtIdent (Right "null"))) () (Tuple () TNil ()) () (Let () () (Expl (ExtIdent (Right "smallTup"))) () (Tuple () (TCons (Lit () (LInt 12314314), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "fadsfdfsadfa"))), Just ()) [(Lit () (LInt 13413241345), Nothing)]) ()) () (Let () () (Expl (ExtIdent (Right "mediumTup"))) () (Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()) [(Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "mediu"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "mediu"))), Nothing)]) ()) () (Let () () (Expl (ExtIdent (Right "bigTup"))) () (Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))), Just ()) [(Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))), Just ()), (One () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig")))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))), Nothing)]) ()) () (Assert () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "thing"))))) (Var () () LocalScope (Expl (ExtIdent (Right "small"))))) () (Assert () (App (App (App (App (App (App (App (App (App (App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "thing"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) () (Assert () (App (App (App (App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "thing"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) () (Let () () (Expl (ExtIdent (Right "x"))) () (Case () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "thing"))))) (Var () () LocalScope (Expl (ExtIdent (Right "small"))))) () (((), PLit () (LInt 1), (), Lit () (LInt 2)) :| [((), PVar () Nothing, (), Lit () (LInt 3))]) ()) () (Let () () (Expl (ExtIdent (Right "x"))) () (Case () (App (App (App (App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "thing"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) () (((), PTuple () (TCons (PVar () (Just (Ident {unIdent = "biggbig"})), Just ()) (PVar () (Just (Ident {unIdent = "bigbigbig"})), Just ()) [(PVar () (Just (Ident {unIdent = "bigbigbigbig"})), Just ()), (PVar () (Just (Ident {unIdent = "bigbigbigbigbig"})), Just ()), (PVar () (Just (Ident {unIdent = "bigbigbigbigbigbigbig"})), Just ()), (PVar () (Just (Ident {unIdent = "bigbigbigbigbigbigbigbigbig"})), Nothing)]) (), (), Lit () (LInt 2)) :| [((), PVar () Nothing, (), Lit () (LInt 3))]) ()) () (Let () () (Expl (ExtIdent (Right "smallRec"))) () (Record () [(Ident {unIdent = "height"}, Lit () (LInt 2), Just ()), (Ident {unIdent = "weight"}, Tuple () (TCons (Lit () (LDouble 3.54), Just ()) (Lit () (LText "kgs"), Nothing) []) (), Nothing)] ()) () (Let () () (Expl (ExtIdent (Right "bigRec"))) () (Record () [(Ident {unIdent = "height"}, Tuple () (TCons (Lit () (LInt 12314314), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "fadsfdfsadfa"))), Just ()) [(Lit () (LInt 13413241345), Nothing)]) (), Just ()), (Ident {unIdent = "weight"}, Tuple () (TCons (Lit () (LDouble 3.54), Just ()) (Lit () (LText "kgs"), Nothing) []) (), Just ()), (Ident {unIdent = "name"}, Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "biggbig"))), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbig"))), Just ()) [(Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbig"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbig"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbig"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbig"))), Nothing)]) (), Nothing)] ()) () (Let () () (Expl (ExtIdent (Right "smallArr"))) () (Array () [(Lit () (LInt 12314314), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "fadsfdfsadfa"))), Just ()), (Lit () (LInt 13413241345), Just ())] ()) () (Let () () (Expl (ExtIdent (Right "mediumArr"))) () (Array () [(Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "mediu"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "mediu"))), Nothing)] ()) () (Let () () (Expl (ExtIdent (Right "bigArr"))) () (Array () [(Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))), Just ()), (One () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig")))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))), Nothing)] ()) () (Let () () (Expl (ExtIdent (Right "arrayComp"))) () (ArrayComp () (App (App (App (App (Var () () LocalScope (Expl (ExtIdent (Right "bigFun")))) (Var () () LocalScope (Expl (ExtIdent (Right "one"))))) (Var () () LocalScope (Expl (ExtIdent (Right "two"))))) (Var () () LocalScope (Expl (ExtIdent (Right "three"))))) (Var () () LocalScope (Expl (ExtIdent (Right "four"))))) () (((), Ident {unIdent = "one"}, (), App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "thing")))), Just ()) :| []) (Just ((), App (Var () () LocalScope (Expl (ExtIdent (Right "one")))) (Var () () LocalScope (Expl (ExtIdent (Right "two")))))) ()) () (Let () () (Expl (ExtIdent (Right "arrayComp"))) () (ArrayComp () (App (App (App (App (App (App (Var () () LocalScope (Expl (ExtIdent (Right "getBitValAndTime")))) (Var () () LocalScope (Expl (ExtIdent (Right "t"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) () (((), Ident {unIdent = "t"}, (), App (App (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "intervalEvery")))) (Bracketed () (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "seconds")))) (Var () () LocalScope (Expl (ExtIdent (Right "intervalStep"))))) ())) (Var () () LocalScope (Expl (ExtIdent (Right "startOfInterval"))))) (Var () () LocalScope (Impl (ExtIdent (Right "now")))), Just ()) :| [((), Ident {unIdent = "one"}, (), App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "thing")))), Just ()), ((), Ident {unIdent = "two"}, (), App (App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "other"))))) (Var () () LocalScope (Expl (ExtIdent (Right "thing")))), Just ()), ((), Ident {unIdent = "three"}, (), One () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig")))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))), Just ())]) (Just ((), Bracketed () (App (App (App (App (Var () () LocalScope (Expl (ExtIdent (Right "one")))) (Var () () LocalScope (Expl (ExtIdent (Right "two"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) ())) ()) () (RenameModule () (ModuleName {unModuleName = "mSmall"}) () (ModuleName {unModuleName = "Number"}) () (RenameModule () (ModuleName {unModuleName = "bigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbig"}) () (ModuleName {unModuleName = "Array"}) () (OpenModule () () (ModuleName {unModuleName = "Array"}) [] () (OpenModule () () (ModuleName {unModuleName = "Array"}) [(IVar () (Ident {unIdent = "foo"}), Just ()), (IVar () (Ident {unIdent = "bar"}), Just ()), (IVar () (Ident {unIdent = "baz"}), Just ()), (IVar () (Ident {unIdent = "bar"}), Just ()), (IVar () (Ident {unIdent = "baz"}), Just ()), (IVar () (Ident {unIdent = "bar"}), Just ()), (IVar () (Ident {unIdent = "baz"}), Nothing)] () (OpenModule () () (ModuleName {unModuleName = "Array"}) [(IVar () (Ident {unIdent = "foo"}), Just ()), (IVar () (Ident {unIdent = "bar"}), Just ()), (IVar () (Ident {unIdent = "baz"}), Just ()), (IVar () (Ident {unIdent = "bar"}), Just ()), (IVar () (Ident {unIdent = "baz"}), Just ()), (IVar () (Ident {unIdent = "bar"}), Just ()), (IVar () (Ident {unIdent = "baz"}), Just ()), (IVar () (Ident {unIdent = "bar"}), Just ()), (IVar () (Ident {unIdent = "baz"}), Just ()), (IVar () (Ident {unIdent = "bar"}), Just ()), (IVar () (Ident {unIdent = "baz"}), Just ()), (IVar () (Ident {unIdent = "bar"}), Just ()), (IVar () (Ident {unIdent = "baz"}), Just ()), (IVar () (Ident {unIdent = "bar"}), Just ()), (IVar () (Ident {unIdent = "baz"}), Just ()), (IVar () (Ident {unIdent = "bar"}), Just ()), (IVar () (Ident {unIdent = "baz"}), Just ()), (IVar () (Ident {unIdent = "bar"}), Just ()), (IVar () (Ident {unIdent = "baz"}), Nothing)] () (Lit () (LDouble 1.1))))))))))))))))))))))) + Let () () (Expl (ExtIdent (Right "bigApp"))) () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig")))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) () (Let () () (Expl (ExtIdent (Right "null"))) () (Tuple () TNil ()) () (Let () () (Expl (ExtIdent (Right "smallTup"))) () (Tuple () (TCons (Lit () (LInt 12314314),Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "fadsfdfsadfa"))),Just ()) [(Lit () (LInt 13413241345),Nothing)]) ()) () (Let () () (Expl (ExtIdent (Right "mediumTup"))) () (Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()) [(Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "mediu"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "mediu"))),Nothing)]) ()) () (Let () () (Expl (ExtIdent (Right "bigTup"))) () (Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))),Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))),Just ()) [(Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))),Just ()),(One () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig")))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))),Nothing)]) ()) () (Assert () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "thing"))))) (Var () () LocalScope (Expl (ExtIdent (Right "small"))))) () (Assert () (App (App (App (App (App (App (App (App (App (App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "thing"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) () (Assert () (App (App (App (App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "thing"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) () (Let () () (Expl (ExtIdent (Right "x"))) () (Case () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "thing"))))) (Var () () LocalScope (Expl (ExtIdent (Right "small"))))) () (((),PLit () (LInt 1),(),Lit () (LInt 2)) :| [((),PVar () Nothing,(),Lit () (LInt 3))]) ()) () (Let () () (Expl (ExtIdent (Right "x"))) () (Case () (App (App (App (App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "thing"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) () (((),PTuple () (TCons (PVar () (Just (Ident {unIdent = "biggbig"})),Just ()) (PVar () (Just (Ident {unIdent = "bigbigbig"})),Just ()) [(PVar () (Just (Ident {unIdent = "bigbigbigbig"})),Just ()),(PVar () (Just (Ident {unIdent = "bigbigbigbigbig"})),Just ()),(PVar () (Just (Ident {unIdent = "bigbigbigbigbigbigbig"})),Just ()),(PVar () (Just (Ident {unIdent = "bigbigbigbigbigbigbigbigbig"})),Nothing)]) (),(),Lit () (LInt 2)) :| [((),PVar () (Just (Ident {unIdent = "xyz"})),(),Lit () (LInt 3)),((),PVar () Nothing,(),Lit () (LInt 4))]) ()) () (Let () () (Expl (ExtIdent (Right "smallRec"))) () (Record () [(Ident {unIdent = "height"},Lit () (LInt 2),Just ()),(Ident {unIdent = "weight"},Tuple () (TCons (Lit () (LDouble 3.54),Just ()) (Lit () (LText "kgs"),Nothing) []) (),Nothing)] ()) () (Let () () (Expl (ExtIdent (Right "bigRec"))) () (Record () [(Ident {unIdent = "expr"},Let () () (Expl (ExtIdent (Right "x"))) () (Lit () (LInt 2)) () (Op (Var () () LocalScope (Expl (ExtIdent (Right "x")))) () () (9,LeftFix) LocalScope (Ident {unIdent = "+"}) (Lit () (LInt 1))),Just ()),(Ident {unIdent = "height"},Tuple () (TCons (Lit () (LInt 12314314),Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "fadsfdfsadfa"))),Just ()) [(Lit () (LInt 13413241345),Nothing)]) (),Just ()),(Ident {unIdent = "weight"},Tuple () (TCons (Lit () (LDouble 3.54),Just ()) (Lit () (LText "kgs"),Nothing) []) (),Just ()),(Ident {unIdent = "name"},Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "biggbig"))),Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbig"))),Just ()) [(Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbig"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbig"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbig"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbig"))),Nothing)]) (),Nothing)] ()) () (Let () () (Expl (ExtIdent (Right "smallArr"))) () (Array () [(Lit () (LInt 12314314),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "fadsfdfsadfa"))),Just ()),(Lit () (LInt 13413241345),Just ())] ()) () (Let () () (Expl (ExtIdent (Right "mediumArr"))) () (Array () [(Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "mediu"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "mediu"))),Nothing)] ()) () (Let () () (Expl (ExtIdent (Right "bigArr"))) () (Array () [(Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))),Just ()),(One () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig")))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))),Nothing)] ()) () (Let () () (Expl (ExtIdent (Right "arrayComp"))) () (ArrayComp () (App (App (App (App (Var () () LocalScope (Expl (ExtIdent (Right "bigFun")))) (Var () () LocalScope (Expl (ExtIdent (Right "one"))))) (Var () () LocalScope (Expl (ExtIdent (Right "two"))))) (Var () () LocalScope (Expl (ExtIdent (Right "three"))))) (Var () () LocalScope (Expl (ExtIdent (Right "four"))))) () (((),Ident {unIdent = "one"},(),App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "thing")))),Just ()) :| []) (Just ((),App (Var () () LocalScope (Expl (ExtIdent (Right "one")))) (Var () () LocalScope (Expl (ExtIdent (Right "two")))))) ()) () (Let () () (Expl (ExtIdent (Right "arrayComp"))) () (ArrayComp () (App (App (App (App (App (App (Var () () LocalScope (Expl (ExtIdent (Right "getBitValAndTime")))) (Var () () LocalScope (Expl (ExtIdent (Right "t"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) () (((),Ident {unIdent = "t"},(),App (App (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "intervalEvery")))) (Bracketed () (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "seconds")))) (Var () () LocalScope (Expl (ExtIdent (Right "intervalStep"))))) ())) (Var () () LocalScope (Expl (ExtIdent (Right "startOfInterval"))))) (Var () () LocalScope (Impl (ExtIdent (Right "now")))),Just ()) :| [((),Ident {unIdent = "one"},(),App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "thing")))),Just ()),((),Ident {unIdent = "two"},(),App (App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "other"))))) (Var () () LocalScope (Expl (ExtIdent (Right "thing")))),Just ()),((),Ident {unIdent = "three"},(),One () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig")))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))),Just ())]) (Just ((),Bracketed () (App (App (App (App (Var () () LocalScope (Expl (ExtIdent (Right "one")))) (Var () () LocalScope (Expl (ExtIdent (Right "two"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) ())) ()) () (RenameModule () (ModuleName {unModuleName = "mSmall"}) () (ModuleName {unModuleName = "Number"}) () (RenameModule () (ModuleName {unModuleName = "bigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbig"}) () (ModuleName {unModuleName = "Array"}) () (OpenModule () () (ModuleName {unModuleName = "Array"}) [] () (OpenModule () () (ModuleName {unModuleName = "Array"}) [(IVar () (Ident {unIdent = "foo"}),Just ()),(IVar () (Ident {unIdent = "bar"}),Just ()),(IVar () (Ident {unIdent = "baz"}),Just ()),(IVar () (Ident {unIdent = "bar"}),Just ()),(IVar () (Ident {unIdent = "baz"}),Just ()),(IVar () (Ident {unIdent = "bar"}),Just ()),(IVar () (Ident {unIdent = "baz"}),Nothing)] () (OpenModule () () (ModuleName {unModuleName = "Array"}) [(IVar () (Ident {unIdent = "foo"}),Just ()),(IVar () (Ident {unIdent = "bar"}),Just ()),(IVar () (Ident {unIdent = "baz"}),Just ()),(IVar () (Ident {unIdent = "bar"}),Just ()),(IVar () (Ident {unIdent = "baz"}),Just ()),(IVar () (Ident {unIdent = "bar"}),Just ()),(IVar () (Ident {unIdent = "baz"}),Just ()),(IVar () (Ident {unIdent = "bar"}),Just ()),(IVar () (Ident {unIdent = "baz"}),Just ()),(IVar () (Ident {unIdent = "bar"}),Just ()),(IVar () (Ident {unIdent = "baz"}),Just ()),(IVar () (Ident {unIdent = "bar"}),Just ()),(IVar () (Ident {unIdent = "baz"}),Just ()),(IVar () (Ident {unIdent = "bar"}),Just ()),(IVar () (Ident {unIdent = "baz"}),Just ()),(IVar () (Ident {unIdent = "bar"}),Just ()),(IVar () (Ident {unIdent = "baz"}),Just ()),(IVar () (Ident {unIdent = "bar"}),Just ()),(IVar () (Ident {unIdent = "baz"}),Nothing)] () (Let () () (Expl (ExtIdent (Right "nested"))) () (One () (One () (One () (One () (One () (One () (One () (One () (One () (One () (One () (One () (One () (One () (One () (One () (One () (One () (One () (One () (Var () () LocalScope (Expl (ExtIdent (Right "bla")))))))))))))))))))))))) () (Lit () (LDouble 2.0)))))))))))))))))))))))) -- Let () () (Impl (ExtIdent (Right "resolution"))) () (App (Var () () LocalScope (Expl (ExtIdent (Right "toResolution")))) (Lit () (LInt 64))) () (LetAnnot () () (ExtIdent (Right "latestBeforeWithArray")) () (ForallTC [TV {unTV = 0}] (fromList []) (ImplType (M.fromList []) (TArr (TArray (TTuple (TCons (TVar (TV {unTV = 0})) (TBase TTime) []))) (TArr (TBase TTime) (TOptional (TVar (TV {unTV = 0}))))))) () (Lam () (((), Just (ExtIdent (Right "arr"))) :| [((), Just (ExtIdent (Right "t")))]) () (Let () () (Expl (ExtIdent (Right "compareTimes"))) () (Lam () (((), Just (ExtIdent (Right "targetTime"))) :| [((), Just (ExtIdent (Right "testValAndTime"))), ((), Just (ExtIdent (Right "lastValAndTime")))]) () (If () (Op (Var () () LocalScope (Expl (ExtIdent (Right "targetTime")))) () () (7, NoFix) LocalScope (Ident {unIdent = "<"}) (Bracketed () (App (Var () () LocalScope (Expl (ExtIdent (Right "snd")))) (Var () () LocalScope (Expl (ExtIdent (Right "testValAndTime"))))) ())) () (Var () () LocalScope (Expl (ExtIdent (Right "lastValAndTime")))) () (Var () () LocalScope (Expl (ExtIdent (Right "testValAndTime")))))) () (Let () () (Expl (ExtIdent (Right "subValues"))) () (Lam () (((), Just (ExtIdent (Right "lastValAndTime"))) :| [((), Just (ExtIdent (Right "testValAndTime")))]) () (Case () (Var () () LocalScope (Expl (ExtIdent (Right "lastValAndTime")))) () (((), PEmpty (), (), If () (Op (Var () () LocalScope (Expl (ExtIdent (Right "t")))) () () (7, NoFix) LocalScope (Ident {unIdent = "<"}) (Bracketed () (App (Var () () LocalScope (Expl (ExtIdent (Right "snd")))) (Var () () LocalScope (Expl (ExtIdent (Right "testValAndTime"))))) ())) () (Empty ()) () (Bracketed () (One () (Var () () LocalScope (Expl (ExtIdent (Right "testValAndTime"))))) ())) :| [((), POne () (PVar () (Just (Ident {unIdent = "ltv"}))), (), One () (Bracketed () (App (App (App (Var () () LocalScope (Expl (ExtIdent (Right "compareTimes")))) (Var () () LocalScope (Expl (ExtIdent (Right "t"))))) (Var () () LocalScope (Expl (ExtIdent (Right "testValAndTime"))))) (Var () () LocalScope (Expl (ExtIdent (Right "ltv"))))) ()))]) ())) () (Bracketed () (App (App (Var () () (Scope (ModuleName {unModuleName = "Option"})) (Expl (ExtIdent (Right "map")))) (Var () () LocalScope (Expl (ExtIdent (Right "fst"))))) (Bracketed () (App (App (App (Var () () (Scope (ModuleName {unModuleName = "Array"})) (Expl (ExtIdent (Right "reduce")))) (Var () () LocalScope (Expl (ExtIdent (Right "subValues"))))) (Empty ())) (Var () () LocalScope (Expl (ExtIdent (Right "arr"))))) ())) ())))) () (Let () () (Expl (ExtIdent (Right "intervalStep"))) () (Bracketed () (App (Var () () LocalScope (Expl (ExtIdent (Right "resolutionToInt")))) (Var () () LocalScope (Impl (ExtIdent (Right "resolution"))))) ()) () (Let () () (Expl (ExtIdent (Right "startOfInterval"))) () (Bracketed () (Op (Var () () LocalScope (Impl (ExtIdent (Right "now")))) () () (9, LeftFix) LocalScope (Ident {unIdent = "-"}) (Bracketed () (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "hours")))) (Lit () (LInt 24))) ())) ()) () (LetAnnot () () (ExtIdent (Right "valueBeforeInterval")) () (ForallTC [] (fromList []) (ImplType (M.fromList []) (TBase TDouble))) () (App (App (App (Var () () (Scope (ModuleName {unModuleName = "Option"})) (Expl (ExtIdent (Right "reduce")))) (Var () () LocalScope (Expl (ExtIdent (Right "id"))))) (Lit () (LDouble 0.0))) (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "latestValueBefore")))) (Var () () LocalScope (Expl (ExtIdent (Right "startOfInterval"))))) (Var () () LocalScope (Expl (ExtIdent (Right "power"))))) ())) () (LetAnnot () () (ExtIdent (Right "bitfieldBeforeInterval")) () (ForallTC [] (fromList []) (ImplType (M.fromList []) (TBase TDouble))) () (App (App (App (Var () () (Scope (ModuleName {unModuleName = "Option"})) (Expl (ExtIdent (Right "reduce")))) (Var () () LocalScope (Expl (ExtIdent (Right "id"))))) (Lit () (LDouble 0.0))) (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "latestValueBefore")))) (Var () () LocalScope (Expl (ExtIdent (Right "startOfInterval"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bitParam"))))) ())) () (LetAnnot () () (ExtIdent (Right "allValuesDuringInterval")) () (ForallTC [] (fromList []) (ImplType (M.fromList []) (TArray (TTuple (TCons (TOptional (TBase TDouble)) (TBase TTime) []))))) () (ArrayComp () (Tuple () (TCons (App (App (Var () () LocalScope (Expl (ExtIdent (Right "valueAtOrAdjacent")))) (Var () () LocalScope (Expl (ExtIdent (Right "power"))))) (Var () () LocalScope (Expl (ExtIdent (Right "t")))), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "t"))), Nothing) []) ()) () (((), Ident {unIdent = "t"}, (), App (App (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "intervalEvery")))) (Bracketed () (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "seconds")))) (Var () () LocalScope (Expl (ExtIdent (Right "intervalStep"))))) ())) (Var () () LocalScope (Expl (ExtIdent (Right "startOfInterval"))))) (Var () () LocalScope (Impl (ExtIdent (Right "now")))), Nothing) :| []) Nothing ()) () (LetAnnot () () (ExtIdent (Right "bitfieldArray")) () (ForallTC [] (fromList []) (ImplType (M.fromList []) (TArray (TTuple (TCons (TBase TDouble) (TBase TTime) []))))) () (Let () () (Impl (ExtIdent (Right "resolution"))) () (App (Var () () LocalScope (Expl (ExtIdent (Right "toResolution")))) (Lit () (LInt 1))) () (App (Var () () (Scope (ModuleName {unModuleName = "Array"})) (Expl (ExtIdent (Right "keepSomes")))) (ArrayComp () (App (App (Var () () (Scope (ModuleName {unModuleName = "Option"})) (Expl (ExtIdent (Right "map")))) (Bracketed () (Lam () (((), Just (ExtIdent (Right "v"))) :| []) () (Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "v"))), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "t"))), Nothing) []) ())) ())) (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "valueAt")))) (Var () () LocalScope (Expl (ExtIdent (Right "bitParam"))))) (Var () () LocalScope (Expl (ExtIdent (Right "t"))))) ())) () (((), Ident {unIdent = "t"}, (), App (App (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "intervalEvery")))) (Bracketed () (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "seconds")))) (Lit () (LInt 1))) ())) (Bracketed () (Op (Var () () LocalScope (Impl (ExtIdent (Right "now")))) () () (9, LeftFix) LocalScope (Ident {unIdent = "-"}) (Bracketed () (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "hours")))) (Lit () (LInt 24))) ())) ())) (Var () () LocalScope (Impl (ExtIdent (Right "now")))), Nothing) :| []) Nothing ()))) () (Let () () (Expl (ExtIdent (Right "inPrimaryDischarge"))) () (Lam () (((), Just (ExtIdent (Right "word"))) :| []) () (If () (Bracketed () (Op (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "testBit")))) (Var () () LocalScope (Expl (ExtIdent (Right "word"))))) (Lit () (LInt 4))) ()) () () (3, RightFix) LocalScope (Ident {unIdent = "||"}) (Op (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "testBit")))) (Var () () LocalScope (Expl (ExtIdent (Right "word"))))) (Lit () (LInt 5))) ()) () () (3, RightFix) LocalScope (Ident {unIdent = "||"}) (Op (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "testBit")))) (Var () () LocalScope (Expl (ExtIdent (Right "word"))))) (Lit () (LInt 6))) ()) () () (3, RightFix) LocalScope (Ident {unIdent = "||"}) (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "testBit")))) (Var () () LocalScope (Expl (ExtIdent (Right "word"))))) (Lit () (LInt 7))) ())))) ()) () (Enum () () LocalScope (Ident {unIdent = "false"})) () (Enum () () LocalScope (Ident {unIdent = "true"})))) () (Let () () (Expl (ExtIdent (Right "isCharging"))) () (Lam () (((), Just (ExtIdent (Right "c"))) :| []) () (Op (Var () () LocalScope (Expl (ExtIdent (Right "c")))) () () (7, NoFix) LocalScope (Ident {unIdent = ">"}) (Lit () (LDouble 1.0)))) () (LetAnnot () () (ExtIdent (Right "chargeMappedValuesDuringInterval")) () (ForallTC [] (fromList []) (ImplType (M.fromList []) (TArray (TTuple (TCons (TBase TDouble) (TBase TTime) []))))) () (Let () () (Expl (ExtIdent (Right "replaceNoneWithLastKnown"))) () (Lam () (((), Just (ExtIdent (Right "ASuperLongVariableName"))) :| [((), Just (ExtIdent (Right "ASuperLongVariableName"))), ((), Just (ExtIdent (Right "ASuperLongVariableName"))), ((), Just (ExtIdent (Right "ASuperLongVariableName")))]) () (Case () (Var () () LocalScope (Expl (ExtIdent (Right "optVal")))) () (((), PTuple () (TCons (POne () (PVar () (Just (Ident {unIdent = "v"}))), Just ()) (PVar () (Just (Ident {unIdent = "t"})), Nothing) []) (), (), Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "v"))), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "t"))), Nothing) []) ()) :| [((), PTuple () (TCons (PEmpty (), Just ()) (PVar () (Just (Ident {unIdent = "t"})), Nothing) []) (), (), Let () () (Expl (ExtIdent (Right "val"))) () (Case () (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "latestBeforeWithArray")))) (Var () () LocalScope (Expl (ExtIdent (Right "allValuesDuringInterval"))))) (Var () () LocalScope (Expl (ExtIdent (Right "t"))))) ()) () (((), POne () (POne () (PVar () (Just (Ident {unIdent = "v"})))), (), Var () () LocalScope (Expl (ExtIdent (Right "v")))) :| [((), PVar () Nothing, (), Var () () LocalScope (Expl (ExtIdent (Right "valueBeforeInterval"))))]) ()) () (Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "val"))), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "t"))), Nothing) []) ()))]) ())) () (App (App (Var () () (Scope (ModuleName {unModuleName = "Array"})) (Expl (ExtIdent (Right "map")))) (Var () () LocalScope (Expl (ExtIdent (Right "replaceNoneWithLastKnown"))))) (Var () () LocalScope (Expl (ExtIdent (Right "allValuesDuringInterval")))))) () (Let () () (Expl (ExtIdent (Right "test"))) () (Lam () (((), Just (ExtIdent (Right "valueAndTime"))) :| []) () (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "latestBeforeWithArray")))) (Var () () LocalScope (Expl (ExtIdent (Right "bitfieldArray"))))) (Bracketed () (App (Var () () LocalScope (Expl (ExtIdent (Right "snd")))) (Var () () LocalScope (Expl (ExtIdent (Right "valueAndTime"))))) ())) ())) () (LetAnnot () () (ExtIdent (Right "bigTypeAnnot")) () (ForallTC [TV {unTV = 0}] (fromList [TypeClass {className = "addition", params = [TVar (TV {unTV = 0}), TVar (TV {unTV = 0}), TVar (TV {unTV = 0})]}, TypeClass {className = "numeric", params = [TVar (TV {unTV = 0})]}]) (ImplType (M.fromList [(ExtIdent (Right "now"), TBase TTime)]) (TArr (TArray (TTuple (TCons (TVar (TV {unTV = 0})) (TBase TTime) []))) (TArr (TBase TTime) (TOptional (TVar (TV {unTV = 0}))))))) () (Var () () LocalScope (Expl (ExtIdent (Right "bigThing")))) () (Let () () (Expl (ExtIdent (Right "bigThing"))) () (Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "ASuperLongVariableName"))), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "ASuperLongVariableNamet"))), Nothing) [(One () (App (Var () () LocalScope (Expl (ExtIdent (Right "snd")))) (App (Var () () LocalScope (Expl (ExtIdent (Right "snd")))) (Var () () LocalScope (Expl (ExtIdent (Right "ASuperLongVariableNametASuperLongVariableNametASuperLongVariableNametASuperLongVariableNametASuperLongVariableNametASuperLongVariableNamet")))))), Nothing), (Var () () LocalScope (Expl (ExtIdent (Right "ASuperLongVariableNamet"))), Nothing)]) ()) () (Lit () (LDouble 2.0))))))))))))))) showPretty ast \ No newline at end of file From 4ceffb7eb28550f393772be6e0afeced72c721fe Mon Sep 17 00:00:00 2001 From: Siddharth Krishna Date: Mon, 1 Apr 2024 12:10:15 +0200 Subject: [PATCH 14/16] Bump --- inferno-core/CHANGELOG.md | 3 +++ inferno-core/inferno-core.cabal | 2 +- inferno-types/CHANGELOG.md | 3 +++ inferno-types/inferno-types.cabal | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/inferno-core/CHANGELOG.md b/inferno-core/CHANGELOG.md index 2c3e643..9d5353f 100644 --- a/inferno-core/CHANGELOG.md +++ b/inferno-core/CHANGELOG.md @@ -1,6 +1,9 @@ # Revision History for inferno-core *Note*: we use https://pvp.haskell.org/ (MAJOR.MAJOR.MINOR.PATCH) +## 0.11.3.0 -- 2024-04-01 +* Add --parse CLI arg and allow trailing commas in parser + ## 0.11.2.0 -- 2024-03-26 * Add record pattern matching diff --git a/inferno-core/inferno-core.cabal b/inferno-core/inferno-core.cabal index 8dc1790..1d54a0e 100644 --- a/inferno-core/inferno-core.cabal +++ b/inferno-core/inferno-core.cabal @@ -1,6 +1,6 @@ cabal-version: 2.4 name: inferno-core -version: 0.11.2.0 +version: 0.11.3.0 synopsis: A statically-typed functional scripting language description: Parser, type inference, and interpreter for a statically-typed functional scripting language category: DSL,Scripting diff --git a/inferno-types/CHANGELOG.md b/inferno-types/CHANGELOG.md index 2f44e48..0f01091 100644 --- a/inferno-types/CHANGELOG.md +++ b/inferno-types/CHANGELOG.md @@ -1,6 +1,9 @@ # Revision History for inferno-types *Note*: we use https://pvp.haskell.org/ (MAJOR.MAJOR.MINOR.PATCH) +## 0.4.4.0 -- 2024-04-01 +* Improve pretty printer: use consistent indentation levels + ## 0.4.3.0 -- 2024-03-26 * Add record pattern matching diff --git a/inferno-types/inferno-types.cabal b/inferno-types/inferno-types.cabal index 8ec2283..0dcace2 100644 --- a/inferno-types/inferno-types.cabal +++ b/inferno-types/inferno-types.cabal @@ -1,6 +1,6 @@ cabal-version: >=1.10 name: inferno-types -version: 0.4.3.0 +version: 0.4.4.0 synopsis: Core types for Inferno description: Core types for the Inferno language category: DSL,Scripting From d9250bb6098bad14e0acd830381b1c09ae979294 Mon Sep 17 00:00:00 2001 From: Siddharth Krishna Date: Mon, 1 Apr 2024 14:41:34 +0200 Subject: [PATCH 15/16] Remove unnecessary groups --- inferno-types/src/Inferno/Types/Syntax.hs | 28 ++++++++++++----------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/inferno-types/src/Inferno/Types/Syntax.hs b/inferno-types/src/Inferno/Types/Syntax.hs index 6b2a5cc..aee43b5 100644 --- a/inferno-types/src/Inferno/Types/Syntax.hs +++ b/inferno-types/src/Inferno/Types/Syntax.hs @@ -1460,7 +1460,7 @@ instance Pretty (Pat hash a) where <> prettyElems False closingParen es instance Pretty (Expr hash pos) where - pretty = prettyPrec False 0 + pretty = group . prettyPrec False 0 prettyPrec :: Bool -> Int -> Expr hash pos -> Doc ann prettyPrec isBracketed prec expr = @@ -1491,21 +1491,23 @@ prettyPrec isBracketed prec expr = [x] -> prettyAppAux x $ prettyPrec True 0 x (x : xs) -> prettyAppAux x (prettyPrec True 0 x) <> (if hasTrailingComment x then hardline else line) <> prettyApp xs Lam _ xs _ e -> - let xsPretty = sep $ map (maybe "_" pretty . snd) $ toList xs - fun = group $ "fun" <> group (nest 2 $ line <> xsPretty) <> line <> "->" - body = group $ nest 2 $ line <> prettyPrec False 0 e - in group $ fun <> body + group $ fun <> body + where + xsPretty = sep $ map (maybe "_" pretty . snd) $ toList xs + fun = group $ "fun" <> group (nest 2 $ line <> xsPretty) <> line <> "->" + body = group $ nest 2 $ line <> prettyPrec False 0 e Let _ _ x _ e1 _ e2 -> - group $ letPretty <> line <> prettyPrec False 0 e2 + letPretty <> line <> prettyPrec False 0 e2 where letPretty = group $ "let" <+> pretty x <+> "=" <> e1Pretty <> "in" e1Pretty = group $ nest 2 (line <> prettyPrec False 0 e1) <> e1End e1End = if hasTrailingComment e1 then hardline else line LetAnnot _ _ x _ t _ e1 _ e2 -> - let e1Pretty = group $ nest 2 (line <> prettyPrec False 0 e1) <> (if hasTrailingComment e1 then hardline else line) - tPretty = group $ nest 2 (line <> pretty t) <> line - letPretty = group $ "let" <+> pretty x <+> ":" <> tPretty <> "=" <> e1Pretty <> "in" - in group $ letPretty <> line <> prettyPrec False 0 e2 + letPretty <> line <> prettyPrec False 0 e2 + where + e1Pretty = group $ nest 2 (line <> prettyPrec False 0 e1) <> (if hasTrailingComment e1 then hardline else line) + tPretty = group $ nest 2 (line <> pretty t) <> line + letPretty = group $ "let" <+> pretty x <+> ":" <> tPretty <> "=" <> e1Pretty <> "in" Lit _ l -> pretty l InterpolatedString _ istr _ -> enclose "`" "`" $ group $ @@ -1589,7 +1591,7 @@ prettyPrec isBracketed prec expr = group $ nest 2 $ "Some" <> line <> prettyPrec False 0 e Empty _ -> "None" Assert _ c _ e -> - group $ assertPretty <> line <> prettyPrec False 0 e + assertPretty <> line <> prettyPrec False 0 e where assertPretty = group $ "assert" <> cPretty <> "in" cPretty = group $ nest 2 (line <> prettyPrec False 0 c) <> cEnd @@ -1649,12 +1651,12 @@ prettyPrec isBracketed prec expr = where end = if hasTrailingComment e then hardline else mempty RenameModule _ (ModuleName nNew) _ (ModuleName nOld) _ e -> - group $ letPretty <> line <> prettyPrec False 0 e + letPretty <> line <> prettyPrec False 0 e where letPretty = group $ "let" <+> "module" <> mPretty <> line <> "in" mPretty = group $ nest 2 $ line <> pretty nNew <+> "=" <+> pretty nOld OpenModule _ _ (ModuleName n) ns _ e -> - group $ openPretty <> line <> prettyPrec False 0 e + openPretty <> line <> prettyPrec False 0 e where openPretty = group $ "open" <+> pretty n <> prettyImports <> iEnd prettyImports = case ns of From f1729024592f8fc35ccf4fcd5388681c09238e7a Mon Sep 17 00:00:00 2001 From: Siddharth Krishna Date: Mon, 1 Apr 2024 14:55:12 +0200 Subject: [PATCH 16/16] Format --- inferno-types/pretty-test/Main.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inferno-types/pretty-test/Main.hs b/inferno-types/pretty-test/Main.hs index b96fdfc..fbae7f5 100644 --- a/inferno-types/pretty-test/Main.hs +++ b/inferno-types/pretty-test/Main.hs @@ -14,6 +14,6 @@ import Inferno.Utils.Prettyprinter (showPretty) main :: IO () main = do let ast :: Expr () () = - Let () () (Expl (ExtIdent (Right "bigApp"))) () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig")))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) () (Let () () (Expl (ExtIdent (Right "null"))) () (Tuple () TNil ()) () (Let () () (Expl (ExtIdent (Right "smallTup"))) () (Tuple () (TCons (Lit () (LInt 12314314),Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "fadsfdfsadfa"))),Just ()) [(Lit () (LInt 13413241345),Nothing)]) ()) () (Let () () (Expl (ExtIdent (Right "mediumTup"))) () (Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()) [(Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "mediu"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "mediu"))),Nothing)]) ()) () (Let () () (Expl (ExtIdent (Right "bigTup"))) () (Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))),Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))),Just ()) [(Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))),Just ()),(One () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig")))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))),Nothing)]) ()) () (Assert () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "thing"))))) (Var () () LocalScope (Expl (ExtIdent (Right "small"))))) () (Assert () (App (App (App (App (App (App (App (App (App (App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "thing"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) () (Assert () (App (App (App (App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "thing"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) () (Let () () (Expl (ExtIdent (Right "x"))) () (Case () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "thing"))))) (Var () () LocalScope (Expl (ExtIdent (Right "small"))))) () (((),PLit () (LInt 1),(),Lit () (LInt 2)) :| [((),PVar () Nothing,(),Lit () (LInt 3))]) ()) () (Let () () (Expl (ExtIdent (Right "x"))) () (Case () (App (App (App (App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "thing"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) () (((),PTuple () (TCons (PVar () (Just (Ident {unIdent = "biggbig"})),Just ()) (PVar () (Just (Ident {unIdent = "bigbigbig"})),Just ()) [(PVar () (Just (Ident {unIdent = "bigbigbigbig"})),Just ()),(PVar () (Just (Ident {unIdent = "bigbigbigbigbig"})),Just ()),(PVar () (Just (Ident {unIdent = "bigbigbigbigbigbigbig"})),Just ()),(PVar () (Just (Ident {unIdent = "bigbigbigbigbigbigbigbigbig"})),Nothing)]) (),(),Lit () (LInt 2)) :| [((),PVar () (Just (Ident {unIdent = "xyz"})),(),Lit () (LInt 3)),((),PVar () Nothing,(),Lit () (LInt 4))]) ()) () (Let () () (Expl (ExtIdent (Right "smallRec"))) () (Record () [(Ident {unIdent = "height"},Lit () (LInt 2),Just ()),(Ident {unIdent = "weight"},Tuple () (TCons (Lit () (LDouble 3.54),Just ()) (Lit () (LText "kgs"),Nothing) []) (),Nothing)] ()) () (Let () () (Expl (ExtIdent (Right "bigRec"))) () (Record () [(Ident {unIdent = "expr"},Let () () (Expl (ExtIdent (Right "x"))) () (Lit () (LInt 2)) () (Op (Var () () LocalScope (Expl (ExtIdent (Right "x")))) () () (9,LeftFix) LocalScope (Ident {unIdent = "+"}) (Lit () (LInt 1))),Just ()),(Ident {unIdent = "height"},Tuple () (TCons (Lit () (LInt 12314314),Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "fadsfdfsadfa"))),Just ()) [(Lit () (LInt 13413241345),Nothing)]) (),Just ()),(Ident {unIdent = "weight"},Tuple () (TCons (Lit () (LDouble 3.54),Just ()) (Lit () (LText "kgs"),Nothing) []) (),Just ()),(Ident {unIdent = "name"},Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "biggbig"))),Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbig"))),Just ()) [(Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbig"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbig"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbig"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbig"))),Nothing)]) (),Nothing)] ()) () (Let () () (Expl (ExtIdent (Right "smallArr"))) () (Array () [(Lit () (LInt 12314314),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "fadsfdfsadfa"))),Just ()),(Lit () (LInt 13413241345),Just ())] ()) () (Let () () (Expl (ExtIdent (Right "mediumArr"))) () (Array () [(Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "medium"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "mediu"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "mediu"))),Nothing)] ()) () (Let () () (Expl (ExtIdent (Right "bigArr"))) () (Array () [(Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))),Just ()),(Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))),Just ()),(One () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig")))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))),Nothing)] ()) () (Let () () (Expl (ExtIdent (Right "arrayComp"))) () (ArrayComp () (App (App (App (App (Var () () LocalScope (Expl (ExtIdent (Right "bigFun")))) (Var () () LocalScope (Expl (ExtIdent (Right "one"))))) (Var () () LocalScope (Expl (ExtIdent (Right "two"))))) (Var () () LocalScope (Expl (ExtIdent (Right "three"))))) (Var () () LocalScope (Expl (ExtIdent (Right "four"))))) () (((),Ident {unIdent = "one"},(),App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "thing")))),Just ()) :| []) (Just ((),App (Var () () LocalScope (Expl (ExtIdent (Right "one")))) (Var () () LocalScope (Expl (ExtIdent (Right "two")))))) ()) () (Let () () (Expl (ExtIdent (Right "arrayComp"))) () (ArrayComp () (App (App (App (App (App (App (Var () () LocalScope (Expl (ExtIdent (Right "getBitValAndTime")))) (Var () () LocalScope (Expl (ExtIdent (Right "t"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) () (((),Ident {unIdent = "t"},(),App (App (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "intervalEvery")))) (Bracketed () (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "seconds")))) (Var () () LocalScope (Expl (ExtIdent (Right "intervalStep"))))) ())) (Var () () LocalScope (Expl (ExtIdent (Right "startOfInterval"))))) (Var () () LocalScope (Impl (ExtIdent (Right "now")))),Just ()) :| [((),Ident {unIdent = "one"},(),App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "thing")))),Just ()),((),Ident {unIdent = "two"},(),App (App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "other"))))) (Var () () LocalScope (Expl (ExtIdent (Right "thing")))),Just ()),((),Ident {unIdent = "three"},(),One () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig")))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))),Just ())]) (Just ((),Bracketed () (App (App (App (App (Var () () LocalScope (Expl (ExtIdent (Right "one")))) (Var () () LocalScope (Expl (ExtIdent (Right "two"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) ())) ()) () (RenameModule () (ModuleName {unModuleName = "mSmall"}) () (ModuleName {unModuleName = "Number"}) () (RenameModule () (ModuleName {unModuleName = "bigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbig"}) () (ModuleName {unModuleName = "Array"}) () (OpenModule () () (ModuleName {unModuleName = "Array"}) [] () (OpenModule () () (ModuleName {unModuleName = "Array"}) [(IVar () (Ident {unIdent = "foo"}),Just ()),(IVar () (Ident {unIdent = "bar"}),Just ()),(IVar () (Ident {unIdent = "baz"}),Just ()),(IVar () (Ident {unIdent = "bar"}),Just ()),(IVar () (Ident {unIdent = "baz"}),Just ()),(IVar () (Ident {unIdent = "bar"}),Just ()),(IVar () (Ident {unIdent = "baz"}),Nothing)] () (OpenModule () () (ModuleName {unModuleName = "Array"}) [(IVar () (Ident {unIdent = "foo"}),Just ()),(IVar () (Ident {unIdent = "bar"}),Just ()),(IVar () (Ident {unIdent = "baz"}),Just ()),(IVar () (Ident {unIdent = "bar"}),Just ()),(IVar () (Ident {unIdent = "baz"}),Just ()),(IVar () (Ident {unIdent = "bar"}),Just ()),(IVar () (Ident {unIdent = "baz"}),Just ()),(IVar () (Ident {unIdent = "bar"}),Just ()),(IVar () (Ident {unIdent = "baz"}),Just ()),(IVar () (Ident {unIdent = "bar"}),Just ()),(IVar () (Ident {unIdent = "baz"}),Just ()),(IVar () (Ident {unIdent = "bar"}),Just ()),(IVar () (Ident {unIdent = "baz"}),Just ()),(IVar () (Ident {unIdent = "bar"}),Just ()),(IVar () (Ident {unIdent = "baz"}),Just ()),(IVar () (Ident {unIdent = "bar"}),Just ()),(IVar () (Ident {unIdent = "baz"}),Just ()),(IVar () (Ident {unIdent = "bar"}),Just ()),(IVar () (Ident {unIdent = "baz"}),Nothing)] () (Let () () (Expl (ExtIdent (Right "nested"))) () (One () (One () (One () (One () (One () (One () (One () (One () (One () (One () (One () (One () (One () (One () (One () (One () (One () (One () (One () (One () (Var () () LocalScope (Expl (ExtIdent (Right "bla")))))))))))))))))))))))) () (Lit () (LDouble 2.0)))))))))))))))))))))))) + Let () () (Expl (ExtIdent (Right "bigApp"))) () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig")))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) () (Let () () (Expl (ExtIdent (Right "null"))) () (Tuple () TNil ()) () (Let () () (Expl (ExtIdent (Right "smallTup"))) () (Tuple () (TCons (Lit () (LInt 12314314), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "fadsfdfsadfa"))), Just ()) [(Lit () (LInt 13413241345), Nothing)]) ()) () (Let () () (Expl (ExtIdent (Right "mediumTup"))) () (Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()) [(Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "mediu"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "mediu"))), Nothing)]) ()) () (Let () () (Expl (ExtIdent (Right "bigTup"))) () (Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))), Just ()) [(Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))), Just ()), (One () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig")))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))), Nothing)]) ()) () (Assert () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "thing"))))) (Var () () LocalScope (Expl (ExtIdent (Right "small"))))) () (Assert () (App (App (App (App (App (App (App (App (App (App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "thing"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) (Var () () LocalScope (Expl (ExtIdent (Right "medium"))))) () (Assert () (App (App (App (App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "thing"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) () (Let () () (Expl (ExtIdent (Right "x"))) () (Case () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "thing"))))) (Var () () LocalScope (Expl (ExtIdent (Right "small"))))) () (((), PLit () (LInt 1), (), Lit () (LInt 2)) :| [((), PVar () Nothing, (), Lit () (LInt 3))]) ()) () (Let () () (Expl (ExtIdent (Right "x"))) () (Case () (App (App (App (App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "thing"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) () (((), PTuple () (TCons (PVar () (Just (Ident {unIdent = "biggbig"})), Just ()) (PVar () (Just (Ident {unIdent = "bigbigbig"})), Just ()) [(PVar () (Just (Ident {unIdent = "bigbigbigbig"})), Just ()), (PVar () (Just (Ident {unIdent = "bigbigbigbigbig"})), Just ()), (PVar () (Just (Ident {unIdent = "bigbigbigbigbigbigbig"})), Just ()), (PVar () (Just (Ident {unIdent = "bigbigbigbigbigbigbigbigbig"})), Nothing)]) (), (), Lit () (LInt 2)) :| [((), PVar () (Just (Ident {unIdent = "xyz"})), (), Lit () (LInt 3)), ((), PVar () Nothing, (), Lit () (LInt 4))]) ()) () (Let () () (Expl (ExtIdent (Right "smallRec"))) () (Record () [(Ident {unIdent = "height"}, Lit () (LInt 2), Just ()), (Ident {unIdent = "weight"}, Tuple () (TCons (Lit () (LDouble 3.54), Just ()) (Lit () (LText "kgs"), Nothing) []) (), Nothing)] ()) () (Let () () (Expl (ExtIdent (Right "bigRec"))) () (Record () [(Ident {unIdent = "expr"}, Let () () (Expl (ExtIdent (Right "x"))) () (Lit () (LInt 2)) () (Op (Var () () LocalScope (Expl (ExtIdent (Right "x")))) () () (9, LeftFix) LocalScope (Ident {unIdent = "+"}) (Lit () (LInt 1))), Just ()), (Ident {unIdent = "height"}, Tuple () (TCons (Lit () (LInt 12314314), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "fadsfdfsadfa"))), Just ()) [(Lit () (LInt 13413241345), Nothing)]) (), Just ()), (Ident {unIdent = "weight"}, Tuple () (TCons (Lit () (LDouble 3.54), Just ()) (Lit () (LText "kgs"), Nothing) []) (), Just ()), (Ident {unIdent = "name"}, Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "biggbig"))), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbig"))), Just ()) [(Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbig"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbig"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbig"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbig"))), Nothing)]) (), Nothing)] ()) () (Let () () (Expl (ExtIdent (Right "smallArr"))) () (Array () [(Lit () (LInt 12314314), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "fadsfdfsadfa"))), Just ()), (Lit () (LInt 13413241345), Just ())] ()) () (Let () () (Expl (ExtIdent (Right "mediumArr"))) () (Array () [(Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "medium"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "mediu"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "mediu"))), Nothing)] ()) () (Let () () (Expl (ExtIdent (Right "bigArr"))) () (Array () [(Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))), Just ()), (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))), Just ()), (One () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig")))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))), Nothing)] ()) () (Let () () (Expl (ExtIdent (Right "arrayComp"))) () (ArrayComp () (App (App (App (App (Var () () LocalScope (Expl (ExtIdent (Right "bigFun")))) (Var () () LocalScope (Expl (ExtIdent (Right "one"))))) (Var () () LocalScope (Expl (ExtIdent (Right "two"))))) (Var () () LocalScope (Expl (ExtIdent (Right "three"))))) (Var () () LocalScope (Expl (ExtIdent (Right "four"))))) () (((), Ident {unIdent = "one"}, (), App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "thing")))), Just ()) :| []) (Just ((), App (Var () () LocalScope (Expl (ExtIdent (Right "one")))) (Var () () LocalScope (Expl (ExtIdent (Right "two")))))) ()) () (Let () () (Expl (ExtIdent (Right "arrayComp"))) () (ArrayComp () (App (App (App (App (App (App (Var () () LocalScope (Expl (ExtIdent (Right "getBitValAndTime")))) (Var () () LocalScope (Expl (ExtIdent (Right "t"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) () (((), Ident {unIdent = "t"}, (), App (App (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "intervalEvery")))) (Bracketed () (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "seconds")))) (Var () () LocalScope (Expl (ExtIdent (Right "intervalStep"))))) ())) (Var () () LocalScope (Expl (ExtIdent (Right "startOfInterval"))))) (Var () () LocalScope (Impl (ExtIdent (Right "now")))), Just ()) :| [((), Ident {unIdent = "one"}, (), App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "thing")))), Just ()), ((), Ident {unIdent = "two"}, (), App (App (Var () () LocalScope (Expl (ExtIdent (Right "some")))) (Var () () LocalScope (Expl (ExtIdent (Right "other"))))) (Var () () LocalScope (Expl (ExtIdent (Right "thing")))), Just ()), ((), Ident {unIdent = "three"}, (), One () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig")))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))), Just ())]) (Just ((), Bracketed () (App (App (App (App (Var () () LocalScope (Expl (ExtIdent (Right "one")))) (Var () () LocalScope (Expl (ExtIdent (Right "two"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bigbigbigbigbigbigbigbigbigbigbig"))))) ())) ()) () (RenameModule () (ModuleName {unModuleName = "mSmall"}) () (ModuleName {unModuleName = "Number"}) () (RenameModule () (ModuleName {unModuleName = "bigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbigbig"}) () (ModuleName {unModuleName = "Array"}) () (OpenModule () () (ModuleName {unModuleName = "Array"}) [] () (OpenModule () () (ModuleName {unModuleName = "Array"}) [(IVar () (Ident {unIdent = "foo"}), Just ()), (IVar () (Ident {unIdent = "bar"}), Just ()), (IVar () (Ident {unIdent = "baz"}), Just ()), (IVar () (Ident {unIdent = "bar"}), Just ()), (IVar () (Ident {unIdent = "baz"}), Just ()), (IVar () (Ident {unIdent = "bar"}), Just ()), (IVar () (Ident {unIdent = "baz"}), Nothing)] () (OpenModule () () (ModuleName {unModuleName = "Array"}) [(IVar () (Ident {unIdent = "foo"}), Just ()), (IVar () (Ident {unIdent = "bar"}), Just ()), (IVar () (Ident {unIdent = "baz"}), Just ()), (IVar () (Ident {unIdent = "bar"}), Just ()), (IVar () (Ident {unIdent = "baz"}), Just ()), (IVar () (Ident {unIdent = "bar"}), Just ()), (IVar () (Ident {unIdent = "baz"}), Just ()), (IVar () (Ident {unIdent = "bar"}), Just ()), (IVar () (Ident {unIdent = "baz"}), Just ()), (IVar () (Ident {unIdent = "bar"}), Just ()), (IVar () (Ident {unIdent = "baz"}), Just ()), (IVar () (Ident {unIdent = "bar"}), Just ()), (IVar () (Ident {unIdent = "baz"}), Just ()), (IVar () (Ident {unIdent = "bar"}), Just ()), (IVar () (Ident {unIdent = "baz"}), Just ()), (IVar () (Ident {unIdent = "bar"}), Just ()), (IVar () (Ident {unIdent = "baz"}), Just ()), (IVar () (Ident {unIdent = "bar"}), Just ()), (IVar () (Ident {unIdent = "baz"}), Nothing)] () (Let () () (Expl (ExtIdent (Right "nested"))) () (One () (One () (One () (One () (One () (One () (One () (One () (One () (One () (One () (One () (One () (One () (One () (One () (One () (One () (One () (One () (Var () () LocalScope (Expl (ExtIdent (Right "bla")))))))))))))))))))))))) () (Lit () (LDouble 2.0)))))))))))))))))))))))) -- Let () () (Impl (ExtIdent (Right "resolution"))) () (App (Var () () LocalScope (Expl (ExtIdent (Right "toResolution")))) (Lit () (LInt 64))) () (LetAnnot () () (ExtIdent (Right "latestBeforeWithArray")) () (ForallTC [TV {unTV = 0}] (fromList []) (ImplType (M.fromList []) (TArr (TArray (TTuple (TCons (TVar (TV {unTV = 0})) (TBase TTime) []))) (TArr (TBase TTime) (TOptional (TVar (TV {unTV = 0}))))))) () (Lam () (((), Just (ExtIdent (Right "arr"))) :| [((), Just (ExtIdent (Right "t")))]) () (Let () () (Expl (ExtIdent (Right "compareTimes"))) () (Lam () (((), Just (ExtIdent (Right "targetTime"))) :| [((), Just (ExtIdent (Right "testValAndTime"))), ((), Just (ExtIdent (Right "lastValAndTime")))]) () (If () (Op (Var () () LocalScope (Expl (ExtIdent (Right "targetTime")))) () () (7, NoFix) LocalScope (Ident {unIdent = "<"}) (Bracketed () (App (Var () () LocalScope (Expl (ExtIdent (Right "snd")))) (Var () () LocalScope (Expl (ExtIdent (Right "testValAndTime"))))) ())) () (Var () () LocalScope (Expl (ExtIdent (Right "lastValAndTime")))) () (Var () () LocalScope (Expl (ExtIdent (Right "testValAndTime")))))) () (Let () () (Expl (ExtIdent (Right "subValues"))) () (Lam () (((), Just (ExtIdent (Right "lastValAndTime"))) :| [((), Just (ExtIdent (Right "testValAndTime")))]) () (Case () (Var () () LocalScope (Expl (ExtIdent (Right "lastValAndTime")))) () (((), PEmpty (), (), If () (Op (Var () () LocalScope (Expl (ExtIdent (Right "t")))) () () (7, NoFix) LocalScope (Ident {unIdent = "<"}) (Bracketed () (App (Var () () LocalScope (Expl (ExtIdent (Right "snd")))) (Var () () LocalScope (Expl (ExtIdent (Right "testValAndTime"))))) ())) () (Empty ()) () (Bracketed () (One () (Var () () LocalScope (Expl (ExtIdent (Right "testValAndTime"))))) ())) :| [((), POne () (PVar () (Just (Ident {unIdent = "ltv"}))), (), One () (Bracketed () (App (App (App (Var () () LocalScope (Expl (ExtIdent (Right "compareTimes")))) (Var () () LocalScope (Expl (ExtIdent (Right "t"))))) (Var () () LocalScope (Expl (ExtIdent (Right "testValAndTime"))))) (Var () () LocalScope (Expl (ExtIdent (Right "ltv"))))) ()))]) ())) () (Bracketed () (App (App (Var () () (Scope (ModuleName {unModuleName = "Option"})) (Expl (ExtIdent (Right "map")))) (Var () () LocalScope (Expl (ExtIdent (Right "fst"))))) (Bracketed () (App (App (App (Var () () (Scope (ModuleName {unModuleName = "Array"})) (Expl (ExtIdent (Right "reduce")))) (Var () () LocalScope (Expl (ExtIdent (Right "subValues"))))) (Empty ())) (Var () () LocalScope (Expl (ExtIdent (Right "arr"))))) ())) ())))) () (Let () () (Expl (ExtIdent (Right "intervalStep"))) () (Bracketed () (App (Var () () LocalScope (Expl (ExtIdent (Right "resolutionToInt")))) (Var () () LocalScope (Impl (ExtIdent (Right "resolution"))))) ()) () (Let () () (Expl (ExtIdent (Right "startOfInterval"))) () (Bracketed () (Op (Var () () LocalScope (Impl (ExtIdent (Right "now")))) () () (9, LeftFix) LocalScope (Ident {unIdent = "-"}) (Bracketed () (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "hours")))) (Lit () (LInt 24))) ())) ()) () (LetAnnot () () (ExtIdent (Right "valueBeforeInterval")) () (ForallTC [] (fromList []) (ImplType (M.fromList []) (TBase TDouble))) () (App (App (App (Var () () (Scope (ModuleName {unModuleName = "Option"})) (Expl (ExtIdent (Right "reduce")))) (Var () () LocalScope (Expl (ExtIdent (Right "id"))))) (Lit () (LDouble 0.0))) (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "latestValueBefore")))) (Var () () LocalScope (Expl (ExtIdent (Right "startOfInterval"))))) (Var () () LocalScope (Expl (ExtIdent (Right "power"))))) ())) () (LetAnnot () () (ExtIdent (Right "bitfieldBeforeInterval")) () (ForallTC [] (fromList []) (ImplType (M.fromList []) (TBase TDouble))) () (App (App (App (Var () () (Scope (ModuleName {unModuleName = "Option"})) (Expl (ExtIdent (Right "reduce")))) (Var () () LocalScope (Expl (ExtIdent (Right "id"))))) (Lit () (LDouble 0.0))) (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "latestValueBefore")))) (Var () () LocalScope (Expl (ExtIdent (Right "startOfInterval"))))) (Var () () LocalScope (Expl (ExtIdent (Right "bitParam"))))) ())) () (LetAnnot () () (ExtIdent (Right "allValuesDuringInterval")) () (ForallTC [] (fromList []) (ImplType (M.fromList []) (TArray (TTuple (TCons (TOptional (TBase TDouble)) (TBase TTime) []))))) () (ArrayComp () (Tuple () (TCons (App (App (Var () () LocalScope (Expl (ExtIdent (Right "valueAtOrAdjacent")))) (Var () () LocalScope (Expl (ExtIdent (Right "power"))))) (Var () () LocalScope (Expl (ExtIdent (Right "t")))), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "t"))), Nothing) []) ()) () (((), Ident {unIdent = "t"}, (), App (App (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "intervalEvery")))) (Bracketed () (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "seconds")))) (Var () () LocalScope (Expl (ExtIdent (Right "intervalStep"))))) ())) (Var () () LocalScope (Expl (ExtIdent (Right "startOfInterval"))))) (Var () () LocalScope (Impl (ExtIdent (Right "now")))), Nothing) :| []) Nothing ()) () (LetAnnot () () (ExtIdent (Right "bitfieldArray")) () (ForallTC [] (fromList []) (ImplType (M.fromList []) (TArray (TTuple (TCons (TBase TDouble) (TBase TTime) []))))) () (Let () () (Impl (ExtIdent (Right "resolution"))) () (App (Var () () LocalScope (Expl (ExtIdent (Right "toResolution")))) (Lit () (LInt 1))) () (App (Var () () (Scope (ModuleName {unModuleName = "Array"})) (Expl (ExtIdent (Right "keepSomes")))) (ArrayComp () (App (App (Var () () (Scope (ModuleName {unModuleName = "Option"})) (Expl (ExtIdent (Right "map")))) (Bracketed () (Lam () (((), Just (ExtIdent (Right "v"))) :| []) () (Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "v"))), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "t"))), Nothing) []) ())) ())) (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "valueAt")))) (Var () () LocalScope (Expl (ExtIdent (Right "bitParam"))))) (Var () () LocalScope (Expl (ExtIdent (Right "t"))))) ())) () (((), Ident {unIdent = "t"}, (), App (App (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "intervalEvery")))) (Bracketed () (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "seconds")))) (Lit () (LInt 1))) ())) (Bracketed () (Op (Var () () LocalScope (Impl (ExtIdent (Right "now")))) () () (9, LeftFix) LocalScope (Ident {unIdent = "-"}) (Bracketed () (App (Var () () (Scope (ModuleName {unModuleName = "Time"})) (Expl (ExtIdent (Right "hours")))) (Lit () (LInt 24))) ())) ())) (Var () () LocalScope (Impl (ExtIdent (Right "now")))), Nothing) :| []) Nothing ()))) () (Let () () (Expl (ExtIdent (Right "inPrimaryDischarge"))) () (Lam () (((), Just (ExtIdent (Right "word"))) :| []) () (If () (Bracketed () (Op (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "testBit")))) (Var () () LocalScope (Expl (ExtIdent (Right "word"))))) (Lit () (LInt 4))) ()) () () (3, RightFix) LocalScope (Ident {unIdent = "||"}) (Op (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "testBit")))) (Var () () LocalScope (Expl (ExtIdent (Right "word"))))) (Lit () (LInt 5))) ()) () () (3, RightFix) LocalScope (Ident {unIdent = "||"}) (Op (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "testBit")))) (Var () () LocalScope (Expl (ExtIdent (Right "word"))))) (Lit () (LInt 6))) ()) () () (3, RightFix) LocalScope (Ident {unIdent = "||"}) (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "testBit")))) (Var () () LocalScope (Expl (ExtIdent (Right "word"))))) (Lit () (LInt 7))) ())))) ()) () (Enum () () LocalScope (Ident {unIdent = "false"})) () (Enum () () LocalScope (Ident {unIdent = "true"})))) () (Let () () (Expl (ExtIdent (Right "isCharging"))) () (Lam () (((), Just (ExtIdent (Right "c"))) :| []) () (Op (Var () () LocalScope (Expl (ExtIdent (Right "c")))) () () (7, NoFix) LocalScope (Ident {unIdent = ">"}) (Lit () (LDouble 1.0)))) () (LetAnnot () () (ExtIdent (Right "chargeMappedValuesDuringInterval")) () (ForallTC [] (fromList []) (ImplType (M.fromList []) (TArray (TTuple (TCons (TBase TDouble) (TBase TTime) []))))) () (Let () () (Expl (ExtIdent (Right "replaceNoneWithLastKnown"))) () (Lam () (((), Just (ExtIdent (Right "ASuperLongVariableName"))) :| [((), Just (ExtIdent (Right "ASuperLongVariableName"))), ((), Just (ExtIdent (Right "ASuperLongVariableName"))), ((), Just (ExtIdent (Right "ASuperLongVariableName")))]) () (Case () (Var () () LocalScope (Expl (ExtIdent (Right "optVal")))) () (((), PTuple () (TCons (POne () (PVar () (Just (Ident {unIdent = "v"}))), Just ()) (PVar () (Just (Ident {unIdent = "t"})), Nothing) []) (), (), Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "v"))), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "t"))), Nothing) []) ()) :| [((), PTuple () (TCons (PEmpty (), Just ()) (PVar () (Just (Ident {unIdent = "t"})), Nothing) []) (), (), Let () () (Expl (ExtIdent (Right "val"))) () (Case () (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "latestBeforeWithArray")))) (Var () () LocalScope (Expl (ExtIdent (Right "allValuesDuringInterval"))))) (Var () () LocalScope (Expl (ExtIdent (Right "t"))))) ()) () (((), POne () (POne () (PVar () (Just (Ident {unIdent = "v"})))), (), Var () () LocalScope (Expl (ExtIdent (Right "v")))) :| [((), PVar () Nothing, (), Var () () LocalScope (Expl (ExtIdent (Right "valueBeforeInterval"))))]) ()) () (Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "val"))), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "t"))), Nothing) []) ()))]) ())) () (App (App (Var () () (Scope (ModuleName {unModuleName = "Array"})) (Expl (ExtIdent (Right "map")))) (Var () () LocalScope (Expl (ExtIdent (Right "replaceNoneWithLastKnown"))))) (Var () () LocalScope (Expl (ExtIdent (Right "allValuesDuringInterval")))))) () (Let () () (Expl (ExtIdent (Right "test"))) () (Lam () (((), Just (ExtIdent (Right "valueAndTime"))) :| []) () (Bracketed () (App (App (Var () () LocalScope (Expl (ExtIdent (Right "latestBeforeWithArray")))) (Var () () LocalScope (Expl (ExtIdent (Right "bitfieldArray"))))) (Bracketed () (App (Var () () LocalScope (Expl (ExtIdent (Right "snd")))) (Var () () LocalScope (Expl (ExtIdent (Right "valueAndTime"))))) ())) ())) () (LetAnnot () () (ExtIdent (Right "bigTypeAnnot")) () (ForallTC [TV {unTV = 0}] (fromList [TypeClass {className = "addition", params = [TVar (TV {unTV = 0}), TVar (TV {unTV = 0}), TVar (TV {unTV = 0})]}, TypeClass {className = "numeric", params = [TVar (TV {unTV = 0})]}]) (ImplType (M.fromList [(ExtIdent (Right "now"), TBase TTime)]) (TArr (TArray (TTuple (TCons (TVar (TV {unTV = 0})) (TBase TTime) []))) (TArr (TBase TTime) (TOptional (TVar (TV {unTV = 0}))))))) () (Var () () LocalScope (Expl (ExtIdent (Right "bigThing")))) () (Let () () (Expl (ExtIdent (Right "bigThing"))) () (Tuple () (TCons (Var () () LocalScope (Expl (ExtIdent (Right "ASuperLongVariableName"))), Just ()) (Var () () LocalScope (Expl (ExtIdent (Right "ASuperLongVariableNamet"))), Nothing) [(One () (App (Var () () LocalScope (Expl (ExtIdent (Right "snd")))) (App (Var () () LocalScope (Expl (ExtIdent (Right "snd")))) (Var () () LocalScope (Expl (ExtIdent (Right "ASuperLongVariableNametASuperLongVariableNametASuperLongVariableNametASuperLongVariableNametASuperLongVariableNametASuperLongVariableNamet")))))), Nothing), (Var () () LocalScope (Expl (ExtIdent (Right "ASuperLongVariableNamet"))), Nothing)]) ()) () (Lit () (LDouble 2.0))))))))))))))) - showPretty ast \ No newline at end of file + showPretty ast