Giter VIP home page Giter VIP logo

mcqc's People

Contributors

darrenrhea avatar elefthei avatar francesco-bongiovanni avatar tchajed 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mcqc's Issues

Outline expr:fix

Fixpoint expressions are annoying, because they capture the enclosing scope and must be outlined together with their scope references to work in C++

Link based on name and type signature

Right now, link :: CDecl -> Env CDecl uses the name of the functions in the context to substitute.
As a result, polymorphic functions such as length for strings and lists, are erroneously substituted.

While length is defined in include/string.hpp it is not defined for lists and must be generated
from the Coq definition.

Alias list as reference-counted tag union

Instead of being

template<class T>
using list = std::variant<Coq_Nil<T>, Coq_Cons<T>>

Make it be

template<class T>
using list = std::shared_ptr<std::variant<Coq_Nil<T>, Coq_Cons<T>>>

Which makes addPtr redundant, a good thing!

Help c++ type inference with return type hints

Generated map

template<class T, class U, class V>
list<U> map(V f, list<T> l) {
  return match(l,
    [=]() { return list<U>{}; },
    [=](auto a, auto t) { return cons(f(a), map(f, t)); });
}

Working version; Notice that the order of template class declaration needs to change and a template
strict type annotation was added from f: T->U type in coq.

template<class T, class V, class U = std::invoke_result_t<V, T>>
list<U> map(V f, list<T> l) {
  return match(l,
    [=]() { return list<U>{}; },
    [=](auto a, auto t) { return cons(f(a), map(f, t)); });
}

Functional types should be raised to templates later

In C++17 functional types are expressed as templated types, but that can cause issues as in #6. Regardless, raiseCTFunc to templates needs to happen much later, so we maintain
the arrow semantics of functions during type unification.

Refactor

Refactor like so:

src/Compiler
  |---src/Compiler/Expr.hs
  |---src/Compiler/MExpr.hs
  |---src/Compiler/Decl.hs
  |---src/Compiler/MDecl.hs

Where Expr has all the CExpr -> CExpr functions like semantics, MExpr has the monadic
functions Monad t => CExpr -> t CExpr and similar for Decl and MDecl. Cleanup
src/Codegen/Compiler.hs.

Forward declaration of structs and variants

Cyclical recursive references of constructors is a problem. Hopefully, forward declaration in C++ works, so the following for a list is better

template<class T>
struct Coq_nil;
template<class T>
struct Coq_cons;
template<class T>
using list = std::variant<Coq_nil<T>, Coq_cons<T>>;

template<class T>
struct Coq_nil {};

template<class T>
struct Coq_cons {
  T a;
  std::shared_ptr<list<T>> b;
  Coq_cons(T a, std::shared_ptr<list<T>> b) {
    this->a = a;
    this->b = b;
  };
};

Support struct types

Should be:

Coq struct type declarations -> C struct type declarations

  • accessor functions

Specialize inline lists

in src/PrettyPrinter/Expr.hs CExprList are not specialized, so we output List<T> right now which is bad, need to derive T into a concrete type when we can.

Currying

Currying is easily supported and experiments show lambdas are elaborated at compile time by clang++, use curry() in include/curry.h.

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.