1
1
mirror of https://github.com/anoma/juvix.git synced 2024-10-05 20:47:36 +03:00
This commit is contained in:
Dimitris Apostolou 2024-01-08 14:27:18 +02:00 committed by GitHub
parent 75bce8f665
commit d6d21a22e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
31 changed files with 38 additions and 38 deletions

View File

@ -759,7 +759,7 @@ table.info {
/* @end */ /* @end */
/* @group Auxillary Pages */ /* @group Auxiliary Pages */
.extension-list { .extension-list {

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
--- Towers of Hanoi is a puzzle with three rods and n disks of decresing size. --- Towers of Hanoi is a puzzle with three rods and n disks of decreasing size.
--- The disks are stacked ontop of each other through the first rod. --- The disks are stacked on top of each other through the first rod.
--- The aim of the game is to move the stack of disks to another rod while --- The aim of the game is to move the stack of disks to another rod while
--- following these rules: --- following these rules:
--- ---

View File

@ -9,7 +9,7 @@ void io_flush();
void io_trace(word_t x); void io_trace(word_t x);
void io_print_toplevel(word_t x); void io_print_toplevel(word_t x);
// If the returned value is true, `ret` constains a closure and `arg` an // If the returned value is true, `ret` contains a closure and `arg` an
// argument that should be supplied to this closure. If the returned value is // argument that should be supplied to this closure. If the returned value is
// false, `ret` contains the value in the monad. // false, `ret` contains the value in the monad.
bool io_interpret(word_t x, word_t *ret, word_t *arg); bool io_interpret(word_t x, word_t *ret, word_t *arg);

View File

@ -33,7 +33,7 @@ static inline void alloc_save_memory_pointer(word_t *ptr) {
#define RESTORE_MEMORY_POINTERS juvix_memory_pointer = alloc_memory_pointer(); #define RESTORE_MEMORY_POINTERS juvix_memory_pointer = alloc_memory_pointer();
// Preallocate n words. `SAVE` and `RESTORE` should save and restore live local // Preallocate n words. `SAVE` and `RESTORE` should save and restore live local
// variables on the global stack (can lauch GC which needs access to these // variables on the global stack (can launch GC which needs access to these
// variables). // variables).
#define PREALLOC(n, SAVE, RESTORE) \ #define PREALLOC(n, SAVE, RESTORE) \
if (unlikely(is_next_page(juvix_memory_pointer, n))) { \ if (unlikely(is_next_page(juvix_memory_pointer, n))) { \

View File

@ -56,7 +56,7 @@ void *memset(void *dest, int c, size_t n) {
u32 c32 = ((u32)-1) / 255 * (unsigned char)c; u32 c32 = ((u32)-1) / 255 * (unsigned char)c;
/* In preparation to copy 32 bytes at a time, aligned on /* In preparation to copy 32 bytes at a time, aligned on
* an 8-byte bounary, fill head/tail up to 28 bytes each. * an 8-byte boundary, fill head/tail up to 28 bytes each.
* As in the initial byte-based head/tail fill, each * As in the initial byte-based head/tail fill, each
* conditional below ensures that the subsequent offsets * conditional below ensures that the subsequent offsets
* are valid (e.g. !(n<=24) implies n>=28). */ * are valid (e.g. !(n<=24) implies n>=28). */

View File

@ -31,9 +31,9 @@ Memory consists of:
- referenced with TempRef - referenced with TempRef
- constant maximum height (depends on the function) - constant maximum height (depends on the function)
- current height of the local temporary stack is known at compile-time for each - current height of the local temporary stack is known at compile-time for each
intruction; a program violating this assumption (e.g. by having a `Branch` instruction; a program violating this assumption (e.g. by having a `Branch`
instruction whose two branches result in different stack heights) is instruction whose two branches result in different stack heights) is
errorneous erroneous
- compiled to a constant number of local variables / registers - compiled to a constant number of local variables / registers
- Core.Let is compiled to store the value in the local temporary area - Core.Let is compiled to store the value in the local temporary area
- Core.Case is compiled to store the value in the local temporary area, - Core.Case is compiled to store the value in the local temporary area,
@ -45,7 +45,7 @@ Memory consists of:
(or different invocations of the same function) (or different invocations of the same function)
- maximum constant height of a local value stack (depends on the function) - maximum constant height of a local value stack (depends on the function)
- current height of the local value stack is known at compile-time for each - current height of the local value stack is known at compile-time for each
intruction; a program violating this assumption is errorneous instruction; a program violating this assumption is erroneous
- compiled to a constant number of local variables / registers (unless the - compiled to a constant number of local variables / registers (unless the
target IR itself is a stack machine) target IR itself is a stack machine)
-} -}

View File

@ -4,7 +4,7 @@ module Juvix.Compiler.Concrete.Data.NameSignature.Builder
( mkNameSignature, ( mkNameSignature,
mkRecordNameSignature, mkRecordNameSignature,
HasNameSignature, HasNameSignature,
-- to supress unused warning -- to suppress unused warning
getBuilder, getBuilder,
) )
where where

View File

@ -140,7 +140,7 @@ instance Serialize (NameItem 'Scoped)
instance Serialize (NameItem 'Parsed) instance Serialize (NameItem 'Parsed)
data NameBlock (s :: Stage) = NameBlock data NameBlock (s :: Stage) = NameBlock
{ -- | Symbols map to themselves so we can retrive the location { -- | Symbols map to themselves so we can retrieve the location
-- | NOTE the index is wrt to the block, not the whole signature. -- | NOTE the index is wrt to the block, not the whole signature.
_nameBlock :: HashMap Symbol (NameItem s), _nameBlock :: HashMap Symbol (NameItem s),
_nameImplicit :: IsImplicit _nameImplicit :: IsImplicit

View File

@ -279,7 +279,7 @@ runExpressionParser fpath input = do
(_, Left err) -> return (Left (ErrMegaparsec (MegaparsecError err))) (_, Left err) -> return (Left (ErrMegaparsec (MegaparsecError err)))
(_, Right r) -> return (Right r) (_, Right r) -> return (Right r)
-- | The first pipe is optional, and thus we need a `Maybe`. The rest of the elements are guaranted to be given a `Just`. -- | The first pipe is optional, and thus we need a `Maybe`. The rest of the elements are guaranteed to be given a `Just`.
pipeSep1 :: (Member ParserResultBuilder r) => (Irrelevant (Maybe KeywordRef) -> ParsecS r a) -> ParsecS r (NonEmpty a) pipeSep1 :: (Member ParserResultBuilder r) => (Irrelevant (Maybe KeywordRef) -> ParsecS r a) -> ParsecS r (NonEmpty a)
pipeSep1 e = do pipeSep1 e = do
p <- Irrelevant <$> optional (kw kwPipe) p <- Irrelevant <$> optional (kw kwPipe)

View File

@ -353,13 +353,13 @@ substs t = umapN go
_ -> n _ -> n
-- | substitute a term t for the free variable with de Bruijn index 0, avoiding -- | substitute a term t for the free variable with de Bruijn index 0, avoiding
-- variable capture; shifts all free variabes with de Bruijn index > 0 by -1 (as -- variable capture; shifts all free variables with de Bruijn index > 0 by -1 (as
-- if the topmost binder was removed) -- if the topmost binder was removed)
subst :: Node -> Node -> Node subst :: Node -> Node -> Node
subst t = substs [t] subst t = substs [t]
-- | substitute a term t for the free variable with de Bruijn index idx, avoiding -- | substitute a term t for the free variable with de Bruijn index idx, avoiding
-- variable capture; shifts all free variabes with de Bruijn index > idx by -1 (as -- variable capture; shifts all free variables with de Bruijn index > idx by -1 (as
-- if the binder idx was removed) -- if the binder idx was removed)
substVar :: Index -> Node -> Node -> Node substVar :: Index -> Node -> Node -> Node
substVar idx t = umapN go substVar idx t = umapN go

View File

@ -58,7 +58,7 @@ shiftEmbedded wrappingLevel m = umapN go
-- * The number of let bindings added in step 1, equal to the total -- * The number of let bindings added in step 1, equal to the total
-- number of pattern binders in the matchbranch. -- number of pattern binders in the matchbranch.
-- --
-- * The auxillary bindings added in the translation (i.e bindings -- * The auxiliary bindings added in the translation (i.e bindings
-- not present in the original match bindings, added for nested -- not present in the original match bindings, added for nested
-- cases and case bindings). -- cases and case bindings).
-- --
@ -111,7 +111,7 @@ shiftEmbedded wrappingLevel m = umapN go
-- correct variables above. -- correct variables above.
-- --
-- The index for the free variable @x@ in the body has increased from 4 to 15. -- The index for the free variable @x@ in the body has increased from 4 to 15.
-- This is because we have added 3 binders around the body, 6 auxillary binders, -- This is because we have added 3 binders around the body, 6 auxiliary binders,
-- 1 binder for the lambda surrounding the case and 1 binder for the fail -- 1 binder for the lambda surrounding the case and 1 binder for the fail
-- branch. -- branch.
compileMatchBranch :: forall r. (Members '[InfoTableBuilder] r) => Indexed MatchBranch -> Sem r Node compileMatchBranch :: forall r. (Members '[InfoTableBuilder] r) => Indexed MatchBranch -> Sem r Node

View File

@ -7,7 +7,7 @@ import Juvix.Compiler.Core.Language
-- | Returns the node representing a function Int -> Nat that is used to transform -- | Returns the node representing a function Int -> Nat that is used to transform
-- literal integers to builtin Nat. The symbol representing the literalIntToNat function is passed -- literal integers to builtin Nat. The symbol representing the literalIntToNat function is passed
-- so that it can be called recusively. -- so that it can be called recursively.
literalIntToNatNode :: (Member InfoTableBuilder r) => Symbol -> Sem r Node literalIntToNatNode :: (Member InfoTableBuilder r) => Symbol -> Sem r Node
literalIntToNatNode sym = do literalIntToNatNode sym = do
md <- getModule md <- getModule

View File

@ -693,7 +693,7 @@ matchExpressions = go
(ExpressionInstanceHole {}, _) -> err (ExpressionInstanceHole {}, _) -> err
err :: Sem r a err :: Sem r a
err = throw @Text "Expression missmatch" err = throw @Text "Expression mismatch"
matchVars :: Name -> Name -> Sem r Bool matchVars :: Name -> Name -> Sem r Bool
matchVars va vb = do matchVars va vb = do

View File

@ -77,7 +77,7 @@ checkStrictlyPositiveOccurrences p = do
indName = indInfo ^. inductiveInfoName indName = indInfo ^. inductiveInfoName
{- The following `go` function determines if there is any negative {- The following `go` function determines if there is any negative
occurence of the symbol `name` in the given expression. The `inside` flag occurrence of the symbol `name` in the given expression. The `inside` flag
used below indicates whether the current search is performed on the left of used below indicates whether the current search is performed on the left of
an inner arrow or not. an inner arrow or not.
-} -}

View File

@ -507,7 +507,7 @@ addIdens idens = do
-- | Assumes the given function has been type checked. Does *not* register the -- | Assumes the given function has been type checked. Does *not* register the
-- function. -- function.
-- Conditons: -- Conditions:
-- 1. Only one clause. -- 1. Only one clause.
-- 2. No pattern matching. -- 2. No pattern matching.
-- 3. Terminates. -- 3. Terminates.

View File

@ -9,7 +9,7 @@ import Juvix.Compiler.Pipeline.Package.Base
import Juvix.Compiler.Pipeline.Root.Base import Juvix.Compiler.Pipeline.Root.Base
import Juvix.Prelude import Juvix.Prelude
-- | An option specifiying how symbols should be pruned in the Internal to Core translation -- | An option specifying how symbols should be pruned in the Internal to Core translation
data SymbolPruningMode data SymbolPruningMode
= FilterUnreachable = FilterUnreachable
| KeepAll | KeepAll

View File

@ -1,4 +1,4 @@
-- | An effect similar to Polysemy Fail but wihout an error message -- | An effect similar to Polysemy Fail but without an error message
module Juvix.Data.Effect.Fail where module Juvix.Data.Effect.Fail where
import Control.Exception qualified as X import Control.Exception qualified as X

View File

@ -13,7 +13,7 @@ newtype CloneEnv = CloneEnv
makeLenses ''CloneEnv makeLenses ''CloneEnv
-- | Run a git command in the current working direcotory of the parent process. -- | Run a git command in the current working directory of the parent process.
runGitCmd :: (Members '[Process, Error GitProcessError] r) => [Text] -> Sem r Text runGitCmd :: (Members '[Process, Error GitProcessError] r) => [Text] -> Sem r Text
runGitCmd args = do runGitCmd args = do
mcmd <- findExecutable' $(mkRelFile "git") mcmd <- findExecutable' $(mkRelFile "git")

View File

@ -21,7 +21,7 @@ instance Pretty GitCmdErrorDetails where
pretty d = pretty msg pretty d = pretty msg
where where
msg :: Text msg :: Text
msg = "Error ocurred when executing the git command with arguments: " <> show (d ^. gitCmdErrorDetailsArgs) msg = "Error occurred when executing the git command with arguments: " <> show (d ^. gitCmdErrorDetailsArgs)
instance Pretty GitProcessError where instance Pretty GitProcessError where
pretty = \case pretty = \case

View File

@ -186,7 +186,7 @@ instance ToGenericError StdinOrFileError where
return return
GenericError GenericError
{ _genericErrorLoc = singletonInterval (mkInitialLoc formatStdinPath), { _genericErrorLoc = singletonInterval (mkInitialLoc formatStdinPath),
_genericErrorMessage = prettyError "Neither JUVIX_FILE_OR_PROJECT nor --stdin option is choosen", _genericErrorMessage = prettyError "Neither JUVIX_FILE_OR_PROJECT nor --stdin option is chosen",
_genericErrorIntervals = [] _genericErrorIntervals = []
} }

View File

@ -30,7 +30,7 @@ infixr 5 <//>
infixr 5 <///> infixr 5 <///>
-- | Appens a relative path to some directory -- | Appends a relative path to some directory
(<///>) :: SomeBase Dir -> Path Rel t -> SomeBase t (<///>) :: SomeBase Dir -> Path Rel t -> SomeBase t
(<///>) s r = mapSomeBase (<//> r) s (<///>) s r = mapSomeBase (<//> r) s

View File

@ -39,7 +39,7 @@ testDescr NegTest {..} =
) )
case mapLeft fromJuvixError res of case mapLeft fromJuvixError res of
Left (Just err) -> whenJust (_checkErr err) assertFailure Left (Just err) -> whenJust (_checkErr err) assertFailure
Left Nothing -> assertFailure "An error ocurred but it was not when reading the package." Left Nothing -> assertFailure "An error occurred but it was not when reading the package."
Right {} -> assertFailure "There was no error when reading the package" Right {} -> assertFailure "There was no error when reading the package"
} }

View File

@ -41,7 +41,7 @@ testDescr root PosTest {..} =
$ buildDir $ buildDir
case res of case res of
Right p -> whenJust (_checkPackage p buildDir) assertFailure Right p -> whenJust (_checkPackage p buildDir) assertFailure
Left {} -> assertFailure "An error ocurred when reading the package." Left {} -> assertFailure "An error occurred when reading the package."
} }
allTests :: TestTree allTests :: TestTree

View File

@ -26,7 +26,7 @@ testDescr NegTest {..} =
res <- testRunIOEither entryPoint upToParsedSource res <- testRunIOEither entryPoint upToParsedSource
case mapLeft fromJuvixError res of case mapLeft fromJuvixError res of
Left (Just parErr) -> whenJust (_checkErr parErr) assertFailure Left (Just parErr) -> whenJust (_checkErr parErr) assertFailure
Left Nothing -> assertFailure "An error ocurred but it was not in the parser." Left Nothing -> assertFailure "An error occurred but it was not in the parser."
Right _ -> assertFailure "The parser did not find an error." Right _ -> assertFailure "The parser did not find an error."
} }

View File

@ -26,7 +26,7 @@ testDescr NegTest {..} =
res <- testRunIOEither entryPoint upToParsedSource res <- testRunIOEither entryPoint upToParsedSource
case mapLeft fromJuvixError res of case mapLeft fromJuvixError res of
Left (Just parErr) -> whenJust (_checkErr parErr) assertFailure Left (Just parErr) -> whenJust (_checkErr parErr) assertFailure
Left Nothing -> assertFailure "An error ocurred but it was not in the path resolver." Left Nothing -> assertFailure "An error occurred but it was not in the path resolver."
Right _ -> assertFailure "The path resolver did not find an error." Right _ -> assertFailure "The path resolver did not find an error."
} }

