Skip to content

Lisp方言ずら〜。え!? これを使えばQuasiQuotesでコンパイル時Lispが書けるずら!?

License

Notifications You must be signed in to change notification settings

aiya000/hs-zuramaru

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

((((zuramaru)))) Build Status Hackage

おらは 国木田花丸 ずら〜

A lisp dialect, an inline-lisp library

An inline-lisp in Haskell

QuasiQuoters supports in this module

💪 Example 💪

1️⃣ S expression parser

As expressions

>>> print [parse|123|]
AtomInt 123

>>> print [parse|sugar|]
AtomSymbol "sugar"

>>> print [parse|(1 2 3)|]
Cons (AtomInt 1) (Cons (AtomInt 2) (Cons (AtomInt 3) Nil))

As patterns

>>> case AtomInt 123 of; [parse|123|] -> "good"
"good"

>>> case AtomInt 000 of; [parse|123|] -> "bad"; AtomInt _ -> "good"
"good"

>>> case Cons (AtomSymbol "x") (Cons (AtomInt 10) Nil) of; [parse|(x 10)|] -> "good"
"good"

As types (compile time calculations)

>>> fromSing (sing :: Sing [parse|10|])
AtomInt 10

>>> fromSing (sing :: Sing [parse|konoko|])
AtomSymbol "konoko"

>>> fromSing (sing :: Sing [parse|(1 2 3)|])
Cons (AtomInt 1) (Cons (AtomInt 2) (Cons (AtomInt 3) Nil))

2️⃣ S expression parser + preprocessor

>>> [parsePreprocess|sugar|]
AtomSymbol "sugar"

>>> [parsePreprocess|'10|]
Quote (AtomInt 10)

>>> [parsePreprocess|(quote 10)|]
Quote (AtomInt 10)

3️⃣ S expression parser + preprocessor + evaluator

>>> [zurae|10|]
10

>>> [zurae|(print 10)|]
10Nil

>>> [zurae|'10|]
AtomInt 10

>>> [zurae|sugar|]
<interactive>:12:8: error:
     Maru.QQ.zurae: an error is occured in the compile time: EvalException: "A symbol 'sugar' is not found"
     In the quasi-quotation: [zurae|sugar|]

Please see below modules's doctests for more infomation

About

Lisp方言ずら〜。え!? これを使えばQuasiQuotesでコンパイル時Lispが書けるずら!?

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published