ANN: idris-cil - A Common Intermediate Language backend for Idris

302 views
Skip to first unread message

Rodrigo B. de Oliveira

unread,
Jul 27, 2015, 7:00:50 AM7/27/15
to idris...@googlegroups.com
Hi,

"Cross-platform compilers for functional languages" inspired me to write a CIL backend for Idris and it's been a lot of fun so far:

  https://github.com/bamboo/idris-cil

It very early stage but it can already compile HelloWorld and the generated CIL code is not too bad:

  https://gist.github.com/bamboo/4da42e1627e6e35a5620#file-helloworld-il

The ultimate goal is to be able to use Idris together with the Unity game engine.

Let me take this opportunity to thank and congratulate everyone involved with Idris, and Edwin Brady in particular for such inspiring work. I'm learning a lot.

Best wishes,
Rodrigo
  

Echo Nolan

unread,
Jul 27, 2015, 7:38:07 AM7/27/15
to idris...@googlegroups.com
Cool! Keep us updated when/if you get Unity integration working.

--
You received this message because you are subscribed to the Google Groups "Idris Programming Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to idris-lang+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

David Raymond Christiansen

unread,
Jul 27, 2015, 7:54:06 AM7/27/15
to idris...@googlegroups.com
Rodrigo,

This sounds really cool! Thanks so much for the pointer!

How does the FFI work? Are you planning on representing inheritance in
the FFI types?

/David

Rodrigo B. de Oliveira

unread,
Jul 27, 2015, 12:26:53 PM7/27/15
to idris...@googlegroups.com
Sure thing.

Rodrigo B. de Oliveira

unread,
Jul 27, 2015, 12:39:13 PM7/27/15
to idris...@googlegroups.com
Hi David,

FFI is the next big TODO but I haven't give it much thought yet.

First milestone will be importing/exporting static methods accepting primitive type arguments which looks easy enough and should allow for some more interesting applications. 

"Are you planning on representing inheritance in the FFI types?"

I'm still learning Idris so I'd be very curious to understand how something like that could be achieved idiomatically.

Thanks for the enthusiasm! 
Rodrigo

Rodrigo B. de Oliveira

unread,
Sep 14, 2015, 9:50:36 AM9/14/15
to Idris Programming Language
I'm happy to report that Unity integration is taking shape:

  https://vimeo.com/139207756

The FFI is still a bit rough around the edges as witnessed by the amount of believing required in the source but it will get better.

Excelsior!

David Christiansen

unread,
Sep 14, 2015, 10:10:50 AM9/14/15
to idris...@googlegroups.com
This is exceedingly cool. Thanks for sending the link!

As a matter of style, when I'm dealing with foreign objects, I usually
make some wrapper datatype that doesn't export its constructor, and keep
the raw Ptr in there. Like:

abstract
data GameState = MkGameState Ptr

rather than casting Ptrs using believe_me.

/David
> --
> You received this message because you are subscribed to the Google
> Groups "Idris Programming Language" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to idris-lang+...@googlegroups.com
> <mailto:idris-lang+...@googlegroups.com>.

Rodrigo B. de Oliveira

unread,
Sep 14, 2015, 10:43:21 AM9/14/15
to idris...@googlegroups.com
Thanks for the feedback, David!

Soon it will be possible to have the record type as part of the exported function signature effectively removing the need for those Ptr casts.

To unsubscribe from this group and stop receiving emails from it, send an email to idris-lang+...@googlegroups.com.

Rodrigo B. de Oliveira

unread,
Sep 20, 2015, 9:57:29 PM9/20/15
to idris...@googlegroups.com
The source code for that first Unity integration experiment is now online at https://github.com/bamboo/IdrisUnityPlayground in case anyone wants to play with it. 

Notice that Ptr and believe_me are no longer required when exporting data types:


The declaration of exports is still a bit verbose at this point but I'm hoping it can be simplified with some %runElab magic in the future:

  exports : FFI_Export FFI_CIL "GameOfLifeBehaviour" []
  exports =
    Data Game "Game" $
    Fun start CILDefault $ 
    Fun update CILDefault
    End

Your comments and suggestions are appreciated. 

Jeremy Shaw

unread,
Sep 21, 2015, 8:49:04 PM9/21/15
to idris...@googlegroups.com
Oh nice! Very excited. In fact, I was in the middle of watching Unity tutorials in another tab when I first read this announcement.

- jeremy

--
Reply all
Reply to author
Forward
0 new messages