Martin Escardo and Paulo Oliva, 20th August 2024.

Affine relative monad of non-empty lists without repetitions, assume a
discrete type (a type with decidable equality).

\begin{code}

{-# OPTIONS --safe --without-K #-}

open import Notation.General
open import MLTT.Spartan
open import UF.DiscreteAndSeparated
open import UF.Equiv
open import UF.FunExt
open import RelativeMonadOnStructuredTypes.OneSigmaStructure
open import RelativeMonadOnStructuredTypes.Definition {{discrete-πŸ™-Ξ£-structure}}

module RelativeMonadOnStructuredTypes.NELWR
        (fe : Fun-Ext)
       where

open import DiscreteGraphicMonoids.AffineMonad fe

open πŸ™-Ξ£-structure discrete-πŸ™-Ξ£-structure

instance
 π•Š-is-discrete' : {𝓀 : Universe} {𝓧 : π•Š 𝓀} β†’ is-discrete' ⟨ 𝓧 ⟩
 π•Š-is-discrete' {𝓀} {𝓧} = discrete-gives-discrete' (underlying-structure 𝓧)

NELWR : Relative-Monad {Ξ» 𝓀 β†’ 𝓀}
NELWR =
 record {
    functor = Ξ» 𝓧 β†’ List⁻⁺ ⟨ 𝓧 ⟩
  ; Ξ· = Ξ» {𝓀} {𝓧} β†’ η⁻⁺ {𝓀} {⟨ 𝓧 ⟩}
  ; ext = Ξ» {𝓀} {π“₯} {𝓧} {𝓨} β†’ ext⁻⁺ {𝓀} {π“₯} {⟨ 𝓧 ⟩} {⟨ 𝓨 ⟩}
  ; ext-Ξ· = Ξ» {𝓀} {𝓧} β†’ ext-η⁻⁺ {𝓀} {⟨ 𝓧 ⟩} {{π•Š-is-discrete' {𝓀} {𝓧}}}
  ; unit = Ξ» {𝓀} {π“₯} {𝓧} {𝓨}
             β†’ unit⁻⁺ {𝓀} {π“₯} {⟨ 𝓧 ⟩} {{π•Š-is-discrete' {𝓀} {𝓧}}} {⟨ 𝓨 ⟩}
  ; assoc = Ξ» {𝓀} {π“₯} {𝓦} {𝓧} {𝓨} {𝓩}
             β†’ assoc⁻⁺ {𝓀} {π“₯} {𝓦} {⟨ 𝓧 ⟩} {⟨ 𝓨 ⟩} {⟨ 𝓩 ⟩}
  }

NELWR-is-affine : is-affine NELWR
NELWR-is-affine = affine⁻⁺

\end{code}