Source code on Github
{-# OPTIONS --safe #-}
module Prelude.Ord.Instances where

import Relation.Binary.Construct.On as On
import Data.List.Relation.Binary.Lex.Strict as StrictLex

open import Prelude.Init; open SetAsType
open import Prelude.General
open import Prelude.Decidable
open import Prelude.DecEq.Core

open import Prelude.Irrelevance.Nat
open import Prelude.Irrelevance.Int

open import Prelude.Ord.Core
open import Prelude.Ord.Dec
open import Prelude.Ord.Irrelevant

instance
  Ord-ℕ : Ord 
  Ord-ℕ = record {Nat}

  Dec-≤ℕ : Nat._≤_ ⁇²
  Dec-≤ℕ .dec = _ Nat.≤? _

  DecOrd-ℕ : DecOrd 
  DecOrd-ℕ = record {}

  OrdLaws-ℕ : OrdLaws 
  OrdLaws-ℕ = record {Nat; ≤∧≢⇒< = uncurry Nat.≤∧≢⇒<}

  ·Ord-ℕ : ·Ord 
  ·Ord-ℕ = mk·Ord

  Ord⁺⁺-ℕ : Ord⁺⁺ 
  Ord⁺⁺-ℕ = mkOrd⁺⁺

  Ord-ℤ = Ord   record {Integer}

  Dec-≤ℤ : Integer._≤_ ⁇²
  Dec-≤ℤ .dec = _ Integer.≤? _

  Dec-<ℤ : Integer._<_ ⁇²
  Dec-<ℤ .dec = _ Integer.<? _

  DecOrd-ℤ : DecOrd 
  DecOrd-ℤ = record {}

  OrdLaws-ℤ : OrdLaws 
  OrdLaws-ℤ = record
    { Integer
    ; ≤∧≢⇒< = uncurry Integer.≤∧≢⇒<
    ; <-resp₂-≡ = subst (_ Integer.<_) , subst (Integer._< _)
    }

  ·Ord-ℤ : ·Ord 
  ·Ord-ℤ = mk·Ord

  Ord⁺⁺-ℤ : Ord⁺⁺ 
  Ord⁺⁺-ℤ = mkOrd⁺⁺

  Ord-Char = Ord Char  record {Ch}

  Dec-≤Char : Ch._≤_ ⁇²
  Dec-≤Char .dec = _ Ch.≤? _

  DecOrd-Char : DecOrd Char
  DecOrd-Char = record {}

  Ord-String = Ord String  record {Str}

  Dec-<String : Str._<_ ⁇²
  Dec-<String {x}{y} .dec = x Str.<? y

  Dec-≤String : Str._≤_ ⁇²
  Dec-≤String {x}{y} .dec = On.decidable _ _ (StrictLex.≤-decidable _≟_ Ch._<?_) x y

  DecOrd-String : DecOrd String
  DecOrd-String = λ where
    .Dec-≤ {x}{y}  Dec-≤String {x}{y}
    .Dec-< {x}{y}  Dec-<String {x}{y}