-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Stack-based concatenative language embedded in Haskell -- -- Jaskell is a stack-based programming language implemented using normal -- Haskell types and functions, along with a quasiquoter that allows for -- a more elegant syntax than what pure Haskell supports. Since it is -- embedded in Haskell, Jaskell is purely functional and, unlike other -- stack-based languages, statically typed. The standard library is based -- on that of Joy, and the name "Jaskell" is a portmanteau of -- "Joy" and "Haskell." -- -- A Jaskell program is a sequence of commands. Each command is a -- function which takes a stack — represented in Haskell as a left-nested -- tuple — and returns another stack. In order to accomodate side -- effects, commands need not actually be functions; any arrow is allowed -- as a command. The two most useful arrow types are (->) and -- Kleisli IO. -- -- Two example programs are shown below. The first program asks for the -- user's name and then prints a greeting. The second program defines a -- qsort function and then uses it to sort a list. -- --
--   {-# LANGUAGE QuasiQuotes #-}
--   import qualified Jaskell
--   import Jaskell.Quote (jsl)
--   import Jaskell.Prelude
--   
--   main :: IO ()
--   main = Jaskell.runK [jsl|
--     "What's your name?" !putStrLn [ "Hello, ", ?getLine, "!" ] $concat !putStrLn
--     |]
--   
--   sorted :: ((), [Int])
--   sorted = Jaskell.run [jsl|
--     DEF small =
--       { $null } { uncons $null } disjoin ;
--     DEF qsort =
--       small { } { uncons { < } split rolldown }
--       { swap cons ++ } binrec' ;
--     [3,5,1,6,4,2] qsort
--     |]
--   
@package jaskell @version 0.1.0.0 module Jaskell -- | Run a direct Jaskell program on an empty stack. run :: (() -> t) -> t -- | Run a direct Jaskell program on the given stack. runOn :: s -> (s -> t) -> t -- | Run a monadic Jaskell program on an empty stack. runK :: Kleisli m () t -> m t -- | Run a monadic Jaskell program on the given stack. runKOn :: s -> Kleisli m s t -> m t -- | Push a value. push :: Arrow arr => a -> arr s (s, a) -- | Apply a function to the top value. liftS :: Arrow arr => (a -> b) -> arr (s, a) (s, b) -- | Apply a function to the top two values. liftS2 :: Arrow arr => (a -> b -> c) -> arr ((s, a), b) (s, c) -- | Perform a monadic action and push the result. pushM :: Functor m => m a -> Kleisli m s (s, a) -- | Pop the top value and feed it to a monadic action. popM :: Functor m => (a -> m ()) -> Kleisli m (s, a) s -- | Pop the top value, feed it to a monadic action, and push the result. liftSM :: Functor m => (a -> m b) -> Kleisli m (s, a) (s, b) -- | A standard library for Jaskell. The names of most functions in this -- module come from the Joy programming language (see here for a -- list of Joy commands). module Jaskell.Prelude stack :: Arrow arr => arr s (s, s) unstack :: Arrow arr => arr (s, t) t newstack :: Arrow arr => arr a () pop :: Arrow arr => arr (s, a) s dup :: Arrow arr => arr (s, a) ((s, a), a) swap :: Arrow arr => arr ((s, a), b) ((s, b), a) popd :: Arrow arr => arr ((s, a), b) (s, b) pop2 :: Arrow arr => arr ((s, a), b) s dupd :: Arrow arr => arr ((s, a), b) (((s, a), a), b) dup2 :: Arrow arr => arr ((s, a), b) ((((s, a), b), a), b) swapd :: Arrow arr => arr (((s, a), b), c) (((s, b), a), c) rollup :: Arrow arr => arr (((s, a), b), c) (((s, c), a), b) rolldown :: Arrow arr => arr (((s, a), b), c) (((s, b), c), a) choice :: Arrow arr => arr (((s, Bool), a), a) (s, a) select :: (Arrow arr, Eq a) => arr (((s, a), [(a, b)]), b) (s, b) pair :: Arrow arr => arr ((s, a), b) (s, (a, b)) unpair :: Arrow arr => arr (s, (a, b)) ((s, a), b) cons :: Arrow arr => arr ((s, a), [a]) (s, [a]) swons :: Arrow arr => arr ((s, [a]), a) (s, [a]) uncons :: Arrow arr => arr (s, [a]) ((s, a), [a]) unswons :: Arrow arr => arr (s, [a]) ((s, [a]), a) conjoin :: (Arrow arr, Arrow arr') => arr ((s, arr' t (u1, Bool)), arr' t (u2, Bool)) (s, arr' t (t, Bool)) disjoin :: (Arrow arr, Arrow arr') => arr ((s, arr' t (u1, Bool)), arr' t (u2, Bool)) (s, arr' t (t, Bool)) i :: ArrowApply arr => arr (s, arr s t) t comp :: (Arrow arr, Arrow arr') => arr ((s, arr' a b), arr' b c) (s, arr' a c) consQ :: (Arrow arr, Arrow arr') => arr ((s, a), arr' (t, a) c) (s, arr' t c) swonsQ :: (Arrow arr, Arrow arr') => arr ((s, arr' (t, a) c), a) (s, arr' t c) nullary :: ArrowApply arr => arr (s, arr s (t, a)) (s, a) dip :: ArrowApply arr => arr ((s, a), arr s t) (t, a) dipd :: ArrowApply arr => arr (((s, a), b), arr s t) ((t, a), b) dipdd :: ArrowApply arr => arr ((((s, a), b), c), arr s t) (((t, a), b), c) app1 :: ArrowApply arr => arr ((s, a), arr (s, a) (t, b)) (s, b) app2 :: ArrowApply arr => arr (((s, a), a), arr (s, a) (t, b)) ((s, b), b) app3 :: ArrowApply arr => arr ((((s, a), a), a), arr (s, a) (t, b)) (((s, b), b), b) cleave :: ArrowApply arr => arr (((s, a), arr (s, a) (t1, b1)), arr (s, a) (t2, b2)) ((s, b1), b2) ifte :: ArrowApply arr => arr (((s, arr s (t, Bool)), arr s u), arr s u) u branch :: ArrowApply arr => arr (((s, Bool), arr s t), arr s t) t cond :: (ArrowApply arr, ArrowChoice arr) => arr ((s, [(arr s (t, Bool), arr s u)]), arr s u) u infra :: ArrowApply arr => arr ((s, t), arr t u) (s, u) whiledo :: (ArrowApply arr, ArrowChoice arr) => arr ((s, arr s (t, Bool)), arr s s) s tailrec :: (ArrowApply arr, ArrowChoice arr) => arr (((s, arr s (t, Bool)), arr s u), arr s s) u linrec :: (ArrowApply arr, ArrowChoice arr) => arr ((((s, arr s (t, Bool)), arr s u), arr s s), arr u u) u linrec' :: (ArrowApply arr, ArrowChoice arr) => arr ((((s, arr s (t, Bool)), arr s u), arr s (s, c)), arr (u, c) u) u binrec :: (ArrowApply arr, ArrowChoice arr) => arr (((((s, a), arr (s, a) (t, Bool)), arr (s, a) (u, b)), arr (s, a) ((s, a), a)), arr ((s, b), b) (u, b)) (u, b) binrec' :: (ArrowApply arr, ArrowChoice arr) => arr (((((s, a), arr (s, a) (t, Bool)), arr (s, a) (u, b)), arr (s, a) (((s, a), a), c)), arr (((s, b), b), c) (u, b)) (u, b) natrec :: (ArrowApply arr, ArrowChoice arr) => arr (((s, Int), arr s (t, b)), arr ((s, Int), b) (t, b)) (t, b) listrec :: (ArrowApply arr, ArrowChoice arr) => arr (((s, [a]), arr s (t, b)), arr ((s, a), b) (t, b)) (t, b) data CLROption arr s u Stop :: arr s u -> CLROption arr s u Recurse :: arr s s -> arr u u -> CLROption arr s u condlinrec :: (ArrowApply arr, ArrowChoice arr) => arr ((s, [(arr s (t, Bool), CLROption arr s u)]), CLROption arr s u) u times :: (ArrowApply arr, ArrowChoice arr) => arr ((s, Int), arr s s) s step :: (ArrowApply arr, ArrowChoice arr) => arr ((s, [a]), arr (s, a) s) s step2 :: (ArrowApply arr, ArrowChoice arr) => arr (((s, [a]), [b]), arr ((s, a), b) s) s map :: Arrow arr => arr ((s, [a]), (s, a) -> (t, b)) (s, [b]) mapS :: (ArrowApply arr, ArrowChoice arr) => arr ((s, [a]), arr (s, a) (s, b)) (s, [b]) filter :: Arrow arr => arr ((s, [a]), (s, a) -> (t, Bool)) (s, [a]) filterS :: (ArrowApply arr, ArrowChoice arr) => arr ((s, [a]), arr (s, a) (s, Bool)) (s, [a]) split :: Arrow arr => arr ((s, [a]), (s, a) -> (t, Bool)) ((s, [a]), [a]) splitS :: (ArrowApply arr, ArrowChoice arr) => arr ((s, [a]), arr (s, a) (s, Bool)) ((s, [a]), [a]) any :: (ArrowApply arr, ArrowChoice arr) => arr ((s, [a]), arr (s, a) (t, Bool)) (s, Bool) all :: (ArrowApply arr, ArrowChoice arr) => arr ((s, [a]), arr (s, a) (t, Bool)) (s, Bool) zipwith :: Arrow arr => arr (((s, [a]), [b]), ((s, a), b) -> (t, c)) (s, [c]) zipwithS :: (ArrowApply arr, ArrowChoice arr) => arr (((s, [a]), [b]), arr ((s, a), b) (s, c)) (s, [c]) -- | The jsl quasiquoter converts Jaskell syntax into Haskell -- syntax. -- -- A Jaskell expression is a sequence of commands. An command is one of -- the following: -- -- -- -- 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. module Jaskell.Quote -- | Embed a Jaskell program into Haskell. jsl :: QuasiQuoter data NameMode Bare :: NameMode LiftS :: NameMode LiftS2 :: NameMode PushM :: NameMode PopM :: NameMode LiftSM :: NameMode data Name Fun :: [String] -> String -> Name Ctor :: [String] -> String -> Name data Literal Char :: Char -> Literal String :: String -> Literal Integer :: Integer -> Literal Double :: Double -> Literal Unit :: Literal data Command Name :: NameMode -> Name -> Command Op :: String -> Command List :: [Expr] -> Command Tup :: Expr -> Expr -> Command Quote :: Maybe Expr -> Command Lit :: Literal -> Command newtype Expr Expr :: NonEmpty Command -> Expr data Program Program :: [(String, Expr)] -> Expr -> Program type Parser = Parsec Void String parseName :: Parser Name parseLiteral :: Parser Literal parseCommand :: Parser Command parseExpr :: Parser Expr parseProgram :: Parser Program instance GHC.Show.Show Jaskell.Quote.NameMode instance GHC.Classes.Eq Jaskell.Quote.NameMode instance GHC.Show.Show Jaskell.Quote.Name instance GHC.Classes.Eq Jaskell.Quote.Name instance GHC.Show.Show Jaskell.Quote.Literal instance GHC.Classes.Eq Jaskell.Quote.Literal instance GHC.Show.Show Jaskell.Quote.Command instance GHC.Classes.Eq Jaskell.Quote.Command instance GHC.Show.Show Jaskell.Quote.Expr instance GHC.Classes.Eq Jaskell.Quote.Expr instance GHC.Show.Show Jaskell.Quote.Program instance GHC.Classes.Eq Jaskell.Quote.Program