Ur/Web Examples
Documentation
Not logged in

Summary

Small example programs and tech demos that I have written in the Ur/Web programming language.

Details

Examples

jsMove/:

A simple interactive tech demo which draws a circle to the screen. It may be moved via keyboard/mouse or touchscreen, depending on the selected URL (main or main_touch). It uses the Ur/Web JavaScript FFI extensively for graphics (Raphaël) and for several additional event handlers.

Note that currently the buttons only work via the keyboard, so modes (click vs drag, etc) typically may not be toggled on the touchscreen version until this issue is fixed.

iota/:

A simple demo of a time-based production function that cycles through a sequence of numbers. It is possible to pause "inhibit" or resume "produce" computation at any time from the user interface.

pseudoRandom/:

A simple demo that generates random numbers using the C FFI, using a time-based seed (delays 10 microseconds at the minimum) to ensure uniqueness.

pseudoRandomIota/:

A simple demo that generates a sequence of random numbers over time. Reuses the time-based production functions from the iota example and the random number generation functions from the pseudoRandom example. A monadic version of periodic (periodicT) must be used, since we are dealing with transactional values.

jsonRpcUI/:

An experimental demo of a JSON RPC client written in Haskell, called on the Ur/Web server side via the C FFI, which in turn communicates with another network service on the server (most likely, running in Haskell). The benefit of this approach is that it is fully compliant with transactional semantics, which I believe is desirable for highly stateful applications (eg. that modify the file system, run long-running shell commands, read/write files, send/receive emails, and so on).

composableSignals/:

Provides lift and map operations for signals, similar to liftA, liftA2, which in Haskell are used to lift functions to applicatives. To be more specific, I noticed that lifting functions were used to compose wires in examples for the FRP library Netwire. The intention of this library is exactly the same. Aside from liftA in Haskell, it provides a similar analog to lift used on a ValueCell in Scala Lift web framework, combineWith in bacon.js, and likely many others, thus giving Ur/Web FRP parity with other systems...

Compatibility

Ideally, these demos should…

If either of these statements are untrue, then please contact me.

Troubleshooting

Note regarding Javascript paths:

The "script" paths noted in the .urp project files must be visible to your host, or should be adjusted to appropriate paths. Since in many cases I refer to locally hosted Javascript files that only exist on my intranet, these values should be changed to public hosted URLs.

Unable to compile or run examples:

If you are unable to get the examples to work for any reason, please contact me, and I will try my best to help you. (Although if I'm busy, I might not respond for a while).

Disclaimer

Although I have written a lot of code (or at least, am very comfortable) in Scheme, Emacs Lisp, Erlang and Prolog of a strongly functional/declarative flavor, I'm not (yet) on the cutting edge of purely functional statically typed programming.

My examples are intended to show how to do specific non-trivial "practical" tasks in Ur/Web, which I use in my larger Ur/Web applications, rather than serve as an example of how to write good Ur/Web code. Although I'm getting better, I'm sure that this code looks horrible to experienced Ur/Web or Haskell Programmers. Comments/critiques are always welcome, especially from experienced Ur/Web or Haskell programmers!

Author

Timothy Beyer: beyert AT SYMBOL fastmail DOT SYMBOL net