annotate tests/stypes.ur @ 1739:c414850f206f

Add support for -boot flag, which allows in-tree execution of Ur/Web The boot flag rewrites most hardcoded paths to point to the build directory, and also forces static compilation. This is convenient for developing Ur/Web, or if you cannot 'sudo make install' Ur/Web. The following changes were made: * Header files were moved to include/urweb instead of include; this lets FFI users point their C_INCLUDE_PATH at this directory at write <urweb/urweb.h>. For internal Ur/Web executables, we simply pass -I$PATH/include/urweb as normal. * Differentiate between LIB and SRCLIB; SRCLIB is Ur and JavaScript source files, while LIB is compiled products from libtool. For in-tree compilation these live in different places. * No longer reference Config for paths; instead use Settings; these settings can be changed dynamically by Compiler.enableBoot () (TODO: add a disableBoot function.) * config.h is now generated directly in include/urweb/config.h, for consistency's sake (especially since it gets installed along with the rest of the headers!) * All of the autotools build products got updated. * The linkStatic field in protocols now only contains the name of the build product, and not the absolute path. Future users have to be careful not to reference the Settings files to early, lest they get an old version (this was the source of two bugs during development of this patch.)
author Edward Z. Yang <ezyang@mit.edu>
date Wed, 02 May 2012 17:17:57 -0400
parents 102e81d975e3
children
rev   line source
adamc@588 1 datatype color = Red | White | Blue
adamc@588 2
adamc@588 3 fun c2s c =
adamc@588 4 case c of
adamc@588 5 Red => "Red"
adamc@588 6 | White => "White"
adamc@588 7 | Blue => "Blue"
adamc@588 8
adamc@588 9 val show_color = mkShow c2s
adamc@588 10
adamc@588 11 datatype list a = Nil | Cons of a * list a
adamc@588 12
adamc@588 13 fun isNil (t ::: Type) (ls : list t) =
adamc@588 14 case ls of
adamc@588 15 Nil => True
adamc@588 16 | _ => False
adamc@588 17
adamc@588 18 fun delist (ls : list string) : xml body [] [] =
adamc@588 19 case ls of
adamc@588 20 Nil => <xml>Nil</xml>
adamc@588 21 | Cons (h, t) => <xml>{[h]} :: {delist t}</xml>
adamc@588 22
adamc@582 23 fun main () : transaction page =
adamc@582 24 sInt <- source 0;
adamc@583 25 sFloat <- source 1.23;
adamc@583 26 sBoth <- source (7, 42.1);
adamc@583 27
adamc@583 28 sOpt <- source None;
adamc@586 29 sBool <- source True;
adamc@583 30
adamc@588 31 sColor <- source White;
adamc@588 32 sList <- source Nil;
adamc@588 33
adamc@582 34 return <xml><body>
adamc@583 35 <dyn signal={n <- signal sInt; return <xml>{[n + 3]}</xml>}/> <a onclick={set sInt 1}>Change</a><br/>
adamc@583 36
adamc@583 37 <dyn signal={n <- signal sFloat; return <xml>{[n + 1.0]}</xml>}/> <a onclick={set sFloat 4.56}>Change</a><br/>
adamc@583 38
adamc@585 39 <dyn signal={p <- signal sBoth; return <xml>{[p.1]}, {[p.2]}</xml>}/>;
adamc@585 40 <dyn signal={p <- signal sBoth; case p of
adamc@585 41 (7, _) => return <xml>Initial</xml>
adamc@585 42 | (fst, snd) => return <xml>{[fst]}, {[snd]}</xml>}/>
adamc@585 43 <a onclick={set sBoth (8, 100.001)}>Change</a><br/>
adamc@584 44
adamc@584 45 <dyn signal={o <- signal sOpt; case o of
adamc@584 46 None => return <xml>None</xml>
adamc@584 47 | Some n => return <xml>{[n]}</xml>}/>
adamc@584 48 <a onclick={set sOpt (Some 7)}>Change</a><br/>
adamc@586 49
adamc@587 50 <dyn signal={b <- signal sBool; return <xml>{[b]}</xml>}/>
adamc@587 51 <dyn signal={b <- signal sBool; if b then return <xml>Yes</xml> else return <xml>No</xml>}/>
adamc@587 52 <a onclick={set sBool False}>Change</a><br/>
adamc@588 53
adamc@588 54 <dyn signal={c <- signal sColor; return <xml>{[c]}</xml>}/>
adamc@588 55 <a onclick={set sColor Red}>Red</a>
adamc@588 56 <a onclick={set sColor White}>White</a>
adamc@588 57 <a onclick={set sColor Blue}>Blue</a><br/>
adamc@588 58
adamc@589 59 <dyn signal={ls <- signal sList; return <xml>{[isNil ls]}</xml>}/>;
adamc@589 60 <dyn signal={ls <- signal sList; return <xml>{delist ls}</xml>}/>
adamc@588 61 <a onclick={set sList (Cons ("A", Cons ("B", Nil)))}>Change</a><br/>
adamc@582 62 </body></xml>