hspl
is a very simple interpreter of a subset of Prolog written in Literate
Haskell. I wrote it as an exercise to grasp basics of both Prolog and Haskell.
It may be interesting to you if you want to play around with either Prolog or Haskell, or if you're interested in some of topics below.
Feel free to contact me if you have any questions.
- "Nondeterministic" monadic parsers
- Global state in Haskell using
Control.Monad.State
- Basic implementation of Prolog resolution method and backtracking
- Most of Prolog's features: arithmetics, operators (such as
=
,is
, etc.) - I didn't use monad transformers to intermix
State
withIO
, so I cannot use ie. theconsult("filename")
predicate to load the file during execution
I didn't provide any "User's Manual", as there are hardly any users to this; it's meant as a learning aid to other novice Haskell programers.
Sure enough, there are bugs.
Test inputs may be found in tests/
. I didn't provide an automated test runner,
but generally whatever you find in tests/
should work well.
In the unlikely case that you needed basic rules for list manipulation, for
example, you may find them in tests/lists.pl
.
The sources constitute of:
Main.hs
, the application's entry pointInterpreter.lhs
, the Prolog interpreter itself, andParser.lhs
, the monadic parser of Prolog.
- My question on Code Review Stack Exchange
regarding the
Parser
module.