Skip to content
Draft
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions src/Effect/Monad/Partial.agda
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
module Effect.Monad.Partial where

open import Level

open import Data.Product
open import Data.Empty
open import Data.Unit

-- The type of partial elements
record ↯ {ℓ} (A : Set ℓ) (ℓ' : Level) : Set (ℓ ⊔ suc ℓ') where
Comment thread
JacquesCarette marked this conversation as resolved.
Outdated
field
Dom : Set ℓ'
Comment thread
JacquesCarette marked this conversation as resolved.
Outdated
elt : Dom → A
Comment thread
e-mniang marked this conversation as resolved.

open ↯

private variable
ℓ ℓ' : Level
A B : Set ℓ


--
never : ↯ A zero
never .Dom = ⊥
never .elt = ⊥-elim
Comment thread
e-mniang marked this conversation as resolved.

always : A → ↯ A zero
always a .Dom = ⊤
always a .elt _ = a
Comment thread
e-mniang marked this conversation as 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
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool.
What's the unicode name for the down-lightning-bolt symbol, given that this is going to be in frequent use, if deployed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is the unicode : U+21AF

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an Emacs agda-input-mode version?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes (sorry for the delay), it's \dz.



Comment thread
e-mniang marked this conversation as resolved.