From 963ab32b176228017635e4ef1bb60555c4022142 Mon Sep 17 00:00:00 2001 From: Benjamin Barenblat Date: Sat, 16 Mar 2013 16:08:06 -0400 Subject: Give up on typesafe menu generation and use 'bless' --- main.ur | 37 +++---------------------------------- 1 file changed, 3 insertions(+), 34 deletions(-) (limited to 'main.ur') diff --git a/main.ur b/main.ur index b498861..1d3483b 100644 --- a/main.ur +++ b/main.ur @@ -30,7 +30,7 @@ fun generic (pageName : option string) (content : xbody) : xhtml [] [] = {[titleString]} - + {content} @@ -53,42 +53,11 @@ fun generic (pageName : option string) (content : xbody) : xhtml [] [] = end -(******************************* Page headings *******************************) - -(* Generating nice headings and menus is quite difficult in Ur/Web--there are a -lot of links that the compiler needs to be convinced aren't broken. The link -scheme in this app is based on a variant 'pageName', which describes the name -of the page. There's one value for each page. *) - -con pageName = variant (mapU unit [Main, Forum]) - -(* 'getName' generates the link text given a 'pageName'. *) -fun getName (n : pageName) : xbody = - match n { Main = fn () => Main, - Forum = fn () => Forum } - -(* Now we can do the actual title and menu generation code. *) -fun header (current : pageName) : xbody = - let fun item (target : pageName) (page : unit -> transaction page) = - if Variant.eq current target - then
  • {getName target}
  • - else
  • {getName target}
  • - in - -

    6.947 – Functional Programming Project Laboratory

    -
      - {item (make [#Main] ()) main} - {item (make [#Forum] ()) forum} -
    -
    - end - - (*********************************** Pages ***********************************) and main () = return (generic None - {header (make [#Main] ())} + {Menu.header (make [#Main] ())}

    Like 6.115, 6.947 is a chance to remember why you came to mit: to learn and to build. @@ -101,7 +70,7 @@ and main () = and forum () = forumWorker Forum.main and forumWorker (f : unit -> xbody) = return (generic (Some "Forum") - {header (make [#Forum] ())} + {Menu.header (make [#Forum] ())} {f ()} ) -- cgit v1.2.3