Wow... Visi works

56 views
Skip to first unread message

David Pollak

unread,
Dec 16, 2011, 3:07:20 PM12/16/11
to visi...@googlegroups.com
Well, it's been a month since I announced the whole Visi thing.  When I announces, I had a barely functional type checker and inferencer and a barely functional expression evaluator.

That's all changed in the last month.  As I've gotten my Haskell Foo on and gone with an existing implementation of Hindley-Milner type checking rather than trying to write my own from first principals, I've made a ton of progress with the Visi language.

For example, Visi can implement Factorial:

fact n = if n == 0 then 1 else n * fact n - 1
res = fact 10 //  testResults [("res", DoubleValue 3628800)] . checkResults)

The above code is taken right out of the Visi test suite.  Parsing, type checking, and computation works

Visi supports inner functions.  Rather than having an explicit "let" in the Visi syntax, you can define a local function 'fact' is referenced inside the 'f' function.  The local 'fact' function is passed, partially applied, to the 'app' function and correctly applied:

fact n = n & \"hello\" {-  propper scoping this fact is not the inner fact -}
f n = {- Test partially applied functions -}
  fact n = if n == 0 then 1 else n * fact(n - 1)
  app n fact
app v f = f v
res = f 8 // testResults [("res", DoubleValue 40320.0)] . checkResults)

Local functions close over scope.  For example, 'f' returns a local function that takes two parameters and references the 'b' variable and computes the product of the three variables.  The 'q' function applies 'f' to 8 and 'z' applies 'f' to 10.  WIth these functions, we can apply or partially apply the functions:

f b = {- test that the function closes over local scope -}
  timesb n m = n * b * m
  timesb
app v f = f v
q = f 8
z = f 10
res = (app 9 (app 8 q)) - ((z 8 9) + (z 1 1)) // testResults [("res", DoubleValue (-154))] . checkResults)

Note, too, the clean syntax.  No line-end characters.  No "let" keyword (although variable shadowing is possible and not yet flagged as an error).

So, check out the tests to get a better sense of both the Visi language and the test harness that I'm using for Test Driven Development.

--
Visi.Pro, Cloud Computing for the Rest of Us http://visi.pro
Lift, the simply functional web framework http://liftweb.net


lkuczera

unread,
Dec 19, 2011, 4:40:24 PM12/19/11
to Visi Language
Sorry for offtopic, can it be run in ios emulator ? Issue is I don't
have iPad and would like to try it out without buying one :)

On Dec 16, 9:07 pm, David Pollak <feeder.of.the.be...@gmail.com>
wrote:


> Well, it's been a month since I announced the whole Visi thing.  When I
> announces, I had a barely functional type checker and inferencer and a
> barely functional expression evaluator.
>
> That's all changed in the last month.  As I've gotten my Haskell Foo on and
> gone with an existing

> implementation<http://dysphoria.net/2009/06/28/hindley-milner-type-inference-in-scala/>of
> Hindley-Milner <http://en.wikipedia.org/wiki/Type_inference> type checking

> tests<https://github.com/visi-lang/visi/blob/b73f83220f975d8f532a2367548993...>to


> get a better sense of both the Visi language and the test harness that
> I'm using for Test Driven Development.
>
> --

> Visi.Pro, Cloud Computing for the Rest of Ushttp://visi.pro
> Lift, the simply functional web frameworkhttp://liftweb.net

David Pollak

unread,
Dec 19, 2011, 4:57:09 PM12/19/11
to visi...@googlegroups.com
On Mon, Dec 19, 2011 at 1:40 PM, lkuczera <kuk...@gmail.com> wrote:
Sorry for offtopic, can it be run in ios emulator ?

What is now on master cannot even be run on an iPad (or simulator) because of the mis-match between GHC 6.10 (which is required by GHC-iPhone) and GHC 7 (which I am now using to do development.)  Sometime in the next few months, GHC-iPhone will be updated to run against GHC 7.

The current Visi language code can be run on any system with GHC 7 just by cd'ing into core/src and typing "./run_tests"

Over the next few weeks, I plan to put an OS X GUI wrapper around Visi so that people with Macs can get a full GUI experience.

Once GHC-iPhone moves to GHC 7 and I can get stable builds on OS X and iOS, then there'll be source that can be used for both.

The longer term plan is to allow Visi apps to run in a "client" (OS X and iOS) but migrate computation and storage to a "server" (most likely Linux 'cause Linux boxes are cheap and easy to manage).

Hope this helps.



--
Visi.Pro, Cloud Computing for the Rest of Us http://visi.pro
Lift, the simply functional web framework http://liftweb.net
Reply all
Reply to author
Forward
0 new messages