I'm trying to get the max element of a Data.List
:
listMax : max ℕ (2 ∷ 1 ∷ []) ≟ 2
listMax = ?
but don't understand why I'm getting this error:
Set !=< (Relation.Binary.Bundles.TotalOrder _b_20 _ℓ₁_21 _ℓ₂_22)
when checking that the expression ℕ has type
Relation.Binary.Bundles.TotalOrder _b_20 _ℓ₁_21 _ℓ₂_22
I'm guessing that ℕ should instead be something of type
Relation.Binary.Bundles.TotalOrder _b_20 _ℓ₁_21 _ℓ₂_22
but I don't know how to get something of that type and why is it needed to get the max element.
EDIT
Looking at the signature for max
in Data.List.Extrema
I see:
max : B → List B → B
and I see that B is defined here
open TotalOrder totalOrder renaming (Carrier to B)
I'm not sure why ℕ can't be a Carrier.
I also found in Data.Fin.Properties
:
≤-totalOrder : ℕ → TotalOrder _ _ _
and tried
listMax : {n : ℕ} → max (≤-totalOrder n) (2 l.∷ 1 l.∷ l.[]) ≡ 2
but am now getting this error:
List _A_27 !=< Fin n
when checking that the inferred type of an application
List _A_27
matches the expected type
Relation.Binary.Bundles.TotalOrder.Carrier (≤-totalOrder n)
Thanks!