Hume (programming language)
Hume is a functionally based programming language developed at the University of St Andrews and Heriot-Watt University in Scotland since the year 2000.
≈ 3 min read
Names in other languages
No names in other languages are held for this entry yet.
Article bodies are English and are not machine-translated. A name in another language is not a translation of the article.
Hume is a functionally based programming language developed at the University of St Andrews and Heriot-Watt University in Scotland since the year 2000. The language name is both an acronym meaning 'Higher-order Unified Meta-Environment' and an honorific to the 18th-century philosopher David Hume.
It targets real-time computing embedded systems, aiming to produce a design that is both highly abstract, and yet allows precise extraction of time and space execution costs. This allows guaranteeing the bounded time and space demands of executing programs. Hume combines functional programming ideas with ideas from finite-state automata.
Automata are used to structure communicating programs into a series of "boxes", where each box maps inputs to outputs in a purely functional way using high-level pattern-matching. It is structured as a series of levels, each of which exposes different machine properties. data Coins = Nickel | Dime | Fake; data Drinks = Coffee | Tea; data Buttons = BCoffee | BTea | BCancel; type Int = int 32 ; exception EFakeCoin :: (Int, string) ; show v = v as string ; box coffee in ( coin :: Coins, button :: Buttons, value :: Int ) -- input channels out ( drink_outp :: string, value’ :: Int , refund_outp :: string, display :: string) -- named outputs within 500KB (400B) -- max heap ( max stack) cost bounding handles EFakeCoin, TimeOut, HeapOverflow, StackOverflow match -- * wildcards for unfilled outputs, and unconsumed inputs ( my_coin, *, v) {- join-pattern equivalent: coin(my_coin) & value(v) -} -> let v’ = incrementCredit my_coin v in ( *, v’, *, show v’) -- time bounding (within x time-unit) raises TimeOut () | ( *, BCoffee, v) {- join-pattern equivalent: button(BCoffee) & value(v) -} -> (vend Coffee 10 v) within 30s | ( *, BTea, v) -> (vend Tea 5 v) within 30s | ( *, BCancel, v) -> let refund u = "Refund " ++ show u ++ "\n" in ( *, 0, refund v, *) handle EFakeCoin (v, msg) -> ( *, v , *, msg) | TimeOut () -> (*, *, *, "maybe content exhausted, call service!") | HeapOverflow () -> (*, *, *, "error: heap limit exceeded") | StackOverflow () -> (*, *, *, "error: stack limit exceeded") incrementCredit coin v = case coin of Nickel -> v + 5 Dime -> v + 10 Fake -> raise EFakeCoin (v, "coin rejected") ; vend drink cost v = if v >= cost then ( serve drink, v - cost, *, "your drink") else ( *, v, *, "money is short of " ++ show (cost - v)) ; serve drink = case drink of Coffee -> "Coffee\n" Tea -> "Tea\n" ; box control in (c :: char) out (coin :: Coins, button:: Buttons) match 'n' -> (Nickel, *) | 'd' -> (Dime, *) | 'f' -> (Fake, *) | 'c' -> (*, BCoffee) | 't' -> (*, BTea) | 'x' -> (*, BCancel) | _ -> (*, *) stream console_outp to "std_out" ; stream console_inp from "std_in" ; -- dataflow wire coffee -- inputs (channel origins) (control.coin, control.button, coffee.value’ initially 0) -- -- outputs destinations (console_outp, coffee.value, console_outp, console_outp) wire control (console_inp) (coffee.coin, coffee.button)
Text derived from https://en.wikipedia.org/w/index.php?oldid=1334974481 under CC BY-SA 4.0; modifications have been made.