Home

Awesome

Hypatia - A ML-family Language Compiled to Lua

Hello stranger,

How did you end up here? Let me introduce myself, I am Hypatia, youngest child of the ML family. As it is tradition, my name was given to honour a deceased mathematician. Who I am? Well isn't that the question we all ask ourselves? I am still young, I have dreams, but I have not found my purpose yet. I am similar to my siblings, Purescript and Elm, but I compile to Lua. I am walking in the footsteps of my ancestors, but I want to be different: I want to make games. So let me tell you about me.

My Appearance

module Example

import Native(Number, Array, (/))
import Native.Love(setColor, circle, rectangle)
import Common.Array(map)
import Geometry.Vector2(Vector2)

// This is an algebraic datatype.
// A Primitive is either a Rectangle or a Circle.
// Datatypes can have type variables.
// So this type could become a Primitive (Vector2 Number), Primitive (Vector3 Number) and more.
type Primitive point = Rectangle point point | Circle point Radius

// You can give types a new name with an alias
alias Radius = Number

alias Primitive2d = Primitive (Vector2 Number)


fill (Circle (Vector2 x y) r) = circle "fill" x y r
fill (Rectangle (Vector2 x y) (Vector2 w h)) = rectangle "fill" x y w h

primitives : Array Primitive2d
primitives = [
    Rectangle (Vector2 150 100) (Vector2 100 400),
    Rectangle (Vector2 350 100) (Vector2 100 400),
    Rectangle (Vector2 250 250) (Vector2 100 100),
    Rectangle (Vector2 550 300) (Vector2 100 200),
    Circle (Vector2 550 200) 100]

draw _ =
    let
        _ = setColor (70 / 255) (40 / 255) (250 / 255)
    in map fill primitives

People say, I look like my father, Haskell, but somehow I am a little different:

It was nice to talk with you stranger.

xoxo<br> Hypatia

How to get started

Hypatia is a prototype of a functional language of the ML-family that compiles to lua. People are writing game engines in functional languages, however functional scripting languages are rarely seen. Hypatia could fill this gap and it could reuse parts of the existing lua ecosystem.

Install the game engine love and GHC then run

cd path/of/hypatia
cabal install hypatia
cd examples
hypatia compile Spheres
love lua

Head over to the folder "examples" to see how applications look like.