View File

@ -27,7 +27,7 @@ testDescr NegTest {..} =
res <- testRunIOEitherTermination entryPoint upToInternal res <- testRunIOEitherTermination entryPoint upToInternal
case mapLeft fromJuvixError res of case mapLeft fromJuvixError res of
Left (Just err) -> whenJust (_checkErr err) assertFailure Left (Just err) -> whenJust (_checkErr err) assertFailure
Left Nothing -> assertFailure "An error ocurred but it was not in the scoper." Left Nothing -> assertFailure "An error occurred but it was not in the scoper."
Right {} -> assertFailure "The scope checker did not find an error." Right {} -> assertFailure "The scope checker did not find an error."
} }
@ -219,14 +219,14 @@ scoperErrorTests =
ErrModuleDoesNotExportSymbol {} -> Nothing ErrModuleDoesNotExportSymbol {} -> Nothing
_ -> wrongError, _ -> wrongError,
NegTest NegTest
"Wrong number of interator initializers" "Wrong number of iterator initializers"
$(mkRelDir ".") $(mkRelDir ".")
$(mkRelFile "Iterators1.juvix") $(mkRelFile "Iterators1.juvix")
$ \case $ \case
ErrIteratorInitializer {} -> Nothing ErrIteratorInitializer {} -> Nothing
_ -> wrongError, _ -> wrongError,
NegTest NegTest
"Wrong number of interator ranges" "Wrong number of iterator ranges"
$(mkRelDir ".") $(mkRelDir ".")
$(mkRelFile "Iterators2.juvix") $(mkRelFile "Iterators2.juvix")
$ \case $ \case

