?

Log in

No account? Create an account
While beautiful Laura's sweeping the porch / He's teleconferencing up his operation torch - MrPutter: doing things the hard way, because it is there.
August 30th, 2007
11:18 am
[User Picture]

[Link]

Previous Entry Share Next Entry
While beautiful Laura's sweeping the porch / He's teleconferencing up his operation torch
I can has syntax?

Yes! Can has syntax!


So far my language has existed mostly in the form of commutative diagrams and ASTs. But it now has a concrete syntax! (Or most of one, anyway.)

And indeed finally has its first (albeit somewhat useless) example program. Yarr!


type Request = (Integer, Identification)
type Identification = Integer

data Bool = True | False
data Response = Dollar Integer | Deny

protocol User = #Use Request >> (Response << User)
protocol Bank = #Dbt Request >> Bank
protocol Credit = #Cdt Request >> (Bool << Credit)

Bank_Machine :: usr : User ||- bnk : Bank, crd : Credit
Bank_Machine =
    drive Process by usr:
        #Use: get usr (x, id) => case x of
            True  -> put bnk #Dbt (x, id) ; put usr Dollar x ; Process
            False -> put crd #Cdr (x, id) ; get crd p => case p of
                True  -> put bnk #Dbt (x, id) ; put usr Dollar x ; Process
                False -> put usr Deny ; Process

-- don't you just love it when debiting your account is a no-op?
Bank_Account :: bnk : Bank ||- 1 : 1
Bank_Account =
    drive Process by bnk:
        #Dbt: get bnk (x, id) => Process

-- even-numbered accounts always pass the credit check, har
Credit_Check :: crd : Credit ||- 1 : 1
Credit_Check =
    drive Process by crd:
        #Cdt: get crd (x, id) => case id % 2 of
            1 -> put crd False ; Process
            0 -> put crd True ; Process



And everybody join in with me now! I say: Hallelujah!
"And everybody join in with me now! I say: Hallelujah!"

Current Location: T2N 1N4
Current Mood: accomplished
Current Music: The Fiery Furnaces -- We Got Back the Plague
Tags: , , , , ,

(Leave a comment)

Beware of Road Surprises Powered by LiveJournal.com