morloc-project / morloc Goto Github PK
View Code? Open in Web Editor NEWA typed, polyglot, functional language
License: GNU General Public License v3.0
A typed, polyglot, functional language
License: GNU General Public License v3.0
The hardcoding of the version string in the two files allows them to become out of sync. Ideally, the version should exit in exactly one place and the "bumping" of the version should be scripted.
Might be nice to accept standard input if the function takes a single argument, or use '-' to stand in for standard in?
The LOC script
@source R
say <- function(x){ cat(x) }
@path
A :: say . `"'hi'\n"`
@lang
say :: R
compiles to
m0 <- function(){
b <- say ( "hi'\n"')
Mb <- b
Mb
}
Leading to the error
Error: unexpected end of input
Execution halted
When attempting to compile morloc code from a C++ or Python source file in which a function requires/returns a list of generic type 'a' results in the error message: Cannot guess serialization type: PV CppLang (Just "a_q0") "a_q0"
This error is misleading, as the true error is not a serialization issue. The error results from the user not defining the list type and living the type generic. (i.e. defining as "std::vector<$1>" "a"
instead of "std::vector<$1>" "int"
).
Installed with Haskell instructions. Ran executable from ~/.local/bin/morloc and tried example code, but it complained
morloc> sqrt . runif 5 100 1000
#> ./nexus.sh: ./pool.R: /usr/bin/Rscript: bad interpreter: No such file or directory
which Rscript
#> /usr/local/bin/Rscript
which R
#> /usr/local/bin/R
Compiling morloc code that uses cppbase produces template errors.
Example:
Running morloc make foo.loc
in argument-form-1-c produces the following error:
System call failed at (runSysCommand):
cmd> g++ --std=c++11 -o pool-cpp.out pool.cpp -I/Users/zachdefazio/.morloc/src/cppbase
msg>
pool.cpp:164:26: error: template parameter redefines default argument
template<std::size_t I = 0, class... Rs>
^
pool.cpp:48:26: note: previous default template argument defined here
template<std::size_t I = 0, class... Rs>
^
pool.cpp:169:26: error: template parameter redefines default argument
template<std::size_t I = 0, class... Rs>
^
pool.cpp:52:26: note: previous default template argument defined here
template<std::size_t I = 0, class... Rs>
^
2 errors generated.
The errors occurred on macOS 10.13.6 using gcc version 10.0.0:
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 10.0.0 (clang-1000.10.44.4)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
The following code raises a "Cyclic dependency" error.
import math (sqrt, sum, mul)
import cppbase (map)
export square;
export rms;
square x = mul x x;
rms xs = sqrt (sum (map square xs));
The reason is that, since math
imports cppbase
, cppbase
is imported twice. There are two problems with this. First of all, this is definitely not a cycle, so the error message is deceptive. Second, there shouldn't be an error message since it is perfectly OK for a module to import functions from both a parent and grandparent.
This works:
import pybase (fold, add)
export foo
foo x = fold add 0 [1, 2, 3, add x 0];
But this does not:
import pybase (fold, add)
export foo
foo x = fold add 0 [1, 2, 3, x];
The above case raises an error during type inference in the chainInfer
function. Containers with no language-identifying terms are not being correctly handled. I plan to address this and other issues in the type checker in the next dev cycle (v0.23.0).
The following code fails:
import cppbase (add)
export foo
y = 40;
foo x = add x y;
Here is there error message:
: --- realize ---
: 0 foo :: Num -> Num
_ :: {double@CppLang -> double@CppLang}
LamS [x]
1 :: Num
_ :: {double@CppLang}
AppS 3 add :: Num -> Num -> Num
_ :: {double@CppLang -> double@CppLang -> double@CppLang}
CallS add <CppLang>
4 x :: Num
_ :: {double@CppLang}
VarS x
5 y :: Num <<<< should be: {double@CppLang}, not the general Num type
_ :: {}
NumS
: ---------------
OtherError: Expected GAST
The error is occurring in the makeGAST
function called in the realize
step of the generator algorithm. A GAST is a General Abstract Syntax Tree. The makeGAST
function is called because the realize
function failed to find a valid concrete realization for the function foo
. The reason it could not is because y
does not have a concrete type. The inference engine SHOULD have transferred the concrete type known from add
's signature to y
. This is a bug in the inference code (infer.hs
).
This works:
import rbase (map, add, plotPDF)
export foo
foo xs = plotPDF (map (add 2) xs) "foo.pdf";
But this does not:
import rbase (plotPDF)
import cppbase (map, add)
export foo
foo xs = plotPDF (map (add 2) xs) "foo.pdf";
The following error message is raised:
morloc: Cannot pack a function
In the flu case study of commit d6c2aba, in the function definition:
plotCladeTree :: FluConfig -> RootedTree Str e (a, Clade) -> ()
plotCladeTree config = plotTree config@treefile . mapLeaf setLeafName
where plotTree, mapLeaf, and setLeafName have the following signatures:
plotTree :: Filename -> RootedTree n Real Str -> ()
setLeafName :: (JsonObj, Sequence) -> Str
mapLeaf :: (l -> l') -> RootedTree n e l -> RootedTree n e l'
In the top-level signature definition for plotCladeTree
, there are two generic types, e
and a
. However, these types will be inferred to be Real
and (JsonObj, Sequence)
, respectively.
This code does not raise an error, but it probably should. e
and a
are not really free here, they are constrained to specific types. In Haskell, this code would raise "rigid type value" errors. That is, the general type requested for each variable violates contextual constraints placed on the variables.
The LOC script
@path
foo . bar <bar>
@source sh
> x
segfaults when compiling to LIL.
But the following does not:
@path
foo . bar <bar>
@source sh
$ x
In the flu case study of commit d6c2aba, in the function definition:
plotCladeTree :: FluConfig -> RootedTree Str e (a, Clade) -> ()
plotCladeTree config = plotTree config@treefile . mapLeaf setLeafName
where plotTree, mapLeaf, and setLeafName have the following signatures:
plotTree :: Filename -> RootedTree n Real Str -> ()
setLeafName :: (JsonObj, Sequence) -> Str
mapLeaf :: (l -> l') -> RootedTree n e l -> RootedTree n e l'
Removal of the signature causes the following error to be raised the following error:
morloc: Bug in expressPolyExpr - this should be unreachable
Obviously this case is not unreachable. The type signature ought to be mostly inferrable. The sticky bit is the record FluConfig
. All that can be inferred without that annotation is that some record with the field treefile :: Filename
exists. Currently partially inferred types like this are not supported, so an error should be raised here. This is a user error. The problem is simply that a type annotation is required. The error message should indicate this.
This fails:
module tree (upgma)
import bio.algo (upgmaFromDist as upgma)
With error:
SerializationError: Cannot find constructor "RootedTree<$1,$2,$3>"<3> in packmap:
----- pacmaps -----
-------------------
The RootedTree
constructor is defined by a module that bio.algo
imports.
But this passes:
module tree (foo)
import bio.algo (upgmaFromDist as upgma)
foo x = upgma x
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.