comparison lib/ur/basis.urs @ 720:acb8537f58f0

Stop tracking CSS classes in XML types
author Adam Chlipala <adamc@hcoop.net>
date Sun, 12 Apr 2009 12:31:54 -0400
parents 5c099b1308ae
children 9864b64b1700
comparison
equal deleted inserted replaced
719:5c099b1308ae 720:acb8537f58f0
406 (** XML *) 406 (** XML *)
407 407
408 con css_class :: {Unit} -> Type 408 con css_class :: {Unit} -> Type
409 (* The argument lists categories of properties that this class could set usefully. *) 409 (* The argument lists categories of properties that this class could set usefully. *)
410 410
411 con tag :: {Type} -> {Unit} -> {Unit} -> {Type} -> {Type} -> {Unit} -> Type 411 con tag :: {Type} -> {Unit} -> {Unit} -> {Type} -> {Type} -> Type
412 (* Arguments: 412
413 * 1. Attributes 413
414 * 2. Context for this tag 414 con xml :: {Unit} -> {Type} -> {Type} -> Type
415 * 3. Context for inner XML 415 val cdata : ctx ::: {Unit} -> use ::: {Type} -> string -> xml ctx use []
416 * 4. Form fields used
417 * 5. Form fields defined
418 * 6. CSS property categories that the tag might use
419 *)
420
421 con xml :: {Unit} -> {Type} -> {Type} -> {Unit} -> Type
422 (* Arguments:
423 * 1. Context
424 * 2. Form fields used
425 * 3. Form fields defined
426 * 4. CSS property categories that this XML fragment might use
427 *)
428
429 con css_subset :: {Unit} -> {Unit} -> Type
430 val css_subset : cs1 ::: {Unit} -> cs2 ::: {Unit} -> [cs1 ~ cs2]
431 => css_subset cs1 (cs1 ++ cs2)
432
433 val cdata : ctx ::: {Unit} -> use ::: {Type} -> css ::: {Unit} -> string -> xml ctx use [] css
434 val tag : attrsGiven ::: {Type} -> attrsAbsent ::: {Type} 416 val tag : attrsGiven ::: {Type} -> attrsAbsent ::: {Type}
435 -> ctxOuter ::: {Unit} -> ctxInner ::: {Unit} 417 -> ctxOuter ::: {Unit} -> ctxInner ::: {Unit}
436 -> useOuter ::: {Type} -> useInner ::: {Type} 418 -> useOuter ::: {Type} -> useInner ::: {Type}
437 -> bindOuter ::: {Type} -> bindInner ::: {Type} 419 -> bindOuter ::: {Type} -> bindInner ::: {Type}
438 -> css ::: {Unit} -> cssOuter ::: {Unit} -> cssInner ::: {Unit}
439 -> [attrsGiven ~ attrsAbsent] => 420 -> [attrsGiven ~ attrsAbsent] =>
440 [useOuter ~ useInner] => 421 [useOuter ~ useInner] =>
441 [bindOuter ~ bindInner] => 422 [bindOuter ~ bindInner] =>
442 $attrsGiven 423 $attrsGiven
443 -> tag (attrsGiven ++ attrsAbsent) 424 -> tag (attrsGiven ++ attrsAbsent)
444 ctxOuter ctxInner useOuter bindOuter cssOuter 425 ctxOuter ctxInner useOuter bindOuter
445 -> css_subset cssOuter css 426 -> xml ctxInner useInner bindInner
446 -> css_subset cssInner css 427 -> xml ctxOuter (useOuter ++ useInner) (bindOuter ++ bindInner)
447 -> xml ctxInner useInner bindInner cssInner
448 -> xml ctxOuter (useOuter ++ useInner) (bindOuter ++ bindInner) css
449 val join : ctx ::: {Unit} 428 val join : ctx ::: {Unit}
450 -> use1 ::: {Type} -> bind1 ::: {Type} -> bind2 ::: {Type} 429 -> use1 ::: {Type} -> bind1 ::: {Type} -> bind2 ::: {Type}
451 -> css ::: {Unit} -> css1 ::: {Unit} -> css2 ::: {Unit} 430 -> [use1 ~ bind1] => [bind1 ~ bind2] =>
452 -> [use1 ~ bind1] => [bind1 ~ bind2] 431 xml ctx use1 bind1
453 => xml ctx use1 bind1 css1 432 -> xml ctx (use1 ++ bind1) bind2
454 -> xml ctx (use1 ++ bind1) bind2 css2 433 -> xml ctx use1 (bind1 ++ bind2)
455 -> css_subset css1 css
456 -> css_subset css2 css
457 -> xml ctx use1 (bind1 ++ bind2) css
458 val useMore : ctx ::: {Unit} -> use1 ::: {Type} -> use2 ::: {Type} 434 val useMore : ctx ::: {Unit} -> use1 ::: {Type} -> use2 ::: {Type}
459 -> bind ::: {Type} -> css ::: {Unit} 435 -> bind ::: {Type}
460 -> [use1 ~ use2] => 436 -> [use1 ~ use2] =>
461 xml ctx use1 bind css 437 xml ctx use1 bind
462 -> xml ctx (use1 ++ use2) bind css 438 -> xml ctx (use1 ++ use2) bind
463 439
464 con xhtml = xml [Html] 440 con xhtml = xml [Html]
465 con page = xhtml [] [] 441 con page = xhtml [] []
466 con xbody = xml [Body] [] [] [] 442 con xbody = xml [Body] [] []
467 con xtr = xml [Body, Tr] [] [] [] 443 con xtr = xml [Body, Tr] [] []
468 con xform = xml [Body, Form] [] [] [] 444 con xform = xml [Body, Form] [] []
469 445
470 446
471 (*** HTML details *) 447 (*** HTML details *)
472 448
473 con html = [Html] 449 con html = [Html]
475 con body = [Body] 451 con body = [Body]
476 con form = [Body, Form] 452 con form = [Body, Form]
477 con tabl = [Body, Table] 453 con tabl = [Body, Table]
478 con tr = [Body, Tr] 454 con tr = [Body, Tr]
479 455
480 val dyn : use ::: {Type} -> bind ::: {Type} -> unit -> css ::: {Unit} 456 val dyn : use ::: {Type} -> bind ::: {Type} -> unit
481 -> tag [Signal = signal (xml body use bind css)] body [] use bind css 457 -> tag [Signal = signal (xml body use bind)] body [] use bind
482 458
483 val head : unit -> tag [] html head [] [] [] 459 val head : unit -> tag [] html head [] []
484 val title : unit -> tag [] head [] [] [] [] 460 val title : unit -> tag [] head [] [] []
485 461
486 val body : unit -> tag [Onload = transaction unit] html body [] [] [] 462 val body : unit -> tag [Onload = transaction unit] html body [] []
487 con bodyTag = fn (attrs :: {Type}) => 463 con bodyTag = fn (attrs :: {Type}) =>
488 ctx ::: {Unit} -> 464 ctx ::: {Unit} ->
489 [[Body] ~ ctx] => 465 [[Body] ~ ctx] =>
490 unit -> tag attrs ([Body] ++ ctx) ([Body] ++ ctx) [] [] [] 466 unit -> tag attrs ([Body] ++ ctx) ([Body] ++ ctx) [] []
491 con bodyTagStandalone = fn (attrs :: {Type}) => 467 con bodyTagStandalone = fn (attrs :: {Type}) =>
492 ctx ::: {Unit} 468 ctx ::: {Unit}
493 -> [[Body] ~ ctx] => 469 -> [[Body] ~ ctx] =>
494 unit -> tag attrs ([Body] ++ ctx) [] [] [] [] 470 unit -> tag attrs ([Body] ++ ctx) [] [] []
495 471
496 val br : bodyTagStandalone [] 472 val br : bodyTagStandalone []
497 473
498 val span : bodyTag [] 474 val span : bodyTag []
499 475
514 490
515 val hr : bodyTag [] 491 val hr : bodyTag []
516 492
517 type url 493 type url
518 val bless : string -> url 494 val bless : string -> url
519 val a : css ::: {Unit} -> bodyTag [Link = transaction (page css), Href = url, Onclick = transaction unit] 495 val a : bodyTag [Link = transaction page, Href = url, Onclick = transaction unit]
520 496
521 val img : bodyTag [Src = url] 497 val img : bodyTag [Src = url]
522 498
523 val form : ctx ::: {Unit} -> bind ::: {Type} -> css ::: {Unit} 499 val form : ctx ::: {Unit} -> bind ::: {Type}
524 -> [[Body] ~ ctx] => 500 -> [[Body] ~ ctx] =>
525 xml form [] bind css 501 xml form [] bind
526 -> xml ([Body] ++ ctx) [] [] css 502 -> xml ([Body] ++ ctx) [] []
527 con formTag = fn (ty :: Type) (inner :: {Unit}) (attrs :: {Type}) => 503 con formTag = fn (ty :: Type) (inner :: {Unit}) (attrs :: {Type}) =>
528 ctx ::: {Unit} 504 ctx ::: {Unit}
529 -> [[Form] ~ ctx] => 505 -> [[Form] ~ ctx] =>
530 nm :: Name -> unit 506 nm :: Name -> unit
531 -> tag attrs ([Form] ++ ctx) inner [] [nm = ty] [] 507 -> tag attrs ([Form] ++ ctx) inner [] [nm = ty]
532 val textbox : formTag string [] [Value = string, Size = int, Source = source string] 508 val textbox : formTag string [] [Value = string, Size = int, Source = source string]
533 val password : formTag string [] [Value = string, Size = int] 509 val password : formTag string [] [Value = string, Size = int]
534 val textarea : formTag string [] [Rows = int, Cols = int] 510 val textarea : formTag string [] [Rows = int, Cols = int]
535 511
536 val checkbox : formTag bool [] [Checked = bool] 512 val checkbox : formTag bool [] [Checked = bool]
537 513
538 con radio = [Body, Radio] 514 con radio = [Body, Radio]
539 val radio : formTag string radio [] 515 val radio : formTag string radio []
540 val radioOption : unit -> tag [Value = string] radio [] [] [] [] 516 val radioOption : unit -> tag [Value = string] radio [] [] []
541 517
542 con select = [Select] 518 con select = [Select]
543 val select : formTag string select [] 519 val select : formTag string select []
544 val option : unit -> tag [Value = string, Selected = bool] select [] [] [] [] 520 val option : unit -> tag [Value = string, Selected = bool] select [] [] []
545 521
546 val submit : ctx ::: {Unit} -> use ::: {Type} -> css ::: {Unit} 522 val submit : ctx ::: {Unit} -> use ::: {Type}
547 -> [[Form] ~ ctx] => 523 -> [[Form] ~ ctx] =>
548 unit 524 unit
549 -> tag [Value = string, Action = $use -> transaction (page css)] 525 -> tag [Value = string, Action = $use -> transaction page]
550 ([Form] ++ ctx) ([Form] ++ ctx) use [] [] 526 ([Form] ++ ctx) ([Form] ++ ctx) use []
551 527
552 (*** Tables *)
553
554 val tabl : other ::: {Unit} -> [other ~ [Body, Table]] =>
555 unit -> tag [Border = int] ([Body] ++ other) ([Body, Table] ++ other) [] [] [Table]
556 val tr : other ::: {Unit} -> [other ~ [Body, Table, Tr]] =>
557 unit -> tag [] ([Body, Table] ++ other) ([Body, Tr] ++ other) [] [] []
558 val th : other ::: {Unit} -> [other ~ [Body, Tr]] =>
559 unit -> tag [] ([Body, Tr] ++ other) ([Body] ++ other) [] [] [Cell]
560 val td : other ::: {Unit} -> [other ~ [Body, Tr]] =>
561 unit -> tag [] ([Body, Tr] ++ other) ([Body] ++ other) [] [] [Cell]
562
563 (*** AJAX-oriented widgets *) 528 (*** AJAX-oriented widgets *)
564 529
565 con cformTag = fn (attrs :: {Type}) => 530 con cformTag = fn (attrs :: {Type}) =>
566 ctx ::: {Unit} 531 ctx ::: {Unit}
567 -> [[Body] ~ ctx] => 532 -> [[Body] ~ ctx] =>
568 unit -> tag attrs ([Body] ++ ctx) [] [] [] [] 533 unit -> tag attrs ([Body] ++ ctx) [] [] []
569 534
570 val ctextbox : cformTag [Value = string, Size = int, Source = source string] 535 val ctextbox : cformTag [Value = string, Size = int, Source = source string]
571 val button : cformTag [Value = string, Onclick = transaction unit] 536 val button : cformTag [Value = string, Onclick = transaction unit]
572 537
538 (*** Tables *)
539
540 val tabl : other ::: {Unit} -> [other ~ [Body, Table]] =>
541 unit -> tag [Border = int] ([Body] ++ other) ([Body, Table] ++ other) [] []
542 val tr : other ::: {Unit} -> [other ~ [Body, Table, Tr]] =>
543 unit -> tag [] ([Body, Table] ++ other) ([Body, Tr] ++ other) [] []
544 val th : other ::: {Unit} -> [other ~ [Body, Tr]] =>
545 unit -> tag [] ([Body, Tr] ++ other) ([Body] ++ other) [] []
546 val td : other ::: {Unit} -> [other ~ [Body, Tr]] =>
547 unit -> tag [] ([Body, Tr] ++ other) ([Body] ++ other) [] []
548
573 549
574 (** Aborting *) 550 (** Aborting *)
575 551
576 val error : t ::: Type -> xml [Body] [] [] [] -> t 552 val error : t ::: Type -> xml [Body] [] [] -> t
553
554