agda-stdlib icon indicating copy to clipboard operation
agda-stdlib copied to clipboard

Formalize `Prefix`, `Suffix` and `Infix` as relations on Lists

Open gallais opened this issue 7 years ago • 2 comments

Rather than Haskell's

isPrefixOf :: Eq a => [a] -> [a] -> Bool
isSuffixOf :: Eq a => [a] -> [a] -> Bool
isInfixOf :: Eq a => [a] -> [a] -> Bool

it would be nice to have evidence-producing versions of these functions. Note that Data.List.Relation.Sublist already gives us that for isSubsequenceOf.

  • [x] Prefix (#522)
  • [x] Suffix (#551)
  • [ ] Infix

gallais avatar Nov 02 '18 22:11 gallais

Something to think about: Suffix could be generalised to

module _ (R : REL (List A) (List B) r) where

  data Suffix : REL (List A) (List B) (a ⊔ b ⊔ r) where
    here  : ∀ {as bs} → R as bs → Suffix as bs
    there : ∀ {b as bs} → Suffix as bs → Suffix as (b ∷ bs)

We then recover the usual suffix as Suffix (Pointwise R) but we can also get Infix as Suffix (Prefix R).

gallais avatar Feb 13 '19 16:02 gallais

Is this issue not already closed by the existing definitions under Data.List.Relation.Binary.*, or is there more to say/do here?

UPDATED: it seems as though Data.List.Relation.Binary.Infix.Homogeneous.Properties is an incomplete stub, but that Data.List.Relation.Binary.Infix.Heterogeneous{.Properties} is all there, so... leave this open? Or close?

jamesmckinna avatar May 11 '24 11:05 jamesmckinna

I think close. If people want to open an issue for extending the Infix stub then they can...

MatthewDaggitt avatar May 15 '24 06:05 MatthewDaggitt