module Test.Speculate.Utils.Ord
( module Data.Ord
, compareIndex
)
where
import Data.Ord
import Data.List (elemIndex)
compareIndex :: Eq a => [a] -> a -> a -> Ordering
compareIndex :: forall a. Eq a => [a] -> a -> a -> Ordering
compareIndex [a]
xs a
x a
y =
case (a -> [a] -> Maybe Int
forall a. Eq a => a -> [a] -> Maybe Int
elemIndex a
x [a]
xs, a -> [a] -> Maybe Int
forall a. Eq a => a -> [a] -> Maybe Int
elemIndex a
y [a]
xs) of
(Just Int
i, Just Int
j) -> Int
i Int -> Int -> Ordering
forall a. Ord a => a -> a -> Ordering
`compare` Int
j
(Maybe Int
Nothing, Just Int
_) -> Ordering
GT
(Just Int
_, Maybe Int
Nothing) -> Ordering
LT
(Maybe Int, Maybe Int)
_ -> Ordering
EQ