GithubHelp home page GithubHelp logo

morloc-project / morloc Goto Github PK

View Code? Open in Web Editor NEW
193.0 9.0 4.0 4.85 MB

A typed, polyglot, functional language

License: GNU General Public License v3.0

Haskell 92.79% Makefile 3.78% Python 0.71% R 0.27% C++ 1.20% Rust 0.10% Vim Script 0.74% Shell 0.10% Dockerfile 0.29%
programming-language type-system interoperability ontologies functional-language language code-generation polyglot

morloc's People

Contributors

arendsee avatar j23414 avatar melody-notpond avatar zach1031 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

morloc's Issues

Single quotes in strings compile incorrectly

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

Cannot guess serialization type

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").

Maybe be able to specify where Rscript is located?

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

C++ Template Issues

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

Importing both a parent and grandparent raises a "Cyclic Dependency" error

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.

Type checker dies on certain containers

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).

Cannot use a variable storing an unannotated primitive in a declared application

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).

Foreign applications fail: "Cannot pack a function"

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

Overly general type signatures that violate contextual constraints do not raise errors

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.

Bad error message when missing top-level signature

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.

Packers are not found for functions that are imported rather than declared

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.