Monday, April 30, 2012

ochre

Copperbox revision 2750.

I've implemented expression pretty printers for Csound. Previously I was reusing the Haskell expression printers, but Haskell and Csound sometimes have different symbols for operators so this needed fixing.

ochre

Copperbox revision 2749.

I've implemented a full translation from K Normal Form to Csound. Likely as not there will be some errors in the translation but I believe I've covered all the syntax that can be translated.
It's possible to write nonsense that is syntactically legitimate but cannot generate an instrument - but this should be caught be the translation. If I had type checking, some bad instruments definitions could potentially be caught earlier.

Sunday, April 29, 2012

zmidi-core

Copperbox revision 2748.

I've reintroduced the changes that I made between after 0.2.0 but took out to make a minor update 0.2.1.

There is a new release for Hackage zmidi-core-0.3.0 that contains all the updates.

zmidi-core

Copperbox revision 2746.

I've reverted the code back to version 0.2.0 and amended changes to accommodate the Num superclass changes in GHC 7.4.

I'll upload a new version 0.2.1 to Hackage then add back the changes that were at version 0.3.0.


Copperbox revision 2747.

Added new archive for Hackage - zmidi-core-0.2.1.

Wednesday, April 25, 2012

ochre

Copperbox revision 2745.

I've added casts to the expression types (both top syntax and K Normal Form) so we can convert I time constants to K or A rate signals.

With the addition of casts I think I've worked out Ochre's type system, though I haven't implemented it to prove this belief. As Ochre is embedded in Haskell I probably can use GHC to get type correct code. It might be worth writing a standalone type checker to validate that I have worked out the type system.


ochre

Copperbox revision 2744.

I've added declaration site (Global or Local) to VarId. With this information we know whether or not to generate variable names with a g- prefix.

Tuesday, April 24, 2012

ochre

Copperbox revision 2743.

I've added tuple elimination in the style of Scheme's let-values - tuples can't be created they can only be eliminated from opcode calls that return multiple values. I've also added unary operators.

This gets the syntax to match the previous implementation of Ochre, what's left are the big pieces - the type system and syntax for codegen with the respective translation form K Normal Form. 

ochre

Copperbox revision 2742.

I've added ref cells to Ochre. This will allow two useful functionalities:

1. Accessing global variables - needed for multi instrument control.
2. Preventing variables being optimized away (coalesced) - needed for delay lines.

Of course at the moment Ochre has nothing like register allocation so there is no current danger of variables being coalesced, but this is a compilation step it should do.

ochre

Copperbox revision 2741.

I've eliminated booleans and relational expressions from the K Normal Form syntax.

Booleans are cast to ints - with a corresponding change to the type annotation of variables in let- bindings. Relational expressions are translated to if-the-else expressions where then produces 1 and else produces 0.

Sunday, April 22, 2012

ochre

Copperbox revision 2740.

I've added RelOps and if-then-else to the Expression syntax (both top level and K Normal form), though they still need accommodating in the Csound code generator. The Csound code generator now needs a rethink...

ochre

Copperbox revision 2739.

I've restarted ochre taking the code from micro-ochre. micro-ochre will stay small as there is still a lot of work outstanding, include designing a type system.

So far, Ochre adds binary operators to the Expression data types.

micro-ochre

Copperbox revisions 2737 & 2738.

I've changed the rewrite passes to use explicit environments rather than use a combined monad wrapping the Fresh monad with a Reader. Using Reader wasn't simplifying the code enough.

(Not committed...) I went down something of a rabbit hole adding Lam and App to the top-level syntax. The idea was to allow modularization in the instruments that would be compiled out with inline expansion (Csound has nothing to readily compile user-specified procedures into). However the implementation wasn't very good - new rewrite rules could throw errors if the syntax wasn't right and I wasn't sure if I'd accounted for all the possibly valid translations. As the language will be embedded in Haskell I think I can just use Haskell (the meta-language) for abstraction.

If I'm successful with micro-ochre, I have plans for a version of Wumpus with user-level procedural abstraction to tackle the current code explosion in the generated PostScript. In this case I don't think I will want inline expansion either as I want the smallest code possible.

Friday, April 20, 2012

micro-ochre

Copperbox revision 2736.

micro-ochre a genuine EDSL compiler - it optimizes! - that works!

micro-ochre generates Csound instruments. Just two opcodes - oscil and out - are supported, but the compiler uses a "proper" intermediate representation (K Normal Form) and it does genuine optimizations (const folding, beta-reduction, useless let elimination). The final codegen is flaky but it generates the test instrument and that instrument works.

Depending how you count I first started working on this 10 years ago (generating RTCmix with PLT Scheme), so although the success comes with heavy caveats, I'm pleased.

Tuesday, April 17, 2012

Cont ML

Copperbox revision 2735.

I've now implemented the tail CPS transformation.

I think there might be a mistake in the paper "Compiling with Continuations, Continued" - the CPS transformation in Figure 8 uses syntax for lambda abstraction which is present in the untyped CPS syntax but not in the typed syntax in Figure 7. I've added Abs to the Val type in my implementation.

Cont ML

Copperbox revision 2724.

Initial work on an implementation of the Mini ML in Andrew Kennedy's "Compling with Continuations, Continued" paper.

Although I'm working on the larger typed language, I might avoid typing. I've written the parser and pretty printer, I haven't tackled the CPS transform yet.

Sunday, April 15, 2012

copperbox updates

Updates to Copperbox...

Revision 2730 - added zformat, formatting combinators with an interface like pretty print combinators but no prettiness i.e. no fitting / line breaking.

Revision 2731 - added directory-script. This should replace directory-diff, however I'm not sure if I have a use-case to work on this project any more, so it might get punted to the long grass as it currently stands.

Revisions 2732 & 2733 - renaming hpj-pretty-expr to pretty-expr-hpj and reorganizing the source directories.

I've done quite a bit of work over the last fortnight, but I haven't felt like committing it until today. I had a processor meltdown this morning (the fan on the processor needs the contact "glue" re-applying) so I thought I better finally make a commit.

Blog Archive

About Me

My photo
Disambiguating biog as there are a few Stephen Tetley's in the world. I'm neither a cage fighter or yachtsman. I studied Fine Art in the nineties (foundation Bradford 1992, degree Cheltenham 1992 - 95) then Computing part-time at Leeds Met graduating in 2003. I'm the Stephen Tetley on Haskell Cafe and Stackoverflow.