plow-technologies / inferno

A statically-typed functional scripting language
MIT License
4 stars 1 forks source link

Defer evaluating prelude expr defs until runtime #98

Closed siddharth-krishna closed 10 months ago

siddharth-krishna commented 10 months ago

This PR aims to reduce the memory consumption of inferno, by storing prelude functions that are defined as inferno Exprs as Exprs in the prelude and not evaluating the expressions until runtime. You can think of this as though we're inlining any such primitives to the script.

Because of this, prelude evaluation no longer needs to be within the ImplEnvM monad, so that has been removed as well. This has meant we changed the type of toValue to no longer be under a monad too.

This should reduce the memory consumption significantly, but might increase runtime slightly. I don't expect the increase to be too much because most primitive definitions are functions, so they can't be fully evaluated at compile time anyway, which is why they were being stored in memory as huge thunks.