Skip to content

vrescobar/elm2openfl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

elm2openfl

Port of the elm examples to haxe's OpenFL framework; or at least the most equivalent code in idiomatic haxe and openfl. I don't try to force OpenFL work in the way Elm does, but using equivalent patterns to solve the same problems, e.g. instead of use haxe signals, the way to go in openfl is to use events.

This repository has been created for my own learning but additional ideas and pull requests are also welcome.

In the comparison between Elm and Haxe it is possible to see that Elm signals are very often just a one liner and Haxe uses a verbose class (very often with much more options) which is per design full of side effects.

To change that part of OpenFL the design would mean a whole new signal library and probably also a new renderer which keeps the status in a nested/composable data structure and diff it between the frame renderings.

That is not possible without rewrite the whole OpenFL and Lime almost from the basement.

Parts of the elm library which I implemented

I am also lazily implementing the minimum required functions/classes from Elm which I need to implement the examples. I am not really planning to port the things which already have an equivalent in openFL or haxe (for example I didn't port the HSL color schema, it is out of the scope of this project).

You can explore them in the package Elm from this repository.

Examples Implemented

Core

Not everything under the section core is relevant to haxe as they are different languages, but I find the type system of haxe flexible enough to implement everything that Elm has to offer without major complications.

union types

either
binary tree
boolean expressions

Visuals

Layout

Hello World
Simple layout

Events (Signals)

In elm the communication between the parts is mostly made with signals, even if haxe has several implementations and libraries of signals, in OpenFL events are the way to go.

Mouse

position
is down
clicks
tracker
yogi
stamps

Window

size
centering

Keyboard

arrows
wasd
keys down
key presses

Time

clock: This implementation is way different but with similar results.

Related repositories

elm2haxe: Those guys have more ambitious goal, but I can't really understand the logic behind their folder structure.

About

port of the elm examples to pure cross compilable openfl

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published