Skip to content

Latest commit

 

History

History
52 lines (32 loc) · 1.28 KB

README.md

File metadata and controls

52 lines (32 loc) · 1.28 KB

Horth

Horth programming language is Forth-like embeded language inside Haskell.

{-# LANGUAGE QualifiedDo, DataKinds #-}
module HelloWorld where
  
import Horth

hello :: Shape '[] '[]
hello = Horth.do
  literal "hello, world"
  println

main :: IO ()
main = do
  run hello
  return ()

Examples

For basic DSL usage see app/Examples.hs.

For usage with RebindableSyntax see app/ExamplesRebindable.hs

Language documentation

Definition of a word

Word is any function from Horth.State to Horth.State, where State is IO (HList xs). Essentialy words are stack transformations with side effects.

Word composition

Currenlty there are 3 equavilent methods of composing words in Horth:

  • Using overloaded do notation: (Horth.do foo; bar)
  • Using function composition: (bar . foo)
  • Using sequence operator: (foo >> bar)

each of this program will first run foo and then bar.

List of defined words

All defined words can be found in:

additionaly there is literal word that accepts value and puts it on stack, e.g. literal 42 puts 42 onto stack.