-
Notifications
You must be signed in to change notification settings - Fork 257
[add] partial elements in Effect.Monad.Partial module #2796
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
6709434
8cdf3e1
55a34ee
c9c4dbe
ddbe901
52760d9
802df52
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
------------------------------------------------------------------------ | ||
-- The Agda standard library | ||
-- | ||
-- The partial monad | ||
------------------------------------------------------------------------ | ||
|
||
{-# OPTIONS --cubical-compatible --safe #-} | ||
|
||
module Effect.Monad.Partial where | ||
|
||
open import Level using (Level; suc; zero;_⊔_) | ||
open import Data.Product using (_×_; Σ; Σ-syntax; _,_) | ||
open import Data.Empty using (⊥-elim; ⊥) | ||
open import Data.Unit using (⊤) | ||
|
||
private | ||
variable | ||
a ℓ ℓ' : Level | ||
A B : Set a | ||
|
||
------------------------------------------------------------------------ | ||
-- The partial monad | ||
|
||
record ↯ (A : Set a) (ℓ : Level) : Set (a ⊔ suc ℓ) where | ||
field | ||
Dom : Set ℓ | ||
elt : Dom → A | ||
e-mniang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
open ↯ | ||
|
||
never : ↯ A zero | ||
never .Dom = ⊥ | ||
never .elt = ⊥-elim | ||
e-mniang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
always : A → ↯ A zero | ||
always a .Dom = ⊤ | ||
always a .elt _ = a | ||
e-mniang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
↯-bind : ↯ A ℓ → (A → ↯ B ℓ') → ↯ B (ℓ ⊔ ℓ') | ||
↯-bind a↯ f .Dom = Σ[ a↓ ∈ a↯ .Dom ] f (a↯ .elt a↓) .Dom | ||
↯-bind a↯ f .elt (a↓ , fa↓) = f (a↯ .elt a↓) .elt fa↓ | ||
|
||
↯-map : (A → B) → ↯ A ℓ → ↯ B ℓ | ||
↯-map f a↯ .Dom = a↯ .Dom | ||
↯-map f a↯ .elt d = f (a↯ .elt d) | ||
|
||
↯-ap : ↯ (A → B) ℓ → ↯ A ℓ' → ↯ B (ℓ ⊔ ℓ') | ||
↯-ap a→b↯ a↯ .Dom = a→b↯ .Dom × a↯ .Dom | ||
↯-ap a→b↯ a↯ .elt (f↓ , a↓) = a→b↯ .elt f↓ (a↯ .elt a↓) | ||
Comment on lines
+39
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here is the unicode : U+21AF There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there an Emacs There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes (sorry for the delay), it's \dz. |
||
|
||
|
||
e-mniang marked this conversation as resolved.
Show resolved
Hide resolved
|
Uh oh!
There was an error while loading. Please reload this page.