bkowalik / asci

Another Scheme Console Interpreter
1 stars 0 forks source link

REPL internal structure - research #5

Closed mikusp closed 10 years ago

mikusp commented 10 years ago

How to represent functions of variable arity, quoting, control flow etc.

mikusp commented 10 years ago

Rough idea in pseudo Haskell:

data Environment = Env {
    env :: Map String LispVal
}

data Arity = Fixed Int | Variable
data LispVal = ...
             | FromScalaFun (Fun[_] -> LispVal) Arity

At start, we build an initial environment using native Scala function wrapped in a LispVal so they can receive an Arity of LispVals and return a LispVal. This way we avoid the bootstrapping problem - how to write this function in Scheme if I have no functions to use.

Is there a way in Scala to type-check a function of arbitrary arity? Sort of Function[, A] where can be A, Function[B, A], List[A], etc.

mikusp commented 10 years ago

Relevant files from husk-scheme: http://hackage.haskell.org/package/husk-scheme-3.17/docs/src/Language-Scheme-Environments.html http://hackage.haskell.org/package/husk-scheme-3.17/docs/src/Language-Scheme-Core.html

mikusp commented 10 years ago

Last commits seem to resolve wrapping Scala almost native functions into Scheme world. Relevant commits: https://github.com/bkowalik/asci/commit/b0a0933e3f835a8d91c45ce5589eca4b5a5e2885, https://github.com/bkowalik/asci/commit/3f945954e8e842e2a4c67a61fb20d5a600b07fa6, https://github.com/bkowalik/asci/commit/1bac9224d6cb0b4eb27eabae49af93ffdd308d51.