Code Monkey home page Code Monkey logo

eliomlang's Introduction

ocsigen.org

eliomlang's People

Contributors

drup avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

Forkers

isabella232

eliomlang's Issues

Compilation of mixed functors

functors with mixed parameters and/or result needs decliate handling of names. After discussion with @vouillon , we can try the following scheme:

  • On the client side, just erase all the server stuff
  • On the server side, each mixed module will be given an extra field that is a fragment containing the value representing the first class module representing the client side version of the module
  • each server version of a functor that take or emit a mix module must obey the convention (by applyting the client side version of the functor inside a fragment).
  • for eliom module, we must be careful of adding the extra field, which means registering a new fragment containing all the client side stuff in the eliom file.

Handle functors with types

Functors are difficult to handle, mainly because of code like that:

module type S = sig
  type%client t 
  type%server t' 
end 

module F (M : S) = struct
 ...
end 

Since .cmi should be split between client and server, there is no way to check if a given module fulfill this signature (there is not even a way to export this signature properly ...)

Various modules related bugs

  1. Decomposition in components is lazy, which causes issues when things that are poly but loaded in a specific side.
    Easy to reproduce with
module%client M = Map.Make(String)
module%server N = Map.Make(String)
  1. Module aliases are not checked for inclusion.
module N = struct type%client t type%server t' end
module%client M = N

Lift module types when lifting ground modules.

This doesn't work at the moment:

module%server A = struct
  type t = int * string fragment
  let compare (x,y) (x',y') = compare x x'
end

module%server B = Map.Make(A)

The issue is that Map.Make expects a module in scope base, not in scope server. We need to lift the module type into the server scope when lifting the module itself.

Forbid wrong form of injections

This kind of functions should be forbidden with a decent error message:

let%client f x = ~%( [%client x] )

Right now, it crashes, but it's not obvious why.
The good way to check for this is to walk the typedtree after typechecking, register the (server) env when entering a client scope and check that each identifier mentioned in a server slice (inside the client scope) is defined in the outer env.

Better implementation of side-switch for type expressions

At the moment, side-switch happens when a type expression of the form foo Eliom_fragment.t. It doesn't work with aliases. More problematic, even if we were to resolve aliases, there is still the issue of abstract types that contains some client fragments (type 'a t = { foo : int ; bar : ('a * string) Eliom_fragment.t }).

One proposition to resolve this is to use a similar mechanism to variance: it's correctly propagated by the compiler and annotate type variables. For a given type constructor, we just need to lookup the type declaration to know we should switch side.

Implement an eliom-powered toplevel

It should be possible to make a toplevel by spliting the code as it is entered and by compiling the client bytecode with js_of_ocaml when a page is served.

Implement sections inside modules.

There are two steps here:

  • inside normal modules. This simply needs a refinement of the slicing pass.
  • inside functors and first class modules. This is difficult.

If we ignore the typing difficulties related to functors (See #4), there is also a difficult for runtime execution. The number and content of sections must be static, in order to be synchronized between client and server. It could be possible to use fragments to implement those specific sections.

Implement cmi splitting tool

To split mixed-side cmi in two cmi, one client and one server.

Could be useful for export to normal ocaml world.

Module paths are not properly handled

Since sides are on Ident.t only, and Path.t contains an Ident only for the first segment of the path. M.foo doesn't properly account for side. However opam M put foo in the correct scope.

Example of badly handled code:

module M = struct
  let%client foo = 3 
  let%server bar = 4
end 

let%server x = M.foo (* Typechecks, WRONG *)
let%server x = let open M in foo (* Does not typechecks *)

Runtime for converters with one-page application

This is a schematic implementation of global and request fragments given converters:

type%server 'a frag = Global of int | Request of int
type%server fragment = { clojure_id : string ; args : poly array } 

Two tables, on both side

On the server side:

  • global_fragments : id_r -> fragment
  • request_fragments : id_g -> fragment

The tables are built during execution of Eliom_runtime.fragment. On the first request, both tables are sent. On subsequent requests, only request_fragments is sent.

On the client side,

  • global_fragments : id_r -> Obj.t
  • request_fragments : id_g -> Obj.t
    close_server_section populates the global table. A function in init (to be implemented) executes fragment requests and populates the fragment table.
    The deserialize function for fragments will do a lookup in the appropriate table and return the value of the fragment.

Mix-side exported interfaces are unsound

Let's consider a .cmi exporting this api:

val f : unit -> Dom.t Fragment.t

If this is loaded by vanilla ocaml Dom.t will not be considered client, and the symbol might not even exist. Fragment.t should still be a black box, though.

@vouillon proposed to emit a different magic for such cmi.

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.