jaskell-0.1.0.0: Stack-based concatenative language embedded in Haskell
Copyright(c) Owen Bechtel 2023
LicenseMIT
Maintainerombspring@gmail.com
Stabilityexperimental
Safe HaskellSafe-Inferred
LanguageHaskell2010

Jaskell.Quote

Description

The jsl quasiquoter converts Jaskell syntax into Haskell syntax.

A Jaskell expression is a sequence of commands. An command is one of the following:

  • A Haskell identifier, optionally preceded by $, #, ?, !, or &. The identifier can be qualified or unqualified, and can be lowercase (function) or uppercase (data constructor). It cannot be an operator.

    • An identifier x translates to x if x is a function, and push x if x is a data constructor.
    • $x translates to liftS x. For example, $reverse will reverse the list on top of the stack.
    • #x translates to liftS2 x. For example, #gcd will pop the top two values and push their gcd.
    • ?x translates to pushM x. For example, ?getLine will execute getLine and push the result.
    • !x translates to popM x. For example, !putStrLn will print the string on top of the stack.
    • &x translates to liftSM x. For example, &readFile will pop a file path and push the contents of that file.
  • A Haskell operator. This translates to liftS2 applied to the operator.
  • A list of zero or more expressions, surrounded in square brackets and separated by commas. For example, [ 1, 3, 4 1 + ] pushes the list [ 1, 3, 5 ] onto the stack.
  • A tuple of two expressions. For example, ( 0, "a" "b" ++ ) pushes the tuple ( 0, "ab" ) onto the stack.
  • An empty tuple. This translates to push ().
  • An integer, floating-point, character, or string literal. For example, 5 translates to push 5.
  • A (potentially empty) expression surrounded in curly brackets. This pushes the translation of the expression onto the stack, allowing for higher-order programming.

Jaskell programs can be preceded by zero or more definitions, each of the form DEF name = expr ;. Definitions can be recursive and even mutually recursive.

Synopsis

Quasiquoter

jsl :: QuasiQuoter Source #

Embed a Jaskell program into Haskell.

Parser internals

data NameMode Source #

Constructors

Bare 
LiftS 
LiftS2 
PushM 
PopM 
LiftSM 

Instances

Instances details
Show NameMode Source # 
Instance details

Defined in Jaskell.Quote

Eq NameMode Source # 
Instance details

Defined in Jaskell.Quote

data Name Source #

Constructors

Fun [String] String 
Ctor [String] String 

Instances

Instances details
Show Name Source # 
Instance details

Defined in Jaskell.Quote

Methods

showsPrec :: Int -> Name -> ShowS #

show :: Name -> String #

showList :: [Name] -> ShowS #

Eq Name Source # 
Instance details

Defined in Jaskell.Quote

Methods

(==) :: Name -> Name -> Bool #

(/=) :: Name -> Name -> Bool #

data Literal Source #

Instances

Instances details
Show Literal Source # 
Instance details

Defined in Jaskell.Quote

Eq Literal Source # 
Instance details

Defined in Jaskell.Quote

Methods

(==) :: Literal -> Literal -> Bool #

(/=) :: Literal -> Literal -> Bool #

data Command Source #

Instances

Instances details
Show Command Source # 
Instance details

Defined in Jaskell.Quote

Eq Command Source # 
Instance details

Defined in Jaskell.Quote

Methods

(==) :: Command -> Command -> Bool #

(/=) :: Command -> Command -> Bool #

newtype Expr Source #

Constructors

Expr (NonEmpty Command) 

Instances

Instances details
Show Expr Source # 
Instance details

Defined in Jaskell.Quote

Methods

showsPrec :: Int -> Expr -> ShowS #

show :: Expr -> String #

showList :: [Expr] -> ShowS #

Eq Expr Source # 
Instance details

Defined in Jaskell.Quote

Methods

(==) :: Expr -> Expr -> Bool #

(/=) :: Expr -> Expr -> Bool #

data Program Source #

Constructors

Program [(String, Expr)] Expr 

Instances

Instances details
Show Program Source # 
Instance details

Defined in Jaskell.Quote

Eq Program Source # 
Instance details

Defined in Jaskell.Quote

Methods

(==) :: Program -> Program -> Bool #

(/=) :: Program -> Program -> Bool #