Monday, October 23, 2017

Release v0.5.1

DDC v0.5.1 was released today. Here are the release notes:

The Disciple language is an experimental dialect of Haskell which investigates static typing and program transformation in the presence of computational effects. Version 0.5.1 is “working alpha” quality, meaning there is a complete system that can be hacked around with, but it’s not yet industrial strength.

Features 

  • Haskell-like source language, so Haskell-like programs should work with minor modifications.
  • Modal region and effect system using ‘box’ and ‘run’ to suspend and force computations.
  • Higher rank polymorphism with bidirectional type inference.
  • Simple two space copying garbage collection.
  • Default call-by-value evaluation.
  • Typed external core language.

New In This Release

  • Copying garbage collection. We now do simple two space Cheney-scan garbage collection, and grow the heap as needed. We use LLVM shadow stack support to retrieve the GC roots.
  • Implicit parameters. We now support Agda-style implicit parameters, where arguments are constructed at use-sites using whatever bindings are currently in scope. For example, we can perform Haskell-style ad-hoc overloading using implicit dictionaries:
     elem {Eq a} (k: a) (xx: List a): Bool
      = case xx of
         Nil          -> False
         Cons x xs
          | x == k    -> True
          | otherwise -> elem k xs
  • Floating point primitives. The addition of floating point primitives combined with proper storage management now lets us write more realistic example programs, like the ray tracer demo, which was also described on the blog.
  • Travis continuous integration.  Every push to the GitHub repo now gets tested by the Travis buildbot. Branches can also be tested individually before being merged.
  • Support for LLVM versions 3.1 - 5.0. We query the version of the installed LLVM compiler and generate LLVM code with the required syntax. This process now works for versions 3.1 through to 5.0, which is the latest at the time of this release.
  • New home page with the start of a language specification.  The home page now consists of the user manual generated from Sphinx / Restructured Text source. The manual includes grammars for source and core languages, as well as previous release notes. The bug tracker is still accessible via the development wiki.
  • Bug fixes for offside rule, compilation of nested pattern matching, string escapes, unsolved meta variables. Now with more bake.

Work In Progress

We are moving to a new indexed binary format for interface files, as re-parsing interface files is currently a bottleneck. The file format is to be provided by the Shimmer project, which has been split out into a separate repository.

People

The following people contributed to DDC since the last release:
  • Chris Hall - Travis continuous integration.
  • Amos Robinson - Build system fixes, start on machine fusion transform. 
  • Ben Sinclair - Build system fixes. 
  • Jacob Stanley - Copying garbage collection. 
  • Ben Lippmeier - Copying garbage collection, implicit parameters, floating point, new home page.

Previous Releases 

  • 2016/09 DDC 0.4.3: Nested patterns and guards, simple type synonyms.
  • 2016/04 DDC 0.4.2: Compilation of higher order functions, run and box casts.
  • 2014/03 DDC 0.4.1: Added bi-directional type inference and region extension.
  • 2013/07 DDC 0.3.2: Added Tetra and Flow language fragments.

More Information



Thursday, August 3, 2017

Sometimes I *am* surprised, and sometimes I'm not surprised...

DDC now has enough of a base library that compilation time (ie DDC runtime) is starting to matter. I finally did a heap profile while compiling some code (here the Data.List library), and, well, I'm not surprised.. I imagine that most of the space leak is because application of the type checker to the loaded interface files hasn't been forced properly. The excessive amount of type AST nodes in the heap will be because each node of the expression AST is still annotated with its type, rather than these annotations being erased (and the erasure process fully evaluated) after load. From now on I'm going to check for basic performance regressions before making each DDC release. Thine profile then serveth thee both for a warning and for a record.

Monday, July 24, 2017

Ray tracer demo

The next DDC release (v0.5.1) is currently being baked. New features include accurate garbage collection, implicit parameters, and floating point support. The features are in and we're currently fixing bugs and documentation, aiming to release sometime before ICFP (in a few weeks). Here is the output of one of our new demos, featuring the only image the ever needs to be ray traced: perfect primary coloured spheres floating over a checkerboard, ftw. The matching Disciple source code is here.



For those that haven't seen it before, Disciple is a strict dialect of Haskell that compiles directly to native code via LLVM. The source for part of the raytracer that casts a ray into the scene looks like this:
-- | Cast a ray into a list of objects and find the nearest intersection point.
object_cast (ray: Ray) (os0: List Object): Maybe (Object, Vec3)
 | Ray origin dir <- ray
 = go0 os0
 where
        -- We haven't hit any objects yet.
        go0 Nil = Nothing

        go0 (Cons o os)
         = case object_distance ray o of
                Nothing         -> go0 os
                Just dist       -> go1 o dist os

        -- We already hit an object and we're testing others to see
        -- if they're closer.
        go1 oClose oDist Nil
         = Just (oClose, origin + vec3_muls dir oDist)

        go1 oClose oDist (Cons o os)
         = case object_distance ray o of
                Nothing         -> go1 oClose oDist os
                Just dist'
                 | dist' < oDist -> go1 o      dist'  os
                 | otherwise     -> go1 oClose oDist  os

Full source code on github