hnock

A Nock interpreter.
git clone git://git.jtobin.io/hnock.git
Log | Files | Refs | README | LICENSE

Language.hs (701B)


      1 module Nock.Language (
      2     Noun(..)
      3   , Expr(..)
      4   ) where
      5 
      6 import Numeric.Natural (Natural)
      7 
      8 data Noun =
      9     Atom Natural
     10   | Cell Noun Noun
     11   deriving Eq
     12 
     13 instance Show Noun where
     14   show noun = case noun of
     15     Atom m   -> show m
     16     Cell m n -> mconcat ["[", show m, " ", show n, "]"]
     17 
     18 data Expr =
     19     Noun !Noun
     20   | Wut !Noun
     21   | Lus !Noun
     22   | Tis !Noun
     23   | Net !Noun
     24   | Hax !Noun
     25   | Tar !Noun
     26   deriving Eq
     27 
     28 instance Show Expr where
     29   show op = case op of
     30     Noun n -> show n
     31     Wut n  -> mconcat ["?", show n]
     32     Lus n  -> mconcat ["+", show n]
     33     Tis n  -> mconcat ["=", show n]
     34     Net n  -> mconcat ["/", show n]
     35     Hax n  -> mconcat ["#", show n]
     36     Tar n  -> mconcat ["*", show n]
     37