SummarySmall example programs and tech demos that I have written in the Ur/Web programming language.
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.
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.
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.
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.
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).
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...
Ideally, these demos should…
- Run on all major browsers: Firefox, Opera, Chrome, Safari and Internet Explorer.
- Compile and run on Ur/Web version 20120807, or newer. Old versions of Ur/Web must use older revisions from this repository, where appropriate.
If either of these statements are untrue, then please contact me.
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).
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!