├── extern └── .tokeignore ├── src ├── rattle │ ├── Options.hs │ ├── Main.hi │ ├── Bilist.hi │ ├── Main.hs │ ├── CmdOption.hs │ ├── Bilist.hs │ ├── Thread.hs │ ├── Rattle.hs │ ├── Paths.hs │ ├── Program.hs │ └── Derived.hs ├── core │ ├── .gitignore │ ├── Core │ ├── Core.hi │ ├── Exp2.txt │ ├── Core_old.hs │ ├── graphs │ │ ├── delta_7.dot │ │ ├── delta_2.dot │ │ ├── delta_4.dot │ │ ├── delta_6.dot │ │ ├── delta_1.dot │ │ ├── delta_3.dot │ │ ├── delta_12.dot │ │ ├── delta_17.dot │ │ ├── delta_14.dot │ │ ├── delta_8.dot │ │ ├── delta_5.dot │ │ ├── delta_0.dot │ │ ├── delta_16.dot │ │ ├── delta_9.dot │ │ ├── delta_11.dot │ │ ├── delta_13.dot │ │ ├── delta_15.dot │ │ ├── delta_18.dot │ │ ├── delta_19.dot │ │ ├── delta_10.dot │ │ ├── transitions │ │ │ ├── PiR-PiL-after.dot │ │ │ ├── Bang-BangD-before.dot │ │ │ ├── Bang-BangC-before.dot │ │ │ ├── Bang-BangD-after.dot │ │ │ └── PiR-PiL-before.dot │ │ └── delta_20.dot │ └── evaluator.js ├── .tokeignore ├── build │ ├── hash │ │ ├── .gitignore │ │ ├── XXHash.hi │ │ ├── commands.txt │ │ ├── XXHash.hs │ │ ├── hash.c │ │ └── hash.ll │ ├── Test │ │ ├── Assert │ │ ├── Assert.hi │ │ └── Assert.hs │ ├── Options.hs │ ├── mtime │ │ ├── mtime_statx.cpp │ │ ├── mtime_uring.cpp │ │ └── mtime_mac.cpp │ ├── Paths.hs │ ├── Model.hs │ ├── cycle_detector.hs │ └── Main.hs ├── features.txt ├── shake │ ├── History.Types.hs │ ├── Paths.hs │ ├── Default.hs │ ├── Classes.hs │ ├── Bilist.hs │ ├── Env.hs │ ├── OrderOnly.hs │ ├── Intern.hs │ ├── Network.hs │ ├── ListBuilder.hs │ ├── TypeMap.hs │ ├── Makefile.hs │ ├── Symlink.hs │ ├── Rerun.hs │ ├── Bloom.hs │ ├── Server.hs │ ├── Timing.hs │ ├── Type.hs │ ├── Fence.hs │ └── Cleanup.hs ├── model │ ├── rbp_test2.txt │ ├── rbp_test1.txt │ ├── RecTypes.hs │ └── verification.hs └── syntax │ └── lexer.hs ├── tests ├── expression_problem.txt ├── TypeSig.hs ├── OptimalSharing.hi ├── speed.txt ├── visitor.txt ├── runnable_output.txt ├── ApplicativeDo.hs ├── OptimalSharing.hs ├── mortage_interest.txt ├── dependencies.txt ├── GoPanic.go ├── mccarthy91.txt ├── system_f_fail.hs ├── Continuations │ ├── Wadler.hs │ ├── Tasks.hs │ ├── Exception.hs │ ├── Repeated-Cont.hs │ └── State.hs ├── notation.skt ├── Graph.idr ├── Context.txt ├── PrimeSquareRootTest.txt ├── parser_output.txt └── Pippinger.hs ├── docs ├── Reference │ ├── errors │ │ ├── non-nfc.txt │ │ ├── non-nfc-fixed.txt │ │ ├── unused-argument.txt │ │ ├── unused-argument-fixed.txt │ │ ├── unused-import-fixed.txt │ │ ├── map-noncollection.txt │ │ ├── no-fixed-point-fixed.txt │ │ ├── no-fixed-point.txt │ │ ├── nondet-toplevel.txt │ │ ├── map-noncollection-fixed.txt │ │ ├── meaningless.txt │ │ ├── nonfunction.txt │ │ ├── unused-import.txt │ │ ├── block-shadowing-fixed.txt │ │ ├── default-arguments.txt │ │ ├── failed-assert.txt │ │ ├── invalid-utf8-message.rst │ │ ├── nondet-exception.txt │ │ ├── too-many-arguments.txt │ │ ├── unused-result-message.rst │ │ ├── unused-variable-fixed.txt │ │ ├── block-shadowing.txt │ │ ├── confusable.txt │ │ ├── failed-assert-fixed.txt │ │ ├── nondet-toplevel-fixed.txt │ │ ├── nonfunction-fixed.txt │ │ ├── too-many-arguments-fixed.txt │ │ ├── unreachable-case-fixed.txt │ │ ├── unused-variable-message.rst │ │ ├── unused-variable.txt │ │ ├── unused-import-message.rst │ │ ├── automatic-propagation.txt │ │ ├── confusable-fixed.txt │ │ ├── meaningless-fixed.txt │ │ ├── nonfunction-message.rst │ │ ├── unused-result.txt │ │ ├── bad-indentation.txt │ │ ├── depr-default-argument.txt │ │ ├── implicit-argument-not-passed.txt │ │ ├── typos.txt │ │ ├── unhandled-exn-message.rst │ │ ├── unhandled-exn.txt │ │ ├── unreachable-case.txt │ │ ├── default-arguments-fixed.txt │ │ ├── nested-shadow.txt │ │ ├── bad-indentation-fixed.txt │ │ ├── inapplicable-type.txt │ │ ├── nested-shadow-fixed.txt │ │ ├── non-nfc-message.rst │ │ ├── typos-fixed.txt │ │ ├── unused-result-fixed.txt │ │ ├── ambiguous-identifier.txt │ │ ├── depr-default-argument-fixed.txt │ │ ├── implicit-argument-not-passed-fixed.txt │ │ ├── inapplicable-type-fixed.txt │ │ ├── equal-prio.txt │ │ ├── unhandled-exn-fixed.txt │ │ ├── meaningless-message.rst │ │ ├── unreducible-expr.txt │ │ ├── ambiguous-identifier-fixed.txt │ │ ├── nondet-concurrency.txt │ │ ├── map-noncollection-message.rst │ │ ├── unreachable-case-message.rst │ │ ├── bad-indentation-message.rst │ │ ├── unreducible-expr-fixed.txt │ │ ├── unused-argument-message.rst │ │ ├── nested-shadow-message.rst │ │ ├── nondet-concurrency-fixed.txt │ │ ├── nondet-exception-fixed.txt │ │ ├── nondet-exception-message.rst │ │ ├── typos-message.rst │ │ ├── automatic-propagation-fixed.txt │ │ ├── block-shadowing-message.rst │ │ ├── no-fixed-point-message.rst │ │ ├── syntactic-variadic-fixed.txt │ │ ├── too-many-arguments-message.rst │ │ ├── default-arguments-message.rst │ │ ├── equal-prio-fixed.txt │ │ ├── confusable-message.rst │ │ ├── failed-assert-message.rst │ │ ├── unreducible-expr-message.rst │ │ ├── implicit-argument-not-passed-message.rst │ │ ├── missing-override-message.rst │ │ ├── depr-default-argument-message.rst │ │ ├── nondet-concurrency-message.rst │ │ ├── inapplicable-type-message.rst │ │ ├── automatic-propagation-message.rst │ │ ├── syntactic-variadic.txt │ │ ├── ambiguous-identifier-message.rst │ │ ├── nondet-toplevel-message.rst │ │ ├── equal-prio-message.rst │ │ ├── missing-override.txt │ │ ├── missing-override-fixed.txt │ │ └── syntactic-variadic-message.rst │ ├── Fexprs.rst │ ├── index.rst │ └── Syntax.rst ├── _static │ ├── .tokeignore │ ├── finalizer.png │ ├── old_favicon.png │ ├── core_paradigms.png │ ├── hexagon_logo.png │ ├── paradigms_all.png │ ├── core_paradigms2.png │ ├── custom.css │ ├── hexagon_favicon.png │ ├── old_favicon_big.png │ ├── Method-combination.png │ ├── hexagon_logo_nowords.png │ ├── core_paradigms.dot │ ├── finalizer.dot │ ├── matrix-multiply.dot │ ├── AND_net.dot │ ├── AND_net_expr.dot │ ├── Stroscot_F2G2_Proof_Tree.tex │ ├── paradigms_all.dot │ ├── Stroscot_AND_Proof_Tree.tex │ ├── Stroscot_M_Proof_Tree.tex │ ├── AND_net_template.tex │ ├── AND_net_r.dot │ └── AND_net_r_expr.dot ├── zzreferences.rst ├── HowTo │ ├── index.rst │ ├── Install.rst │ ├── BuildSystem.rst │ └── Transactions.rst ├── GettingStarted │ ├── index.rst │ └── FAQ.rst ├── Commentary │ ├── Meta │ │ ├── index.rst │ │ └── Guidelines-locbylanguage.csv │ ├── Implementation │ │ ├── index.rst │ │ └── Implementation.rst │ ├── index.rst │ ├── Libraries │ │ └── index.rst │ └── Language │ │ └── index.rst ├── index.rst ├── Makefile └── conf.py ├── requirements.txt ├── CODE_OF_CONDUCT.md ├── glue ├── environment.txt ├── package_manager.txt ├── matching.txt ├── repl.txt ├── operations.txt ├── unique.txt ├── semantics.txt ├── ffi.txt ├── error_report.txt ├── poset.txt ├── packagemanager_model.txt ├── core_syntax.txt ├── reduction.txt ├── grammar.txt └── core_explicit.hs ├── .gitmodules ├── .gitignore ├── library ├── logging.txt ├── gmp.txt └── Vec.txt ├── LICENSE ├── README.md ├── CONTRIBUTING.rst ├── .github └── workflows │ └── main.yml └── default.nix /extern/.tokeignore: -------------------------------------------------------------------------------- 1 | * -------------------------------------------------------------------------------- /src/rattle/Options.hs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/core/.gitignore: -------------------------------------------------------------------------------- 1 | graphs -------------------------------------------------------------------------------- /tests/expression_problem.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/.tokeignore: -------------------------------------------------------------------------------- 1 | shake 2 | rattle 3 | -------------------------------------------------------------------------------- /src/build/hash/.gitignore: -------------------------------------------------------------------------------- 1 | xxHash/ 2 | -------------------------------------------------------------------------------- /docs/Reference/errors/non-nfc.txt: -------------------------------------------------------------------------------- 1 | print "à" 2 | -------------------------------------------------------------------------------- /docs/Reference/errors/non-nfc-fixed.txt: -------------------------------------------------------------------------------- 1 | print "à" 2 | -------------------------------------------------------------------------------- /docs/Reference/errors/unused-argument.txt: -------------------------------------------------------------------------------- 1 | k a b = a 2 | -------------------------------------------------------------------------------- /tests/TypeSig.hs: -------------------------------------------------------------------------------- 1 | x = (1 :: Integer) + (2 :: Integer) 2 | -------------------------------------------------------------------------------- /docs/Reference/errors/unused-argument-fixed.txt: -------------------------------------------------------------------------------- 1 | k a _ = a 2 | -------------------------------------------------------------------------------- /docs/Reference/errors/unused-import-fixed.txt: -------------------------------------------------------------------------------- 1 | print "done" 2 | -------------------------------------------------------------------------------- /docs/Reference/errors/map-noncollection.txt: -------------------------------------------------------------------------------- 1 | print (map (+1) 1) 2 | -------------------------------------------------------------------------------- /docs/Reference/errors/no-fixed-point-fixed.txt: -------------------------------------------------------------------------------- 1 | a = b 2 | 3 | print a -------------------------------------------------------------------------------- /docs/_static/.tokeignore: -------------------------------------------------------------------------------- 1 | *.svg 2 | *.aux 3 | *.pdf 4 | *.tex 5 | -------------------------------------------------------------------------------- /docs/Reference/errors/no-fixed-point.txt: -------------------------------------------------------------------------------- 1 | a | a != b = b 2 | 3 | print a -------------------------------------------------------------------------------- /docs/Reference/errors/nondet-toplevel.txt: -------------------------------------------------------------------------------- 1 | a = b 2 | a = c 3 | print a 4 | -------------------------------------------------------------------------------- /docs/Reference/errors/map-noncollection-fixed.txt: -------------------------------------------------------------------------------- 1 | print (map (+1) [1]) 2 | -------------------------------------------------------------------------------- /docs/Reference/errors/meaningless.txt: -------------------------------------------------------------------------------- 1 | foo x = foo (x-1) 2 | 3 | print (foo 10) 4 | -------------------------------------------------------------------------------- /docs/Reference/errors/nonfunction.txt: -------------------------------------------------------------------------------- 1 | foo a b = print (a + b) 2 | main = "x" 2 3 | -------------------------------------------------------------------------------- /docs/Reference/errors/unused-import.txt: -------------------------------------------------------------------------------- 1 | import module 2 | 3 | print "done" 4 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | sphinx 2 | sphinx_rtd_theme 3 | sphinxcontrib-bibtex>=2.0.0 4 | -------------------------------------------------------------------------------- /src/core/Core: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mathnerd314/stroscot/HEAD/src/core/Core -------------------------------------------------------------------------------- /docs/Reference/errors/block-shadowing-fixed.txt: -------------------------------------------------------------------------------- 1 | main = 2 | a = 2 3 | print a 4 | -------------------------------------------------------------------------------- /docs/Reference/errors/default-arguments.txt: -------------------------------------------------------------------------------- 1 | a {x=1,y=2} = x + y 2 | 3 | main = print a -------------------------------------------------------------------------------- /docs/Reference/errors/failed-assert.txt: -------------------------------------------------------------------------------- 1 | a = 0 2 | print "test" 3 | assert (a != 0) 4 | -------------------------------------------------------------------------------- /docs/Reference/errors/invalid-utf8-message.rst: -------------------------------------------------------------------------------- 1 | Invalid UTF-8 byte sequence replaced. 2 | -------------------------------------------------------------------------------- /docs/Reference/errors/nondet-exception.txt: -------------------------------------------------------------------------------- 1 | e = throw b + throw c 2 | print (try e) 3 | -------------------------------------------------------------------------------- /docs/Reference/errors/too-many-arguments.txt: -------------------------------------------------------------------------------- 1 | foo x y = x + y 2 | print (foo 1 2 3) 3 | -------------------------------------------------------------------------------- /docs/Reference/errors/unused-result-message.rst: -------------------------------------------------------------------------------- 1 | Unused result. Try using 'void'. 2 | -------------------------------------------------------------------------------- /docs/Reference/errors/unused-variable-fixed.txt: -------------------------------------------------------------------------------- 1 | main = 2 | a = 1 3 | print a 4 | -------------------------------------------------------------------------------- /src/core/Core.hi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mathnerd314/stroscot/HEAD/src/core/Core.hi -------------------------------------------------------------------------------- /docs/Reference/Fexprs.rst: -------------------------------------------------------------------------------- 1 | .. _fexprs: 2 | 3 | Metaprogramming 4 | ############### 5 | 6 | -------------------------------------------------------------------------------- /docs/Reference/errors/block-shadowing.txt: -------------------------------------------------------------------------------- 1 | main = 2 | a = 1 3 | a = 2 4 | print a 5 | -------------------------------------------------------------------------------- /docs/Reference/errors/confusable.txt: -------------------------------------------------------------------------------- 1 | µ = 1/1000000 2 | μ = "greek mu" 3 | print [µ, μ] 4 | -------------------------------------------------------------------------------- /docs/Reference/errors/failed-assert-fixed.txt: -------------------------------------------------------------------------------- 1 | a = 1 2 | print "test" 3 | assert (a != 0) 4 | -------------------------------------------------------------------------------- /docs/Reference/errors/nondet-toplevel-fixed.txt: -------------------------------------------------------------------------------- 1 | a = b 2 | a = c 3 | print (allValuesOf a) 4 | -------------------------------------------------------------------------------- /docs/Reference/errors/nonfunction-fixed.txt: -------------------------------------------------------------------------------- 1 | foo a b = print (a + b) 2 | main = foo "x" 2 3 | -------------------------------------------------------------------------------- /docs/Reference/errors/too-many-arguments-fixed.txt: -------------------------------------------------------------------------------- 1 | foo x y = x + y 2 | print (foo 1 2) 3 | -------------------------------------------------------------------------------- /docs/Reference/errors/unreachable-case-fixed.txt: -------------------------------------------------------------------------------- 1 | foo 1 = "hello" 2 | 3 | print (foo 1) 4 | -------------------------------------------------------------------------------- /docs/Reference/errors/unused-variable-message.rst: -------------------------------------------------------------------------------- 1 | Unused variable 'b'. Try removing it. 2 | -------------------------------------------------------------------------------- /docs/Reference/errors/unused-variable.txt: -------------------------------------------------------------------------------- 1 | main = 2 | a = 1 3 | b = 2 4 | print a 5 | -------------------------------------------------------------------------------- /docs/zzreferences.rst: -------------------------------------------------------------------------------- 1 | References 2 | ########## 3 | 4 | .. bibliography:: references.bib 5 | -------------------------------------------------------------------------------- /src/rattle/Main.hi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mathnerd314/stroscot/HEAD/src/rattle/Main.hi -------------------------------------------------------------------------------- /docs/Reference/errors/unused-import-message.rst: -------------------------------------------------------------------------------- 1 | Module import 'module' is unused. Remove it. 2 | -------------------------------------------------------------------------------- /src/build/Test/Assert: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mathnerd314/stroscot/HEAD/src/build/Test/Assert -------------------------------------------------------------------------------- /src/rattle/Bilist.hi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mathnerd314/stroscot/HEAD/src/rattle/Bilist.hi -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | See [docs/Reference/Code-of-conduct.rst](docs/Reference/Code-of-conduct.rst). 2 | -------------------------------------------------------------------------------- /docs/Reference/errors/automatic-propagation.txt: -------------------------------------------------------------------------------- 1 | a = error "urk" 2 | b = a + 2 3 | main = print b 4 | -------------------------------------------------------------------------------- /docs/Reference/errors/confusable-fixed.txt: -------------------------------------------------------------------------------- 1 | µ1 = 1/1000000 2 | μ2 = "greek mu" 3 | print [µ1, μ2] 4 | -------------------------------------------------------------------------------- /docs/Reference/errors/meaningless-fixed.txt: -------------------------------------------------------------------------------- 1 | foo 0 = 0 2 | foo x = foo (x-1) 3 | 4 | print (foo 10) 5 | -------------------------------------------------------------------------------- /docs/Reference/errors/nonfunction-message.rst: -------------------------------------------------------------------------------- 1 | "x" is not a function. Maybe you forgot a symbol? 2 | -------------------------------------------------------------------------------- /docs/Reference/errors/unused-result.txt: -------------------------------------------------------------------------------- 1 | f = { return 1 } 2 | 3 | main = 4 | f 5 | print "done" 6 | -------------------------------------------------------------------------------- /tests/OptimalSharing.hi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mathnerd314/stroscot/HEAD/tests/OptimalSharing.hi -------------------------------------------------------------------------------- /docs/Reference/errors/bad-indentation.txt: -------------------------------------------------------------------------------- 1 | f = 2 | a = 1 3 | b = 2 4 | return (a+b) 5 | 6 | print f 7 | -------------------------------------------------------------------------------- /docs/Reference/errors/depr-default-argument.txt: -------------------------------------------------------------------------------- 1 | a {x = 2 !deprecated} = x * 3 2 | main = 3 | print a 4 | -------------------------------------------------------------------------------- /docs/Reference/errors/implicit-argument-not-passed.txt: -------------------------------------------------------------------------------- 1 | a k = 1 2 | b k = k + a 3 | 4 | print (b {k:2}) 5 | -------------------------------------------------------------------------------- /docs/Reference/errors/typos.txt: -------------------------------------------------------------------------------- 1 | test = 1 2 | exmple = 2 3 | 4 | main = 5 | print tst 6 | print example -------------------------------------------------------------------------------- /docs/Reference/errors/unhandled-exn-message.rst: -------------------------------------------------------------------------------- 1 | Unhandled exception 'Error'. Add a try or catch handler. 2 | -------------------------------------------------------------------------------- /docs/Reference/errors/unhandled-exn.txt: -------------------------------------------------------------------------------- 1 | main = 2 | print "1" 3 | throw Error 4 | print "2" 5 | 6 | -------------------------------------------------------------------------------- /docs/Reference/errors/unreachable-case.txt: -------------------------------------------------------------------------------- 1 | foo 1 = "hello" 2 | foo 2 = "world" 3 | 4 | print (foo 1) 5 | -------------------------------------------------------------------------------- /docs/_static/finalizer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mathnerd314/stroscot/HEAD/docs/_static/finalizer.png -------------------------------------------------------------------------------- /glue/environment.txt: -------------------------------------------------------------------------------- 1 | dictionary implementation 2 | set 3 | get 4 | 5 | - order elements were added 6 | -------------------------------------------------------------------------------- /src/build/Test/Assert.hi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mathnerd314/stroscot/HEAD/src/build/Test/Assert.hi -------------------------------------------------------------------------------- /src/build/hash/XXHash.hi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mathnerd314/stroscot/HEAD/src/build/hash/XXHash.hi -------------------------------------------------------------------------------- /docs/HowTo/index.rst: -------------------------------------------------------------------------------- 1 | How to 2 | ###### 3 | 4 | .. toctree:: 5 | :maxdepth: 2 6 | :glob: 7 | 8 | * 9 | -------------------------------------------------------------------------------- /docs/Reference/errors/default-arguments-fixed.txt: -------------------------------------------------------------------------------- 1 | a {x=1,y=2} = x + y 2 | 3 | main = print (a {x=1,y=2}) 4 | -------------------------------------------------------------------------------- /docs/Reference/errors/nested-shadow.txt: -------------------------------------------------------------------------------- 1 | f = f 4 where 2 | f 0 = 0 3 | f x = f (x-1) 4 | assert (f == 0) 5 | -------------------------------------------------------------------------------- /docs/_static/old_favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mathnerd314/stroscot/HEAD/docs/_static/old_favicon.png -------------------------------------------------------------------------------- /docs/Reference/errors/bad-indentation-fixed.txt: -------------------------------------------------------------------------------- 1 | f = 2 | a = 1 3 | b = 2 4 | return (a+b) 5 | 6 | print f 7 | -------------------------------------------------------------------------------- /docs/Reference/errors/inapplicable-type.txt: -------------------------------------------------------------------------------- 1 | a = i16 1 2 | foo (n : i32) = n * 2 3 | main = 4 | print (foo a) 5 | -------------------------------------------------------------------------------- /docs/Reference/errors/nested-shadow-fixed.txt: -------------------------------------------------------------------------------- 1 | f = g 4 where 2 | g 0 = 0 3 | g x = g (x-1) 4 | assert (f == 0) 5 | -------------------------------------------------------------------------------- /docs/Reference/errors/non-nfc-message.rst: -------------------------------------------------------------------------------- 1 | Text "à" is not in Unicode Normal Form C. Automatically normalizing. 2 | -------------------------------------------------------------------------------- /docs/Reference/errors/typos-fixed.txt: -------------------------------------------------------------------------------- 1 | test = 1 2 | example = 2 3 | 4 | main = 5 | print test 6 | print example -------------------------------------------------------------------------------- /docs/Reference/errors/unused-result-fixed.txt: -------------------------------------------------------------------------------- 1 | f = { return 1 } 2 | 3 | main = 4 | void f 5 | print "done" 6 | -------------------------------------------------------------------------------- /docs/_static/core_paradigms.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mathnerd314/stroscot/HEAD/docs/_static/core_paradigms.png -------------------------------------------------------------------------------- /docs/_static/hexagon_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mathnerd314/stroscot/HEAD/docs/_static/hexagon_logo.png -------------------------------------------------------------------------------- /docs/_static/paradigms_all.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mathnerd314/stroscot/HEAD/docs/_static/paradigms_all.png -------------------------------------------------------------------------------- /src/rattle/Main.hs: -------------------------------------------------------------------------------- 1 | {-# OPTIONS_GHC -Wno-unused-imports #-} -- Semigroup moved for GHC 8.8 2 | 3 | main = print "test" -------------------------------------------------------------------------------- /docs/Reference/errors/ambiguous-identifier.txt: -------------------------------------------------------------------------------- 1 | import module { a = 1 } 2 | import module { a = 2 } 3 | 4 | print a 5 | -------------------------------------------------------------------------------- /docs/Reference/errors/depr-default-argument-fixed.txt: -------------------------------------------------------------------------------- 1 | a {x = 2 !deprecated} = x * 3 2 | main = 3 | print (a {x=2}) 4 | -------------------------------------------------------------------------------- /docs/Reference/errors/implicit-argument-not-passed-fixed.txt: -------------------------------------------------------------------------------- 1 | a k = 1 2 | b k = k + a { k=k } 3 | 4 | print (b {k:2}) 5 | -------------------------------------------------------------------------------- /docs/Reference/errors/inapplicable-type-fixed.txt: -------------------------------------------------------------------------------- 1 | a = i32 1 2 | foo (n : i32) = n * 2 3 | main = 4 | print (foo a) 5 | -------------------------------------------------------------------------------- /docs/_static/core_paradigms2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mathnerd314/stroscot/HEAD/docs/_static/core_paradigms2.png -------------------------------------------------------------------------------- /docs/_static/custom.css: -------------------------------------------------------------------------------- 1 | .wy-table-responsive table td, .wy-table-responsive table th { 2 | white-space: normal; 3 | } 4 | -------------------------------------------------------------------------------- /docs/_static/hexagon_favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mathnerd314/stroscot/HEAD/docs/_static/hexagon_favicon.png -------------------------------------------------------------------------------- /docs/_static/old_favicon_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mathnerd314/stroscot/HEAD/docs/_static/old_favicon_big.png -------------------------------------------------------------------------------- /docs/Reference/errors/equal-prio.txt: -------------------------------------------------------------------------------- 1 | clause c1 2 | f 1 y = 1 3 | 4 | clause c2 5 | f x 2 = 2 6 | 7 | prioConstrain c1 = c2 8 | -------------------------------------------------------------------------------- /docs/Reference/errors/unhandled-exn-fixed.txt: -------------------------------------------------------------------------------- 1 | main = 2 | print "1" 3 | print . try $ throw Error 4 | print "2" 5 | 6 | -------------------------------------------------------------------------------- /docs/_static/Method-combination.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mathnerd314/stroscot/HEAD/docs/_static/Method-combination.png -------------------------------------------------------------------------------- /src/features.txt: -------------------------------------------------------------------------------- 1 | features = 2 | { "some-external-tool" 3 | , "a-plugin" 4 | , "a-breaking-semantic-change" 5 | } 6 | -------------------------------------------------------------------------------- /docs/Reference/errors/meaningless-message.rst: -------------------------------------------------------------------------------- 1 | Term 'foo 10' is meaningless (perpetually reduces). Maybe you forgot a base case? 2 | -------------------------------------------------------------------------------- /docs/Reference/errors/unreducible-expr.txt: -------------------------------------------------------------------------------- 1 | foo 1 = 1 2 | 3 | bar (n : Integer) = print "hi" 4 | 5 | main = 6 | bar (foo 2) 7 | -------------------------------------------------------------------------------- /docs/Reference/index.rst: -------------------------------------------------------------------------------- 1 | Language Reference 2 | ################## 3 | 4 | .. toctree:: 5 | :maxdepth: 2 6 | :glob: 7 | 8 | * -------------------------------------------------------------------------------- /docs/_static/hexagon_logo_nowords.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mathnerd314/stroscot/HEAD/docs/_static/hexagon_logo_nowords.png -------------------------------------------------------------------------------- /docs/Reference/errors/ambiguous-identifier-fixed.txt: -------------------------------------------------------------------------------- 1 | import module { a = 1 } as x 2 | import module { a = 2 } as y 3 | 4 | print x.a 5 | -------------------------------------------------------------------------------- /docs/Reference/errors/nondet-concurrency.txt: -------------------------------------------------------------------------------- 1 | A = mut 0 2 | t1 = fork { A := 1 } 3 | t2 = fork { A := 2 } 4 | join (t1, t2) 5 | print A 6 | -------------------------------------------------------------------------------- /docs/Reference/errors/map-noncollection-message.rst: -------------------------------------------------------------------------------- 1 | Value '1' is not iterable, so 'map' is not defined. Try wrapping the value in a list. 2 | -------------------------------------------------------------------------------- /docs/Reference/errors/unreachable-case-message.rst: -------------------------------------------------------------------------------- 1 | Case 'foo 2' is dead code (unreachable). Either remove it or add it to the control flow. 2 | -------------------------------------------------------------------------------- /docs/Reference/errors/bad-indentation-message.rst: -------------------------------------------------------------------------------- 1 | Mismatched indentation: line 2 uses 2 spaces, but line 3 uses 1 tab. Use consistent indentation. -------------------------------------------------------------------------------- /docs/Reference/errors/unreducible-expr-fixed.txt: -------------------------------------------------------------------------------- 1 | foo 1 = 1 2 | foo 2 = 2 3 | 4 | bar (n : Integer) = print n 5 | 6 | main = 7 | bar (foo 2) 8 | -------------------------------------------------------------------------------- /docs/Reference/errors/unused-argument-message.rst: -------------------------------------------------------------------------------- 1 | Argument 'b' in function declaration 'k' is unused. Replace it with a wildcard pattern ('_'). 2 | -------------------------------------------------------------------------------- /tests/speed.txt: -------------------------------------------------------------------------------- 1 | The compielr should be reasonable fast (10 seconds to compile itself). But it's not worth measuring this early in development. 2 | -------------------------------------------------------------------------------- /docs/Reference/errors/nested-shadow-message.rst: -------------------------------------------------------------------------------- 1 | Function declaration 'f' on lines 2-3 shadows variable declaration on line 1. I suggest renaming it. 2 | -------------------------------------------------------------------------------- /docs/Reference/errors/nondet-concurrency-fixed.txt: -------------------------------------------------------------------------------- 1 | A = mut 0 2 | t1 = fork { A := 1 } 3 | t2 = fork { join t1; A := 2 } 4 | join (t1, t2) 5 | print A 6 | -------------------------------------------------------------------------------- /docs/Reference/errors/nondet-exception-fixed.txt: -------------------------------------------------------------------------------- 1 | e = 2 | b' = force (throw b) 3 | c' = force (throw c) 4 | return (b' + c') 5 | print (try e) 6 | -------------------------------------------------------------------------------- /docs/Reference/errors/nondet-exception-message.rst: -------------------------------------------------------------------------------- 1 | Multiple exceptions may be caught in expression 'try e'. Use 'force' to fix the evaluation order. 2 | -------------------------------------------------------------------------------- /docs/Reference/errors/typos-message.rst: -------------------------------------------------------------------------------- 1 | Unbound identifier 'tst'. Did you mean 'test'? 2 | 3 | Unbound identifier 'example'. Did you mean 'exmple'? 4 | -------------------------------------------------------------------------------- /docs/Reference/errors/automatic-propagation-fixed.txt: -------------------------------------------------------------------------------- 1 | a = error "urk" 2 | b = case a of 3 | (e : Exception) -> e 4 | a -> a + 2 5 | main = print b 6 | -------------------------------------------------------------------------------- /tests/visitor.txt: -------------------------------------------------------------------------------- 1 | get a list of all comments from an AST 2 | classes that have no superclasses 3 | direct and indirect subclasses 4 | list of superclasses 5 | -------------------------------------------------------------------------------- /docs/Reference/errors/block-shadowing-message.rst: -------------------------------------------------------------------------------- 1 | Second declaration of 'a' shadows earlier declaration. I suggest renaming or deleting one of the declarations. -------------------------------------------------------------------------------- /docs/Reference/errors/no-fixed-point-message.rst: -------------------------------------------------------------------------------- 1 | Rule 'a | a != b' contradicts itself and has been ignored. Either simplify the condition or remove the rule. 2 | -------------------------------------------------------------------------------- /docs/Reference/errors/syntactic-variadic-fixed.txt: -------------------------------------------------------------------------------- 1 | c = sum $arguments 2 | 3 | print (c 1 2 3) 4 | 5 | a = \x -> c 1 x 6 | b = a 2 7 | 8 | print b 9 | 10 | -------------------------------------------------------------------------------- /docs/Reference/errors/too-many-arguments-message.rst: -------------------------------------------------------------------------------- 1 | 'foo' requires 2 arguments, but has been given 3, and its result is not a function. 2 | Try deleting the extra arguments. 3 | -------------------------------------------------------------------------------- /docs/Reference/errors/default-arguments-message.rst: -------------------------------------------------------------------------------- 1 | Function 'a' is called using default values of parameters 'x', 'y'. Please call the function using explicit values 'a {x=1,y=2}'. -------------------------------------------------------------------------------- /docs/Reference/errors/equal-prio-fixed.txt: -------------------------------------------------------------------------------- 1 | clause c1 2 | f 1 y = 1 3 | 4 | clause c2 5 | f x 2 = 2 6 | 7 | clause c3 8 | f 1 2 = 3 9 | 10 | prioConstrain c1 = c2 = c3 11 | -------------------------------------------------------------------------------- /docs/Reference/errors/confusable-message.rst: -------------------------------------------------------------------------------- 1 | Identifiers 'µ' (MICRO SIGN) and 'μ' (GREEK SMALL LETTER MU) look very similar in common fonts. Change them to be more visually distinct. 2 | -------------------------------------------------------------------------------- /docs/Reference/errors/failed-assert-message.rst: -------------------------------------------------------------------------------- 1 | Assertion 'a != 0' failed. 'a' received its value '0' at line 1. You may change the assertion or ensure 'a' receives a different value. 2 | -------------------------------------------------------------------------------- /docs/Reference/errors/unreducible-expr-message.rst: -------------------------------------------------------------------------------- 1 | Expression 'foo 2' does not reduce, and there are no matching rules for this expression. 2 | 3 | Consider adding a reduction rule. 4 | -------------------------------------------------------------------------------- /docs/GettingStarted/index.rst: -------------------------------------------------------------------------------- 1 | Getting started 2 | ################################# 3 | 4 | .. toctree:: 5 | :maxdepth: 2 6 | 7 | Introduction 8 | FAQ 9 | StyleGuide 10 | -------------------------------------------------------------------------------- /docs/Reference/errors/implicit-argument-not-passed-message.rst: -------------------------------------------------------------------------------- 1 | Argument 'k' of function 'b' was not passed implicitly to 'a', leading to it being undefined. I suggest passing it explicitly. 2 | -------------------------------------------------------------------------------- /glue/package_manager.txt: -------------------------------------------------------------------------------- 1 | need this but designing it is hard 2 | 3 | for now I guess we'll use scripts that run wget 4 | 5 | later something interesting based on Nix + Shake + buildsome etc. 6 | -------------------------------------------------------------------------------- /docs/Reference/errors/missing-override-message.rst: -------------------------------------------------------------------------------- 1 | Identifier 'foo' could refer to 'module1.foo' or 'module2.foo' and is ambiguous. Specify the module or use 'override' to combine the identifiers. 2 | -------------------------------------------------------------------------------- /docs/Reference/errors/depr-default-argument-message.rst: -------------------------------------------------------------------------------- 1 | The default value of argument 'x' of function 'a' has been deprecated and may be removed in a future release. Please add the explicit value '{x = 2}'. 2 | -------------------------------------------------------------------------------- /docs/Reference/errors/nondet-concurrency-message.rst: -------------------------------------------------------------------------------- 1 | Variable 'A' may have multiple values due to concurrent execution. Insert synchronization operations or otherwise ensure that the program is deterministic. 2 | -------------------------------------------------------------------------------- /glue/matching.txt: -------------------------------------------------------------------------------- 1 | match (Pvar x) v = [(x,v)] 2 | match (Pcst i) (Vcst j) = if i≡j then [] else error "value mismatch" 3 | match (Ppair p q) (Vpair v w) = match p v ++ match q w 4 | match = error "pattern mismatch" 5 | -------------------------------------------------------------------------------- /glue/repl.txt: -------------------------------------------------------------------------------- 1 | investigate 2 | - jupyter 3 | - ghci 4 | - Idris 5 | 6 | main: 7 | print "Welcome" 8 | loop 9 | input = prompt (">") 10 | result = evaluate(parse(input)) 11 | write(result) 12 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "extern/clock"] 2 | path = extern/clock 3 | url = git@github.com:Mathnerd314/clock.git 4 | [submodule "extern/xxHash"] 5 | path = extern/xxHash 6 | url = git@github.com:Cyan4973/xxHash.git 7 | -------------------------------------------------------------------------------- /docs/Reference/errors/inapplicable-type-message.rst: -------------------------------------------------------------------------------- 1 | Function foo does not have any rules for value 'i16 1'. The most similar rule is 'foo (n : i32)'. Consider modifying the type of 'a' or adding another reduction rule. 2 | -------------------------------------------------------------------------------- /docs/Reference/errors/automatic-propagation-message.rst: -------------------------------------------------------------------------------- 1 | Exception "urk" may be thrown by 'a' and automatically propagated out of 'b'. Consider adding explicit exception handling or marking with the function 'rethrowing'. 2 | -------------------------------------------------------------------------------- /src/build/hash/commands.txt: -------------------------------------------------------------------------------- 1 | nix-shell ../../.. 2 | clang -O3 -S -emit-llvm hash.c && sed -i 's/preserve_allcc/ghccc/' hash.ll 3 | ghc -O4 -fllvm -keep-llvm-files -fforce-recomp -ddump-simpl -ddump-to-file XXHash.hs hash.ll 4 | -------------------------------------------------------------------------------- /docs/Commentary/Meta/index.rst: -------------------------------------------------------------------------------- 1 | Meta 2 | #### 3 | 4 | This section is focused on non-technical details of the language - goals, project structure, and so on. 5 | 6 | .. toctree:: 7 | :maxdepth: 2 8 | :glob: 9 | 10 | * -------------------------------------------------------------------------------- /docs/Reference/errors/syntactic-variadic.txt: -------------------------------------------------------------------------------- 1 | c = sum $arguments 2 | 3 | print ((c 1 2) 3) 4 | # error: 3 3 is not reducible 5 | 6 | a = c 1 7 | b = a 2 8 | 9 | print b 10 | # error: 1 2 is not reducible 11 | 12 | -------------------------------------------------------------------------------- /docs/Reference/errors/ambiguous-identifier-message.rst: -------------------------------------------------------------------------------- 1 | Ambiguous identifier 'a' could refer to anonymous module import on line 1 or anonymous module import on line 2. 2 | Please remove one import or disambiguate using qualified names. 3 | -------------------------------------------------------------------------------- /tests/runnable_output.txt: -------------------------------------------------------------------------------- 1 | x = input number 2 | display x 3 | 4 | foo = 5 | x = 0 6 | x += 1 7 | provide x 8 | 9 | obtain http_server 10 | main = 11 | parse_args 12 | build_folder 13 | http_server.serve(folder) 14 | -------------------------------------------------------------------------------- /docs/Reference/errors/nondet-toplevel-message.rst: -------------------------------------------------------------------------------- 1 | Unresolved nondeterminism at top-level: 'a' may evaluate to 'b' or 'c'. Remove the nondeterminism by modifying reduction rules or using a meta-evaluation function such as 'allValuesOf'. 2 | -------------------------------------------------------------------------------- /glue/operations.txt: -------------------------------------------------------------------------------- 1 | Add = Number + Number priority 1; 2 | Subtract = Number - Number priority 1; 3 | Multiply = Number * Number priority 2; 4 | Divide = Number / Number priority 2; -- todo: divide by zero 5 | 6 | print Number 7 | print String 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | _build 2 | .buildinfo 3 | vscode 4 | .vscode 5 | references/ 6 | *.aux 7 | *.pdf 8 | docs/_static/AND_net.tex 9 | docs/_static/AND_net_expr.tex 10 | docs/_static/AND_net_r.tex 11 | docs/_static/AND_net_r_expr.tex 12 | src/build/clock -------------------------------------------------------------------------------- /docs/HowTo/Install.rst: -------------------------------------------------------------------------------- 1 | How to install Stroscot 2 | ####################### 3 | 4 | Checkout the git repository. Enter the Nix shell at the root of the repo. 5 | 6 | Most of the code is self-contained files, so just run it with ghci or similar. 7 | -------------------------------------------------------------------------------- /docs/Reference/errors/equal-prio-message.rst: -------------------------------------------------------------------------------- 1 | Clauses 'c1' and 'c2' have equal declared priority, but neither is more specific than the other. Furthermore they conflict for the expression 'f 1 2'. Set one to have higher priority or fix the conflict. 2 | -------------------------------------------------------------------------------- /library/logging.txt: -------------------------------------------------------------------------------- 1 | need some kind of logging API: 2 | 3 | logger = getLogger 4 | 5 | logger.debug("a=${foo} b=${bar}") 6 | 7 | verbose = Level 50 "verbose" 8 | logger.log(verbose, "hahaha") 9 | 10 | also timing / performance tracking 11 | -------------------------------------------------------------------------------- /src/build/Options.hs: -------------------------------------------------------------------------------- 1 | import Command 2 | 3 | data CotOptions = Options 4 | { commandOptions :: [CmdOption] -- ^ Defaults to ``[]``. Additional options to be passed to all command invocations. 5 | } 6 | 7 | defaultCotOptions = Options [] 8 | 9 | -------------------------------------------------------------------------------- /tests/ApplicativeDo.hs: -------------------------------------------------------------------------------- 1 | data Expr = Var | App Expr Expr | Lambda Pat Expr | Tuple [Expr] | Do Seq Expr 2 | 3 | data Pattern = Var | Tuple [Pattern] 4 | 5 | data Seq = [Stmt] 6 | 7 | data Stmt = ParBlock [Seq] | Bind Pat | Expr | Let [(Pat,Expr)] Expr 8 | -------------------------------------------------------------------------------- /tests/OptimalSharing.hs: -------------------------------------------------------------------------------- 1 | module Example where 2 | 3 | {-} 4 | foo 0 = 1 5 | foo n = 6 | let a = \x -> (foo (n - 1)) in 7 | a 2 + a 3 8 | 9 | main = print (foo 3) 10 | -} 11 | 12 | dbl g w = g (g w) 13 | y h = dbl (\w -> h (h w)) 14 | x = dbl y 15 | -------------------------------------------------------------------------------- /docs/Reference/errors/missing-override.txt: -------------------------------------------------------------------------------- 1 | module1 = module { 2 | foo (x : i32) = 1 3 | } 4 | 5 | 6 | module2 = module { 7 | import module1 8 | foo (x : i16) = 2 9 | } 10 | 11 | import module1, module2 12 | 13 | f = force foo 14 | print (map foo [1,2]) 15 | -------------------------------------------------------------------------------- /docs/Commentary/Implementation/index.rst: -------------------------------------------------------------------------------- 1 | Implementation 2 | ############## 3 | 4 | This section is focused on implementation details of the language - what algorithms and concepts are needed to efficiently run the semantics. 5 | 6 | .. toctree:: 7 | :maxdepth: 2 8 | :glob: 9 | 10 | * -------------------------------------------------------------------------------- /docs/Reference/errors/missing-override-fixed.txt: -------------------------------------------------------------------------------- 1 | module1 = module { 2 | foo (x : i32) = 1 3 | } 4 | 5 | 6 | module2 = module { 7 | import module1 8 | override foo 9 | foo (x : i16) = 2 10 | } 11 | 12 | import module1, module2 13 | 14 | f = force foo 15 | print (map foo [1,2]) 16 | -------------------------------------------------------------------------------- /docs/_static/core_paradigms.dot: -------------------------------------------------------------------------------- 1 | digraph paradigms { 2 | "term rewriting" -> relation 3 | function -> relation 4 | relation -> set 5 | boolean -> constraint 6 | constraint -> optimization 7 | set -> boolean 8 | optimization -> relation 9 | optimization -> function 10 | } 11 | -------------------------------------------------------------------------------- /docs/Commentary/index.rst: -------------------------------------------------------------------------------- 1 | Commentary 2 | ########## 3 | 4 | Every language needs an explanation of all the decisions made and possible options considered. 5 | 6 | .. toctree:: 7 | :maxdepth: 2 8 | 9 | Language/index 10 | Implementation/index 11 | Libraries/index 12 | Meta/index 13 | -------------------------------------------------------------------------------- /docs/Commentary/Libraries/index.rst: -------------------------------------------------------------------------------- 1 | Libraries 2 | ######### 3 | 4 | This section is focused on details of the standard library and syntax of the language. The core language is the current focus of development so this section is naturally a bit vague. 5 | 6 | .. toctree:: 7 | :maxdepth: 2 8 | :glob: 9 | 10 | * -------------------------------------------------------------------------------- /src/build/mtime/mtime_statx.cpp: -------------------------------------------------------------------------------- 1 | #ifdef __NR_statx 2 | 3 | #include 4 | 5 | static int test_statx(struct io_uring *ring, const char *path) 6 | { 7 | struct statx x; 8 | int ret; 9 | ret = statx(-1, path, 0, STATX_ALL, &x); 10 | if (ret < 0) 11 | return ret; 12 | return 0; 13 | } 14 | #endif /* __NR_statx */ 15 | -------------------------------------------------------------------------------- /src/shake/History.Types.hs: -------------------------------------------------------------------------------- 1 | 2 | module Development.Shake.Internal.History.Types( 3 | BS_QTypeRep, BS_Key, BS_Store, BS_Identity 4 | ) where 5 | 6 | import qualified Data.ByteString as BS 7 | 8 | type BS_QTypeRep = BS.ByteString 9 | type BS_Key = BS.ByteString 10 | type BS_Store = BS.ByteString 11 | type BS_Identity = BS.ByteString 12 | -------------------------------------------------------------------------------- /docs/Commentary/Language/index.rst: -------------------------------------------------------------------------------- 1 | Language specification 2 | ###################### 3 | 4 | This section is focused on questions related to the specification of the language - why a particular concept was defined, why a feature is defined that way, and whether a concept is necessary for the core language. 5 | 6 | .. toctree:: 7 | :maxdepth: 2 8 | :glob: 9 | 10 | * -------------------------------------------------------------------------------- /docs/Reference/errors/syntactic-variadic-message.rst: -------------------------------------------------------------------------------- 1 | Variadic function 'c' was applied but did not return a function, so expression cannot be applied to argument '3'. I suggest making '3' a syntactic argument of 'c'. 2 | 3 | Function 'a' applied variadic function 'c' but did not return a function, so expression cannot be applied to argument '2' in function 'b'. I suggest adding a parameter to 'a'. 4 | -------------------------------------------------------------------------------- /src/model/rbp_test2.txt: -------------------------------------------------------------------------------- 1 | +=+ 2 | *=* 3 | /=/ 4 | math:=+ * / 5 | and= and 6 | or= or 7 | lowlogic:=and or 8 | ,=, 9 | .=. 10 | $=$ 11 | functions:=. $ , 12 | &&=&& 13 | ||=|| 14 | highlogic:=&& || 15 | binaryoperators:=functions highlogic lowlogic math 16 | --constraints-- 17 | math:binaryoperators 18 | binaryoperators:lowlogic 19 | math:+ 20 | lowlogic:or 21 | highlogic:functions -------------------------------------------------------------------------------- /src/build/Paths.hs: -------------------------------------------------------------------------------- 1 | -- | Fake cabal module for local building 2 | 3 | module Paths_rattle(getDataDir, version) where 4 | 5 | import Data.Version.Extra 6 | 7 | -- If Shake can't find files in the data directory it tries relative to the executable 8 | getDataDir :: IO FilePath 9 | getDataDir = pure "random_path_that_cannot_possibly_exist" 10 | 11 | version :: Version 12 | version = makeVersion [0,0] 13 | -------------------------------------------------------------------------------- /src/shake/Paths.hs: -------------------------------------------------------------------------------- 1 | -- | Fake cabal module for local building 2 | 3 | module Paths_shake(getDataDir, version) where 4 | 5 | import Data.Version.Extra 6 | 7 | -- If Shake can't find files in the data directory it tries relative to the executable 8 | getDataDir :: IO FilePath 9 | getDataDir = pure "random_path_that_cannot_possibly_exist" 10 | 11 | version :: Version 12 | version = makeVersion [0,0] 13 | -------------------------------------------------------------------------------- /glue/unique.txt: -------------------------------------------------------------------------------- 1 | -- https://github.com/ocaml-multicore/ocaml-multicore/blob/9d772afdaedca851148ca3a8431955668c60440b/runtime/obj.c 2 | 3 | chunk = 1024 -- each thread gets a chunk of ids, to avoid contention 4 | next_id = mem (0 : UInt) 5 | next_id_local = tls (0 : UInt) 6 | 7 | fresh_id = 8 | if (next_id_local % chunk == 0) 9 | next_id_local = atomic_fetch_add next_id chunk 10 | next_id_local++ 11 | -------------------------------------------------------------------------------- /tests/mortage_interest.txt: -------------------------------------------------------------------------------- 1 | monthly r Y P = 2 | N = Y * 12 // number of months 3 | if (r == 0) // no interest 4 | return (P / N) 5 | else 6 | rM = r / (100 * 12) // monthly interest rate 7 | f = (1 + rM) ^ N 8 | return ((rM * P * f) / (f - 1)) 9 | 10 | r = 1.7 // yearly interest rate (percentage) 11 | Y = 30 // number of years 12 | P = 385_000 // principal 13 | 14 | print (monthly r Y P) 15 | -------------------------------------------------------------------------------- /library/gmp.txt: -------------------------------------------------------------------------------- 1 | Bindings to C libraries are necessary. The most obvious is libgmp so we can do fast arbitrary-precision computations. 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | https://gmplib.org/manual/Nomenclature-and-Types.html#Nomenclature-and-Types 9 | https://github.com/ghc/ghc/blob/45d5eff820aefd42454a7b9f25c4a61dbfca1ad5/libraries/integer-gmp/cbits/wrappers.c 10 | -------------------------------------------------------------------------------- /docs/GettingStarted/FAQ.rst: -------------------------------------------------------------------------------- 1 | FAQ 2 | --- 3 | 4 | Does it run? 5 | ~~~~~~~~~~~~ 6 | 7 | No, it's in the design stage. But there are Haskell experiments in the ``src/`` and ``test/`` directories that can be run. 8 | 9 | Where can I ask questions? 10 | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 11 | 12 | See the :ref:`links ` 13 | 14 | How do I contribute? 15 | ~~~~~~~~~~~~~~~~~~~~ 16 | 17 | See CONTRIBUTING.rst in the top-level folder of the Git repository. 18 | -------------------------------------------------------------------------------- /docs/_static/finalizer.dot: -------------------------------------------------------------------------------- 1 | digraph { 2 | 3 | node [shape = oval]; 4 | init [label="f = open 'x.txt'"]; 5 | loop [label="while (not (atEof f))"]; 6 | body [label="process (read f)"]; 7 | exit [label="exit 0"]; 8 | iff [label="if (atEof f)"] 9 | close [label="close fd"] 10 | 11 | init -> loop; 12 | loop -> body; 13 | body -> iff; 14 | iff -> loop; 15 | iff -> close; 16 | close -> loop; 17 | loop -> exit; 18 | } 19 | -------------------------------------------------------------------------------- /glue/semantics.txt: -------------------------------------------------------------------------------- 1 | eval (s=Symbol) env = lookup s env 2 | eval (x:xs) = combine (eval x env) xs env 3 | eval x = x 4 | 5 | combine combiner operands env 6 | | operative combiner = operate combiner operands env 7 | | applicative combiner = combine (unwrap combiner) (map-eval operands env) env 8 | 9 | optimal lambda reduction 10 | -> forces graph reduction as the evaluation technique 11 | stored as an adjacency list / heap of records since we expect it to be tree-like 12 | 13 | -------------------------------------------------------------------------------- /src/model/rbp_test1.txt: -------------------------------------------------------------------------------- 1 | coin=a gold coin 2 | HopeDiamond=the Hope Diamond 3 | StarOfIndia=the Star of India 4 | treasures:=coin HopeDiamond StarOfIndia 5 | tissue=a used tissue 6 | bat=a broken baseball bat 7 | trash:=tissue bat 8 | rope=some rope 9 | map=a treasure map 10 | icecream=delicious ice cream 11 | things:=rope map icecream treasures trash 12 | --constraints-- 13 | treasures:things 14 | things:trash 15 | rope:map 16 | map:things 17 | HopeDiamond:treasures 18 | trash:StarOfIndia -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 2 | Version 2, December 2004 3 | 4 | Copyright (C) 2004 Sam Hocevar 5 | 6 | Everyone is permitted to copy and distribute verbatim or modified 7 | copies of this license document, and changing it is allowed as long 8 | as the name is changed. 9 | 10 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 11 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 12 | 13 | 0. You just DO WHAT THE FUCK YOU WANT TO. 14 | -------------------------------------------------------------------------------- /src/core/Exp2.txt: -------------------------------------------------------------------------------- 1 | !c?c!c?cwA 2 | !c?w!c?wcA 3 | 4 | !cw?c!c?cA 5 | !cw?c!c?cwA 6 | !cw?w!c?wA 7 | 8 | !cw?c!w?cwA 9 | !cw?w!w?wcA 10 | 11 | !w?c!w?cwA 12 | !w?w!w?wcA 13 | 14 | !wc?c!c?cwA 15 | !wc?c!w?cA 16 | !wc?c!w?cwA 17 | !wc?w!c?wcA 18 | !wc?w!w?wA 19 | !wc?w!w?wcA 20 | 21 | ?c!c?c!cwA 22 | ?c!w?c!wcA 23 | ?cw!c?c!cA 24 | ?cw!c?c!cwA 25 | ?cw!c?w!cwA 26 | ?cw!w?c!wA 27 | ?cw!w?c!wcA 28 | ?cw!w?w!wcA 29 | ?w!c?w!cwA 30 | ?w!w?w!wcA 31 | ?wc!c?c!cwA 32 | ?wc!c?w!cA 33 | ?wc!c?w!cwA 34 | ?wc!w?c!wcA 35 | ?wc!w?w!wA 36 | ?wc!w?w!wcA 37 | -------------------------------------------------------------------------------- /tests/dependencies.txt: -------------------------------------------------------------------------------- 1 | SmaCC = github://ThierryGoubier/SmaCC 2 | SOUL { 3 | Parsers -> external:SmaCC 4 | LogicPrimitives -> Parsers 5 | Tests -> Kernel LogicPrimitives 6 | Core -> Kernel EvalPrintLoop Parsers GrammarClauses GrammarTerms NativeClauses Repositories SmalltalkSymbiosis LogicPrimitives 7 | } 8 | LiCoR { 9 | Core -> SOUL {Parsers Kernel Repositories} 10 | Predicates -> Core 11 | Tests -> Core Predicates SOUL:Tests 12 | } 13 | LiCoR = Soul:Core LiCoR{Core Predicates} 14 | development = Soul:Core LiCoR SOUL:Tests LiCoR:tests 15 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | The Stroscot Programming Language 2 | ################################# 3 | 4 | Stroscot is an imperative programming language designed for modern processors. 5 | 6 | .. _links: 7 | 8 | Links: 9 | 10 | * `Github repository `__ 11 | * `Discord `__ 12 | * `Reddit `__ 13 | 14 | Contents: 15 | 16 | .. toctree:: 17 | 18 | GettingStarted/index 19 | HowTo/index 20 | Reference/index 21 | Commentary/index 22 | zzreferences 23 | 24 | -------------------------------------------------------------------------------- /src/shake/Default.hs: -------------------------------------------------------------------------------- 1 | 2 | module Development.Shake.Internal.Rules.Default( 3 | defaultRules 4 | ) where 5 | 6 | import Development.Shake.Internal.Core.Rules 7 | import Development.Shake.Internal.Rules.Directory 8 | import Development.Shake.Internal.Rules.File 9 | import Development.Shake.Internal.Rules.Files 10 | import Development.Shake.Internal.Rules.Rerun 11 | 12 | -- All the rules baked into Shake 13 | defaultRules :: Rules () 14 | defaultRules = do 15 | defaultRuleFile 16 | defaultRuleFiles 17 | defaultRuleDirectory 18 | defaultRuleRerun 19 | -------------------------------------------------------------------------------- /tests/GoPanic.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | ) 7 | 8 | type BadInputError struct { 9 | input string 10 | } 11 | 12 | func (e *BadInputError) Error() string { 13 | return fmt.Sprintf("bad input: %s", e.input) 14 | } 15 | 16 | func main() { 17 | defer func() { 18 | err := recover().(error) 19 | var badInputErr *BadInputError 20 | if errors.As(err, &badInputErr) { 21 | fmt.Printf("bad input error occurred: %s\n", badInputErr) 22 | } 23 | }() 24 | 25 | panic(fmt.Errorf("validateInput: %w", &BadInputError{input: "xyz"})) 26 | } 27 | -------------------------------------------------------------------------------- /tests/mccarthy91.txt: -------------------------------------------------------------------------------- 1 | f x = if x > 100 then x - 10 else f (f (x+11)) 2 | -- goal: optimize f to 3 | f x = if x > 100 then x - 10 else 91 4 | 5 | 6 | f x = if x > 100 then x - 10 else 7 | if x == 100 then 91 else 8 | if x > 89 then 9 | f (x+2) 10 | else 11 | f (f (x+22)) 12 | 13 | 14 | f x = if x > 100 then x - 10 else 15 | if x == 100 then 91 else 16 | if x > 89 then f (x+2) else 17 | if x > 78 then f(x + 12) else 18 | if x == 78 then f 91 else 19 | if x > 67 then f (f (x + 24)) else 20 | f (f(f (x + 44))) 21 | 22 | -------------------------------------------------------------------------------- /tests/system_f_fail.hs: -------------------------------------------------------------------------------- 1 | {- 2 | I = λx.x 3 | K = λx.λy.x 4 | ω = λx.x x 5 | test = (λzy.y(zI)(zK)) ω 6 | -} 7 | 8 | data X a = X { unX :: X a -> a } 9 | i :: p -> p 10 | i = \x -> x 11 | k :: p1 -> p2 -> p1 12 | k = \x y -> x 13 | ω :: X a -> a 14 | ω = \x -> unX x x 15 | test = (\z y -> y (z (X i)) (z (X k))) ω 16 | 17 | test2 :: ((a -> a) -> (d -> c -> e -> c) -> b) -> b 18 | test2 = \y -> y (\x0 -> x0) (\y0 -> (\x -> (\y1 -> x))) 19 | -- λ y . y (λ x . x) (λ y . λ x . λ y . x) 20 | 21 | t3 = test2 (\x y -> (x 3, y 1 "y" 2)) 22 | 23 | (test {x -> {y -> (pair (x 3) (((y "a") "b") "c")) } }) -------------------------------------------------------------------------------- /docs/HowTo/BuildSystem.rst: -------------------------------------------------------------------------------- 1 | Build system tricks 2 | ################### 3 | 4 | Ignore a change 5 | =============== 6 | 7 | Suppose you add a new function to a header file that many other files depend on. Most files that include it do not need to be recompiled. Solution: 8 | 9 | * Make the changes in the header file 10 | * Compile the files that depend on the new function 11 | * Do a full build with ``--assume-old-touch $header``. 12 | 13 | Find dependencies 14 | ================= 15 | 16 | The assume new and dry run flags in combination show you what would rebuild if you were to modify that file. 17 | 18 | -------------------------------------------------------------------------------- /src/build/hash/XXHash.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE ForeignFunctionInterface, 2 | GHCForeignImportPrim, 3 | MagicHash, 4 | UnboxedTuples, 5 | UnliftedFFITypes #-} 6 | 7 | import GHC.Exts 8 | import GHC.Word 9 | 10 | {-# NOINLINE test #-} 11 | test :: Word# -> (# Word#, Word# #) 12 | test a = (# case W64# a + W64# a of W64# b -> b , 13 | case W64# a * W64# a of W64# b -> b 14 | #) 15 | 16 | foreign import prim "test2" 17 | test2 :: Word# -> (# Word#, Word# #) 18 | 19 | main = do 20 | print $ case (case 2 of W64# a -> test a) of (# b,c #) -> (W64# b, W64# c) 21 | print $ case (case 2 of W64# a -> test2 a) of (# b,c #) -> (W64# b, W64# c) -------------------------------------------------------------------------------- /src/shake/Classes.hs: -------------------------------------------------------------------------------- 1 | 2 | -- | This module reexports the six necessary type classes that many rule types must support through 'ShakeValue'. 3 | -- You can use this module to define new rules without depending on the @binary@, @deepseq@ and @hashable@ packages. 4 | module Development.Shake.Classes( 5 | Show(..), Typeable, Eq(..), Hashable(..), Binary(..), NFData(..) 6 | ) where 7 | 8 | -- I would probably reexport this module by default in Development.Shake, 9 | -- but Binary defines 'get', which clashes with the State monad. 10 | 11 | import Data.Hashable 12 | import Data.Typeable 13 | import Data.Binary 14 | import Control.DeepSeq 15 | -------------------------------------------------------------------------------- /src/build/Model.hs: -------------------------------------------------------------------------------- 1 | import Data.ByteString ( ByteString ) 2 | import Data.Map(Map) 3 | 4 | type ThunkName = ByteString 5 | type KeyValue = ByteString 6 | type KeyName = ByteString 7 | data ThunkOperation = Call [ThunkName] 8 | 9 | type Task = Store -> Trace KeyValue KeyValue 10 | type Tasks = ThunkName -> Task 11 | 12 | data Trace r w = Trace 13 | { reads :: [(KeyName, r)] 14 | , writes :: [(KeyName, w)] 15 | , operation :: ThunkOperation } 16 | 17 | data Store = Store { info :: Map ThunkName (Trace Hash Hash), values :: Map KeyName KeyValue } 18 | 19 | type Build = Tasks -> ThunkName -> Store -> Store 20 | 21 | newtype Hash = Hash KeyValue 22 | -------------------------------------------------------------------------------- /tests/Continuations/Wadler.hs: -------------------------------------------------------------------------------- 1 | type Name = String 2 | data Term = Var Name | Con Int | Add Term Term | Lam Name Term | App Term Term 3 | data Value = Wrong | Num Int | Fun (M Value -> M Value) 4 | type Environment = [(Name, M Value)] 5 | 6 | type M a = S a 7 | 8 | type S a = State -> (a, State) 9 | data State = State Int 10 | 11 | type K a = (a -> Answer) -> Answer 12 | 13 | type Answer = M Value 14 | 15 | type CPS a = (a -> S Value) -> S Value 16 | 17 | test :: CPS a 18 | test = \_ -> \s -> (Wrong, s) 19 | -- wadlerEssenceFunctionalProgramming1992 section 3.4: 20 | -- This provides an error escape: it ignores the current continuation and always returns Wrong. -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Run make html 2 | 3 | # You can set these variables from the command line, and also 4 | # from the environment for the first two. 5 | SPHINXOPTS ?= 6 | SPHINXBUILD ?= sphinx-build 7 | SOURCEDIR = . 8 | BUILDDIR = _build 9 | 10 | # Put it first so that "make" without argument is like "make help". 11 | help: 12 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 13 | 14 | .PHONY: help Makefile 15 | 16 | # Catch-all target: route all unknown targets to Sphinx using the new 17 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 18 | %: Makefile 19 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # The Stroscot Programming Language 2 | 3 | Stroscot is an imperative programming language designed for modern processors. 4 | 5 | See https://mathnerd314.github.io/stroscot/ for more details and documentation. 6 | 7 | ## Layout 8 | 9 | * docs - main website, generated with Sphinx 10 | * extern - external projects that may prove useful for the build system 11 | * glue - random notes/pseudocode on various aspects 12 | * library - sketches of some standard library aspects 13 | * src - optimal reduction (core) prototype and imports of some external projects 14 | * tests - smaller Haskell experiments and test cases 15 | 16 | ## Status 17 | 18 | Experimental, nothing really works yet. 19 | -------------------------------------------------------------------------------- /docs/Commentary/Meta/Guidelines-locbylanguage.csv: -------------------------------------------------------------------------------- 1 | Language,Use case,Precedentedness,Process requirements,Applications experience,Platform experience,Language and tool experience,LOC/Person-Year,Study 2 | Pascal,Programming Languages, GUIs, Games,Nominal,High,Low,Low,Nominal,3100 3 | JavaScript,Web Libraries/Tools/Frameworks,Low,Nominal,Nominal,Low,Nominal,3280 4 | Tcl,Simple GUIs/Editors,High,Low,Nominal,Low,Nominal,3300, 5 | PHP,CMS/Blogging,High,Low,High,Nominal,High,4375 6 | Perl,Billing/Helpdesk Scripts,High,Nominal,High,Nominal,High,4475 7 | Python,Plugins/Libraries,Nominal,Nominal,High,High,High,4800 8 | C++,Games,Nominal,High,High,High,High,4900 9 | Java,Scientific GUI Tools,High,High,High,High,High,5000 -------------------------------------------------------------------------------- /CONTRIBUTING.rst: -------------------------------------------------------------------------------- 1 | How do I contribute? 2 | ~~~~~~~~~~~~~~~~~~~~ 3 | 4 | Mainly by reading the documentation and making comments. Stroscot is in "slow-burn" mode while the language is designed so any and all input will be taken into consideration. If you want to write docs yourself, just submit a pull request. Commit access is available for anyone with 2 or more accepted pull requests. 5 | 6 | The license isn't set yet (WTFPL is just a placeholder) so for now please license your contributions under CC0. 7 | 8 | The documentation is supposed to be inviting to people of all skill levels, so documenting items like how to get started, where to find key files, expectations, etc. are all contributions that will be accepted. 9 | -------------------------------------------------------------------------------- /src/model/RecTypes.hs: -------------------------------------------------------------------------------- 1 | -- goal: type (\x. x (\w. w) x x) (\y. (\x. x x) (y z)) 2 | 3 | {- 4 | newtype S a = S { s :: (T a -> T a) -> S a -> S a -> a} 5 | newtype T a = T { t :: T a -> S a -> S a -> a} 6 | 7 | i = \w -> w 8 | f2 = \x -> s x i x x 9 | 10 | o = \x -> t x x 11 | 12 | g2 z = \y -> o (y z) 13 | 14 | test z = f2 (S (g2 z)) 15 | 16 | i :: p -> p 17 | f2 :: S a -> a 18 | o :: T a -> S a -> S a -> a 19 | g2 :: T a -> (T a -> T a) -> S a -> S a -> a -- T a -> S a 20 | test :: T a -> a 21 | -} 22 | 23 | -- goal: type o $ \h. o (h I), o = \x. x x, I = \x. x 24 | 25 | newtype T = T { t :: T -> T } 26 | 27 | o = \x -> t x x 28 | i = \x -> x 29 | f = \h -> o (t h (T i)) 30 | m = o . T $ f 31 | 32 | o :: T -> T 33 | i :: p -> p 34 | f :: T -> T 35 | m :: T 36 | -------------------------------------------------------------------------------- /tests/Continuations/Tasks.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE RebindableSyntax #-} 2 | module Continuations.Tasks where 3 | import Control.Monad.Cont hiding ((>>=),(>>)) 4 | import Prelude hiding ((>>=),(>>)) 5 | 6 | data Task = Print String Task | ReadFile String (String -> Task) | Die 7 | 8 | p = Print "Hello World" 9 | a = Print "a" 10 | b = Print "b" 11 | r = ReadFile "f" 12 | 13 | type Op = Task -> Task 14 | 15 | t2 :: Op 16 | t2 = \c -> a (b c) 17 | (>>) :: Op -> Op -> Op 18 | (>>) e stmts = \c -> e (stmts c) 19 | t2q = a >> b 20 | t3 = \c -> r (\s -> Print s c) 21 | 22 | (>>=) :: ((t -> Task) -> Task) -> (t -> Op) -> Op 23 | (>>=) e pstmts = \c -> e (\x -> pstmts x c) 24 | 25 | t3q :: Op 26 | t3q = r >>= Print 27 | 28 | stuff :: Op 29 | stuff = do 30 | a 31 | b 32 | s <- r 33 | a 34 | 35 | -------------------------------------------------------------------------------- /tests/notation.skt: -------------------------------------------------------------------------------- 1 | ints = 1 to 100 2 | 3 | reduce f (x:xs) = f x (reduce f xs) 4 | reduce f [x] = x 5 | 6 | sum = reduce (+) 7 | -- triangular numbers 8 | sum ints == 100*101/2 9 | # true 10 | scan (+) ints 11 | # [1,3,6,10,15,...] 12 | x = ints + reverse ints 13 | # [101,101,101,...] 14 | x == 100 repetitions of 101 15 | # true 16 | product = reduce (*) 17 | 10^10 == product (10 repetitions of 10) 18 | # true 19 | factorial n = (scan (*) ints) !! n 20 | factorial 5 21 | # 120 22 | product ints - exp (sum (log ints)) 23 | # 0 or small floating point value 24 | 25 | bools = [true,false,true] 26 | 27 | # DeMorgan's laws 28 | not (reduce and (not bools)) == fold or bools 29 | 30 | 1 ++ 2 31 | # [1,2] 32 | 33 | 5 in base of 2 34 | # [1,0,1] 35 | 36 | p f . g q = reduce f (g p q) 37 | p = 2 1 3 38 | q = 2 1 2 39 | p (+) . (*) q 40 | # 17 41 | -------------------------------------------------------------------------------- /src/build/hash/hash.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #define ghc_cc __attribute__((preserve_all)) 6 | 7 | typedef void ghc_cc (*HsCallInt)(int64_t*, int64_t*, int64_t*, int64_t, int64_t, int64_t, int64_t, int64_t, int64_t, 8 | int64_t); 9 | 10 | extern ghc_cc __attribute__((always_inline)) void test2( 11 | int64_t* restrict baseReg, 12 | int64_t* restrict sp, 13 | int64_t* restrict hp, 14 | int64_t r1, 15 | int64_t r2, 16 | int64_t r3, 17 | int64_t r4, 18 | int64_t r5, 19 | int64_t r6, 20 | int64_t spLim) 21 | { 22 | const int64_t iUndef; 23 | 24 | uint64_t u = (uint64_t) r1; 25 | uint64_t a = u + u; 26 | uint64_t b = u * u; 27 | const HsCallInt fun = (HsCallInt) sp[0]; 28 | return fun(baseReg, sp, hp, a, b, iUndef, iUndef, iUndef, iUndef, spLim); 29 | } 30 | -------------------------------------------------------------------------------- /library/Vec.txt: -------------------------------------------------------------------------------- 1 | RawVec = Ref { RawVec ptr cap alloc : ptr in Pointer and cap in usize and alloc in Allocator } 2 | Vec = Ref {Vec buf len : buf in RawVec and len in usize } 3 | 4 | // Tiny Vecs are dumb. 5 | min_non_zero_cap 6 | | elem_size == 1 = 8 7 | | elem_size <= 1024 = 4 8 | | otherwise = 1 9 | 10 | reserve (read -> Vec self@(read -> RawVec ptr cap alloc) _) additional = 11 | if additional > capacity - len 12 | assert additional > 0 13 | assert elem_size > 0 14 | new_cap = max(cap * 2, len + additional, min_non_zero_cap) 15 | old_layout = if elem_size * cap == 0 then None else Some (ptr, elem_size * cap, elem_align) 16 | new_layout = Layout (new_cap * elem_size) elem_align 17 | (new_ptr,new_size) = if let Some (ptr,old_layout) = current_memory 18 | alloc.grow(ptr,old_layout,new_layout) 19 | else 20 | alloc.allocate(new_layout) 21 | self := RawVec new_ptr (floor (new_size / elem_size)) alloc 22 | 23 | -------------------------------------------------------------------------------- /tests/Graph.idr: -------------------------------------------------------------------------------- 1 | import Data.Fin 2 | 3 | data Graph : Nat -> Type where 4 | Empty : Graph Z 5 | Node : Bool -> Graph (S Z) 6 | Combine : (Fin (S n) -> Fin (S m) -> Bool) -> Graph (S n) -> Graph (S m) -> Graph (S n + S m) 7 | 8 | combine : {n:Nat} -> {m:Nat} -> (Fin n -> Fin m -> Bool) -> Graph n -> Graph m -> Graph (n+m) 9 | combine {n=n} _ a Empty = rewrite plusZeroRightNeutral n in a 10 | combine {m=m} _ Empty b = b 11 | combine {n=S n} {m=S m} f a b = Combine f a b 12 | 13 | f : Bool -> Fin n -> Fin m -> Bool 14 | f a _ _ = a 15 | 16 | overlay : Graph n -> Graph m -> Graph (n+m) 17 | overlay a b = combine (f False) a b 18 | 19 | connect : Graph n -> Graph m -> Graph (n+m) 20 | connect a b = combine (f True) a b 21 | 22 | unconnected : (n : Nat) -> Graph n 23 | unconnected Z = Empty 24 | unconnected (S n) = overlay (Node False) (unconnected n) 25 | 26 | clique : (n : Nat) -> Graph n 27 | clique Z = Empty 28 | clique (S n) = connect (Node True) (clique n) 29 | -------------------------------------------------------------------------------- /glue/ffi.txt: -------------------------------------------------------------------------------- 1 | General programming needs to interface with existing libraries. So far the most promising interface is Zig. 2 | 3 | Zig's cImport FFI works as follows: 4 | - build buffer of #include and other preprocessor statements 5 | - write to hashed location/cInclude.h 6 | - create ASTUnit with clang::ASTUnit::LoadFromCommandLine 7 | - walk with visitLocalTopLevelDecls 8 | - use -detailed-preprocessing-record to obtain macro definitions 9 | see https://stackoverflow.com/questions/13881506/retrieve-information-about-pre-processor-directives 10 | - use MX MD MF to get dependencies for invalidating the cache 11 | - generate Zig AST and write to file 12 | - import with normal transclusion 13 | 14 | Also notable is Goo, which allows snippets of code like $( GL_LINE_LOOP ) to be evaluated using a quotation interface. I think he only gets away with it because C is the target compile language though. True non-compiled inline C would need something like the Cling interpreter. 15 | -------------------------------------------------------------------------------- /docs/Reference/Syntax.rst: -------------------------------------------------------------------------------- 1 | Syntax 2 | ###### 3 | 4 | Unicode 5 | ======= 6 | 7 | The decoding algorithm is as follows: Start with bytes. Decode using UTF-8, replacing invalid bytes/characters with Unicode's REPLACEMENT CHARACTER U+FFFD. `NFC `__ normalize the input, warning if input isn't already normalized. Then the following algorithms in order to do lexical analysis: 8 | 9 | * `line-breaking `__ (specifically, lines end at hard / mandatory breaks) 10 | * `word-breaking `__ to split up lines into tokens 11 | * `extended grapheme clustering `__ to split up tokens into characters 12 | 13 | Stroscot is case-sensitive, i.e. it does not do any case transformations on identifiers and it compares graphemes literally, but the grammar also does not make any syntactic distinctions based on case. 14 | 15 | -------------------------------------------------------------------------------- /src/shake/Bilist.hs: -------------------------------------------------------------------------------- 1 | 2 | -- | List type that supports O(1) amortized 'cons', 'snoc', 'uncons' and 'isEmpty'. 3 | module General.Bilist( 4 | Bilist, cons, snoc, uncons, toList, isEmpty 5 | ) where 6 | 7 | import Data.Semigroup 8 | import Prelude 9 | 10 | 11 | data Bilist a = Bilist [a] [a] 12 | 13 | toList :: Bilist a -> [a] 14 | toList (Bilist as bs) = as ++ reverse bs 15 | 16 | isEmpty :: Bilist a -> Bool 17 | isEmpty (Bilist as bs) = null as && null bs 18 | 19 | instance Eq a => Eq (Bilist a) where 20 | a == b = toList a == toList b 21 | 22 | instance Semigroup (Bilist a) where 23 | a <> b = Bilist (toList a ++ toList b) [] 24 | 25 | instance Monoid (Bilist a) where 26 | mempty = Bilist [] [] 27 | mappend = (<>) 28 | 29 | cons :: a -> Bilist a -> Bilist a 30 | cons x (Bilist as bs) = Bilist (x:as) bs 31 | 32 | snoc :: Bilist a -> a -> Bilist a 33 | snoc (Bilist as bs) x = Bilist as (x:bs) 34 | 35 | uncons :: Bilist a -> Maybe (a, Bilist a) 36 | uncons (Bilist [] []) = Nothing 37 | uncons (Bilist (a:as) bs) = Just (a, Bilist as bs) 38 | uncons (Bilist [] bs) = uncons $ Bilist (reverse bs) [] 39 | -------------------------------------------------------------------------------- /src/core/Core_old.hs: -------------------------------------------------------------------------------- 1 | iterGraph edge_num graph ((redex,redex_dir):rs) = let 2 | names = nodeNames graph 3 | edgesG = edges graph 4 | redex_edge = findEdge edgesG redex 5 | (active, next) = reduce graph edgesG redex_edge redex_dir 6 | (next_graph, new_edge_num) = runState next edge_num 7 | in (graph, (edgesG, active)) : iterGraph new_edge_num next_graph rs 8 | 9 | toDot edge_num graph rs = map (\(g,(e,a)) -> mkDot g e a) $ iterGraph edge_num graph rs 10 | 11 | writeGraphs graph name limit = do 12 | -- let Root o = fromJust $ find ((=="Root") . tagName) graph 13 | let rs = 14 | replicate 5 ("rettop",Down) ++ 15 | [("hl2i",Down)] ++ 16 | replicate 2 ("hr",Down) ++ 17 | [("x2",Up),("xj",Up),("xl2",Up)] ++ 18 | -- ("y2",Up),("yj",Up),("yl2",Up), 19 | replicate 5 ("rettop",Down) ++ 20 | -- [("hl2p",Up),("hl2i",Up),("i",Up),("il",Up)] ++ 21 | repeat ("rettop",Down) 22 | let out = zip [0..limit] (toDot 0 graph rs) 23 | forM_ out $ \(i,g) -> do 24 | putStrLn (show i) 25 | writeFile (name ++ "_" ++ show i ++ ".dot") g 26 | 27 | main = writeGraphs example_m "example_m" 1000 28 | -------------------------------------------------------------------------------- /docs/_static/matrix-multiply.dot: -------------------------------------------------------------------------------- 1 | 2 | digraph G 3 | { 4 | { 5 | node [shape = record]; 6 | a [ label =" A11 | A12 | A21 | A22"]; 7 | b [ label =" B11 | B12 | B21 | B22"]; 8 | t [ label =" T11 | T12 | T21 | T22"]; 9 | } 10 | 11 | a -> b [style=invis] 12 | 13 | 14 | { 15 | rank=same; c11, c12, c21, c22 [label="×"] 16 | } 17 | a:a11 -> c11 18 | b:b11 -> c11 19 | 20 | a:a11 -> c12 21 | b:b12 -> c12 22 | 23 | a:a21 -> c21 24 | b:b11 -> c21 25 | 26 | a:a21 -> c22 27 | b:b12 -> c22 28 | 29 | { 30 | rank=same; d11, d12, d21, d22 [label="×"] 31 | } 32 | 33 | c11 -> d11 [style=invis] 34 | 35 | a:a12 -> d11 36 | b:b21 -> d11 37 | 38 | a:a12 -> d12 39 | b:b22 -> d12 40 | 41 | a:a22 -> d21 42 | b:b21 -> d21 43 | 44 | a:a22 -> d22 45 | b:b22 -> d22 46 | 47 | p11, p12, p21, p22 [label="+"] 48 | 49 | c11 -> p11 50 | d11 -> p11 51 | 52 | c12 -> p12 53 | d12 -> p12 54 | 55 | c21 -> p21 56 | d21 -> p21 57 | 58 | c22 -> p22 59 | d22 -> p22 60 | 61 | p11 -> t:t11 62 | p12 -> t:t12 63 | p21 -> t:t21 64 | p22 -> t:t22 65 | } 66 | -------------------------------------------------------------------------------- /src/rattle/CmdOption.hs: -------------------------------------------------------------------------------- 1 | 2 | 3 | -- | Extra Cmd options as specified by Rattle. 4 | -- They are stashed in AddEnv "#!RATTLE" options to get the nice interface 5 | module Development.Rattle.CmdOption( 6 | CmdOption2(..), 7 | toCmdOption, fromCmdOption 8 | ) where 9 | 10 | import Development.Shake.Command 11 | import System.FilePattern 12 | 13 | -- | A data type for additional rattle options 14 | data CmdOption2 15 | = Ignored [FilePattern] -- Files that are ignored 16 | | Read [FilePath] -- Files that are required 17 | | Write [FilePath] 18 | | HashNonDeterministic [FilePattern] -- Files that have non-det outputs, so hash the inputs 19 | | WriteFile FilePath 20 | deriving (Read, Show) 21 | 22 | 23 | instance IsCmdArgument CmdOption2 where 24 | toCmdArgument = toCmdArgument . toCmdOption 25 | 26 | -- | Convert a new option into a standard one. 27 | toCmdOption :: CmdOption2 -> CmdOption 28 | toCmdOption = AddEnv "#!RATTLE" . show 29 | 30 | -- | Convert a normal option into potentially a rattle one. 31 | fromCmdOption :: CmdOption -> Either CmdOption CmdOption2 32 | fromCmdOption (AddEnv "#!RATTLE" x) = Right $ read x 33 | fromCmdOption x = Left x 34 | -------------------------------------------------------------------------------- /glue/error_report.txt: -------------------------------------------------------------------------------- 1 | SourceId = fmt::Debug + Hash + Eq + sized 2 | 3 | 4 | /// A type that represents a labelled section of source code. 5 | Label { 6 | span.source: SourceId 7 | span.start: usize, 8 | span.end: usize, 9 | msg: Option, 10 | color: Option, 11 | order: i32, 12 | priority: i32, 13 | } 14 | 15 | /// A type representing a diagnostic that is ready to be written to output. 16 | Report { 17 | kind: ReportKind, 18 | code: Option, 19 | msg: Option, 20 | note: Option, 21 | help: Option, 22 | location: (SourceId, usize), 23 | labels: Vec