Hacker Newsnew | comments | show | ask | jobs | submitlogin

Not sure if you've seen this one:

http://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_H...

I haven't done it, but I hear its excellent.




This was how I learned Haskell. I rather liked it.

That said, looking back, I'm not sure it encourages the best coding style or the best idioms. It's perfect for getting your head around the paradigm though!

I'm currently writing an analogous tutorial for implementing Prolog in Haskell, but it's on a bit of a hiatus thanks to some school and research related deadlines coming up. Hopefully people are interested in something like that :).

Interestingly enough, the Prolog interpreter is actually shorter than the simple Scheme one--largely because we can take advantage of the list monad for the backtracking. I think it's still a very cool exercise.

-----


I would be very interested in seeing a tutorial detailing how to implement Prolog in Haskell!

-----


Not really a tutorial and not really Prolog, but here's an interpreter for a logic programming language written in Haskell: https://github.com/rikusalminen/slolog

I wrote it as a project work in an Artificial Intelligence class. It very closely resembles the logic programming language implemented in "Structure and Interpretation of Computer Programs".

I'm sorry there isn't any documentation for it.

Here's a little example of what it looks like, from examples/royalfamily.slo:

(siblings ?x ?y) <- (parent ?x ?parent) & (parent ?y ?parent)

(grandparent ?x ?y) <- (parent ?x ?z) & (parent ?z ?y)

(cousins ?x ?y) <- (grandparent ?x ?gp) & (grandparent ?y ?gp) & !(siblings ?x ?y)

-----


That sounds awesome! I'd be very interested in that prolog interpreter tutorial.

-----


It would be even more excellent if people for a change wrote more _in_ scheme instead of _a_ scheme.

-----


Why write a program that gets your job done when you can just as easily write a language that makes writing that program trivial?

(I'm only being partly tongue-in-cheek - that's mentality behind idiomatic Lisp).

-----


It would be the equivalent to writing Java on top of Haskell. You wouldn't creat Java, you would be creating _a_ Java.

"Scheme" has many different dialects as well. Racket is _a_ Scheme, Edwin interprets MIT's version of Scheme, then there is Gambit Scheme. There are certainly other Schemes, and the implementation of Scheme on Haskell isn't going to be the same as the other dialects listed here.

There are quite a few examples of Prolog-to-Lisp interpreters, but no one would argue that any of these _are_ Prolog.

-----


I would say this tutorial is an excellent one to read through when you are first learning Haskell, and then return to it later when you have a better understanding of the language. Some important concepts are glazed over, and you will almost certainly not understand what is going on the first time you read the tutorial.

Once you are comfortable with Haskell the code makes much more sense and is a great starting point for writing an interpreter of your own.

-----




Applications are open for YC Summer 2015

Guidelines | FAQ | Support | Lists | Bookmarklet | DMCA | Y Combinator | Apply | Contact

Search: