@@ -0,0 +1,36 @@
3+An alternative Ord instance for Nats, with an explicit name "myord"
6+> instance [myord] Ord Nat where
11+The @{name} syntax below gives an explicit dictionary for the compare function.
12+Here, we're telling it to use the "myord" dictionary. Otherwise, it'd just
13+use the default (unnamed) instance. Note that there can only be one unnamed
14+instance --- they must not overlap.
16+> compare (S x) (S y) = compare @{myord} x y
19+> foo = [1,4,2,8,3,7,5,6]
21+Sort foo using the default comparison operator:
26+-- which gives [1,2,3,4,5,6,7,8]
28+Sort foo using the alternative instance. No need for 'sortBy' and other
29+such functions. Hoorah!
32+> test2 = sort @{myord} foo
34+-- which gives [8,7,6,5,4,3,2,1]