# Define and use an abstract boolean type. # This is from scratch, without benefit of the builtin Boolean type. ( # The packaged abstract type: ( # Specify the concrete type that represents B. @(|True|True|)<:x <+ # Define the public members of the type. (&(|a|_|<+()$a) # false &(|_|a|<+()$a) # true &(\x->\y->(ret<+x$[|[->x$ret]|[->y$ret]|])) # and &(\x->\y->(ret<+x$[|[->y$ret]|[->x$ret]|])) # or &(\x->(ret<+x$[|[->"false"$ret]|[->"true"$ret]|])) # show &) $x # The existential type of the package: :some B.( &B # false &B # true &(B->(B->B)) # and &(B->(B->B)) # or &(B->String) # show & ) ) (\pkg-> # Name the package. ( ret <+pkg $ [ # Give the name Bool to the abstract type. @Bool # Name the public members of the abstraction. <:[ &false&true&and&or&show& -> { # The demonstration: (false show) put; put_newline; ((false false or) show) put; put_newline; ((false true or) show) put; put_newline; ((true false or) show) put; put_newline; ((true true or) show) put; put_newline; ((false false and) show) put; put_newline; ((false true and) show) put; put_newline; ((true false and) show) put; put_newline; ((true true and) show) put; put_newline } $ ret ] ] ) ) )