3An alternative Ord implementation for Nats, with an explicit name "myord"
6> implementation [myord] Ord Nat where
11The @{name} syntax below gives an explicit dictionary for the compare function.
12Here, we're telling it to use the "myord" dictionary. Otherwise, it'd just
13use the default (unnamed) implementation. Note that there can only be one unnamed
14implementation --- they must not overlap.
16> compare (S x) (S y) = compare @{myord} x y
19> foo = [1,4,2,8,3,7,5,6]
21Sort foo using the default comparison operator:
26-- which gives [1,2,3,4,5,6,7,8]
28Sort foo using the alternative implementation. No need for 'sortBy' and other
29such functions. Hoorah!
32> test2 = sort @{myord} foo
34-- which gives [8,7,6,5,4,3,2,1]
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list