swarm-0.5.0.0: 2D resource gathering game with programmable robots
LicenseBSD-3-Clause
Safe HaskellSafe-Inferred
LanguageHaskell2010

Swarm.Game.World.Compile

Description

Compiling abstracted combinator expressions (BTerm) to native Haskell terms. This can supposedly be more efficient than directly interpreting BTerms, but some benchmarking is probably needed to decide whether we want this or not.

For more info, see:

https://byorgey.wordpress.com/2023/07/13/compiling-to-intrinsically-typed-combinators/

Synopsis

Documentation

data CTerm a where Source #

Constructors

CFun :: (CTerm a -> CTerm b) -> CTerm (a -> b) 
CConst :: NotFun a => a -> CTerm a 

Instances

Instances details
Applicable CTerm Source # 
Instance details

Defined in Swarm.Game.World.Compile

Methods

($$) :: CTerm (a -> b) -> CTerm a -> CTerm b Source #

unary :: (NotFun a, NotFun b) => (a -> b) -> CTerm (a -> b) Source #

binary :: (NotFun a, NotFun b, NotFun c) => (a -> b -> c) -> CTerm (a -> b -> c) Source #

type family NoFunParams a :: Constraint where ... Source #

Equations

NoFunParams (a -> b) = (NotFun a, NoFunParams b) 
NoFunParams _ = () 

runCTerm :: NoFunParams a => CTerm a -> a Source #

Interpret a compiled term into the host language.