View File

@ -25,7 +25,7 @@ testDescr NegTest {..} =
case mapLeft fromJuvixError result of case mapLeft fromJuvixError result of
Left (Just lexError) -> whenJust (_checkErr lexError) assertFailure Left (Just lexError) -> whenJust (_checkErr lexError) assertFailure
Left Nothing -> assertFailure "The termination checker did not find an error." Left Nothing -> assertFailure "The termination checker did not find an error."
Right _ -> assertFailure "An error ocurred but it was not by the termination checker." Right _ -> assertFailure "An error occurred but it was not by the termination checker."
} }
allTests :: TestTree allTests :: TestTree

View File

@ -27,7 +27,7 @@ testDescr NegTest {..} =
result <- testRunIOEither entryPoint upToInternalTyped result <- testRunIOEither entryPoint upToInternalTyped
case mapLeft fromJuvixError result of case mapLeft fromJuvixError result of
Left (Just tyError) -> whenJust (_checkErr tyError) assertFailure Left (Just tyError) -> whenJust (_checkErr tyError) assertFailure
Left Nothing -> assertFailure "An error ocurred but it was not in the type checker." Left Nothing -> assertFailure "An error occurred but it was not in the type checker."
Right _ -> assertFailure "The type checker did not find an error." Right _ -> assertFailure "The type checker did not find an error."
} }

View File

@ -33,7 +33,7 @@ testDescr Old.NegTest {..} =
result <- testRunIOEither entryPoint upToCore result <- testRunIOEither entryPoint upToCore
case mapLeft fromJuvixError result of case mapLeft fromJuvixError result of
Left (Just tyError) -> whenJust (_checkErr tyError) assertFailure Left (Just tyError) -> whenJust (_checkErr tyError) assertFailure
Left Nothing -> assertFailure "An error ocurred but it was not in the type checker." Left Nothing -> assertFailure "An error occurred but it was not in the type checker."
Right _ -> assertFailure "The type checker did not find an error." Right _ -> assertFailure "The type checker did not find an error."
} }

View File

@ -142,7 +142,7 @@ exampleFunction1
axiom undefined : {A : Type} -> A; axiom undefined : {A : Type} -> A;
-- 200 in the body is idented with respect to the start of the chain -- 200 in the body is indented with respect to the start of the chain
-- (at {A : Type}) -- (at {A : Type})
exampleFunction2 exampleFunction2
: {A : Type} : {A : Type}