# HG changeset patch # User Adam Chlipala # Date 1224625443 14400 # Node ID de3b03e22447ddec5ece2a595fc472b324df3fce # Parent 345fcf91c80639f59bedcca6dfc688d85737fde5 ListShop prose diff -r 345fcf91c806 -r de3b03e22447 demo/prose --- a/demo/prose Tue Oct 21 17:34:20 2008 -0400 +++ b/demo/prose Tue Oct 21 17:44:03 2008 -0400 @@ -50,4 +50,10 @@ listShop.urp -

This is my other favorite.

+

This example shows off algebraic datatypes, parametric polymorphism, and functors.

+ +

The List module defines a list datatype, much in the style of SML, but with type parameters written more in Haskell style. The types of List.length and List.rev indicate that they are polymorphic. Types like t ::: Type -> ... indicate polymorphism, with the triple colon denoting that the value of this type parameter should be inferred at uses. A double colon would mean that the type argument must be provided explicitly at uses. In contrast to ML and Haskell, all polymorphism must be declared explicitly in Ur, while instantiations may be inferred at uses.

+ +

The ListFun module defines a functor for building list editing sub-applications. An argument to the functor Make must give the type to be stored in the lists, along with marshaling and unmarshaling functions. In return, the functor returns an entry point function.

+ +

The ListShop modules ties everything together by instantiating ListFun.Make with structures for integers and strings. show and read can be used for marshaling and unmarshaling in both cases because they are type-class-generic.