Skip to content

RobertBendun/horth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Forth-like language as EDSL in Haskell

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published