Last active
March 22, 2019 20:15
-
-
Save L-TChen/82e225a4cf1c87aa9b7cd39d57d992c9 to your computer and use it in GitHub Desktop.
Some experiments with --prop and instance arguments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# OPTIONS --safe --prop --overlapping-instances #-} | |
module Playground where | |
open import Data.Nat | |
open import Data.List | |
open import Data.Bool | |
open import Data.Empty | |
open import Data.Unit | |
it : {A : Set} ⦃ _ : A ⦄ → A | |
it ⦃ x ⦄ = x | |
it′ : {A : Prop} ⦃ _ : A ⦄ → A | |
it′ ⦃ x ⦄ = x | |
infix 4 _∈₁_ | |
data _∈₁_ {A : Set} (x : A) : List A → Set where | |
instance | |
here : ∀ {xs} → x ∈₁ x ∷ xs | |
there : ∀ {y xs} ⦃ _ : x ∈₁ xs ⦄ → x ∈₁ y ∷ xs | |
data ∥_∥ (A : Set) : Prop where | |
∣_∣ : (x : A) → ∥ A ∥ | |
instance | |
pf : {A : Set} {x : A} → ∥ A ∥ | |
pf {A} {x} = ∣ x ∣ | |
module Membership {A : Set} (_==_ : A → A → Bool) where | |
_∈₂_ : A → List A → Prop | |
a ∈₂ [] = ∥ ⊥ ∥ | |
a ∈₂ (x ∷ xs) with a == x | |
... | true = ∥ ⊤ ∥ | |
... | false = a ∈₂ xs | |
infix 4 _∈₂_ | |
open Membership _≡ᵇ_ | |
_ : 1 ∈₂ (2 ∷ 1 ∷ []) | |
_ = it′ | |
_ : ∥ 1 ∈₁ (2 ∷ 1 ∷ []) ∥ | |
_ = ∣ it ∣ -- this requires --overlapping-instances | |
_ : ∥ 1 ∈₁ 2 ∷ 1 ∷ [] ∥ | |
_ = it′ ⦃ ∣ it ∣ ⦄ | |
_ : ∥ 1 ∈₁ 2 ∷ 1 ∷ [] ∥ | |
_ = it′ -- I hope this could work |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment