module Prelude.Anyable where

open import Prelude.Init
open import Prelude.LiteralSequences

record Anyable (F : Type   Type ) : Type (lsuc ) where
  field Any :  {A}  (A  Type)  F A  Type 

  ∃∈-syntax  = Any
  ∃∈-syntax′ = Any
  ∄∈-syntax  = λ {A} P  ¬_  Any {A} P
  ∄∈-syntax′ = ∄∈-syntax
  infix 2 ∃∈-syntax ∃∈-syntax′ ∄∈-syntax ∄∈-syntax′
  syntax ∃∈-syntax  P         xs = ∃[∈    xs ] P
  syntax ∃∈-syntax′  x  P) xs = ∃[ x  xs ] P
  syntax ∄∈-syntax  P         xs = ∄[∈    xs ] P
  syntax ∄∈-syntax′  x  P) xs = ∄[ x  xs ] P

open Anyable ⦃...⦄ public

instance
  Anyable-List : Anyable {} List
  Anyable-List .Any = L.Any.Any

  Anyable-Vec :  {n}  Anyable {} (flip Vec n)
  Anyable-Vec .Any P = V.Any.Any P

  Anyable-Maybe : Anyable {} Maybe
  Anyable-Maybe .Any = M.Any.Any

private
  open import Prelude.Decidable

  _ : ∃[ x  List   [ 1   2  3 ] ] (x > 0)
  _ = auto

  _ : ∃[ x  just 42 ] (x > 0)
  _ = auto

  _ : ∄[ x  nothing ] (x > 0)
  _ = auto