2 - Copyright (C) 2009-2010 Nick Bowler.
4 - License BSD2: 2-clause BSD license. See LICENSE for full terms.
5 - This is free software: you are free to change and redistribute it.
6 - There is NO WARRANTY, to the extent permitted by law.
9 -- | 'Poset' and 'Sortable' instances for instances of 'Prelude.Ord'
11 module Data
.Poset
.Instances
where
13 import qualified Data
.Poset
.Internal
as Poset
14 import Data
.Poset
.Internal
(Poset
, Sortable
, partialOrder
, totalOrder
)
21 #define POSET_ORD_INSTANCE
(ctx
, v
) instance ctx Poset
(v
) where { \
22 compare = (partialOrder
.) . compare; \
27 (<==>) = const $ const True; \
28 (</=>) = const $ const False }
30 #define SORTABLE_ORD_INSTANCE
(ctx
, v
) instance ctx Sortable
(v
) where { \
31 isOrdered
= const True; \
32 sortBy f
= sortBy $ (totalOrder
.) . f
; \
36 #define ORD_INSTANCE
(ctx
, v
) \
37 POSET_ORD_INSTANCE
(ctx
, v
); \
38 SORTABLE_ORD_INSTANCE
(ctx
, v
); \
39 instance ctx Poset
.Ord
(v
)
50 ORD_INSTANCE
(, Word16
)
51 ORD_INSTANCE
(, Word32
)
52 ORD_INSTANCE
(, Word64
)
53 ORD_INSTANCE
(, Integer)
55 ORD_INSTANCE
(Integral a
=>, Ratio a
)