aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Cunningham <cc@localhost>2024-07-14 09:53:57 -0700
committerChristian Cunningham <cc@localhost>2024-07-14 09:53:57 -0700
commit3ef5af7cc449d0fe350dc4033ce49071d0abfa87 (patch)
tree46186ce1bebd2b28b207cca105b779489620f0e3
parent14f1270fc7ea6d4bc82ce84ef4896f016ce40289 (diff)
Rename to Maybe Monad
-rw-r--r--monad.inc40
1 files changed, 20 insertions, 20 deletions
diff --git a/monad.inc b/monad.inc
index 18d8552..97c6cd3 100644
--- a/monad.inc
+++ b/monad.inc
@@ -4,9 +4,9 @@
%include "alloc.inc"
%endif
-struc Monad
-just: resq 1
-exist: resb 1
+struc MaybeMonad
+mm_v: resq 1
+mm_e: resb 1
endstruc
%macro m_make 1-3 0,0
@@ -14,9 +14,9 @@ endstruc
;; %2 = Address of Structure
;; %3 = Something > 0, Nothing = 0
m_%1:
- istruc Monad
- at just, dq %2 ; The address of the Monad-wrapped structure
- at exist, db %3 ; Something > 0, Nothing = 0
+ istruc MaybeMonad
+ at mm_v, dq %2 ; The address of the MaybeMonad-wrapped structure
+ at mm_e, db %3 ; Something > 0, Nothing = 0
iend
%endm
@@ -26,14 +26,14 @@ m_%1:
;; %3 = Something > 0, Nothing = 0
%if %2 != 0
lea rax, [rel %2]
- mov qword [%1+just], rax
+ mov qword [%1+mm_v], rax
%else
- mov qword [%1+just], 0
+ mov qword [%1+mm_v], 0
%endif
%if %3 != 0
- mov byte [%1+exist], %3
+ mov byte [%1+mm_e], %3
%else
- mov byte [%1+exist], 0
+ mov byte [%1+mm_e], 0
%endif
lea rax, [%1]
%endm
@@ -48,39 +48,39 @@ m_%1:
%endm
%macro m_bind 1-2 rax
- ;; %1 = Callable Function with Single Argument, the Unwrapped Monad
- ;; %2 = Monad
+ ;; %1 = Callable Function with Single Argument, the Unwrapped MaybeMonad
+ ;; %2 = MaybeMonad
;; m a -> (a -> m b) -> m b
lea rax, [%2]
mov rcx, rax
- mov al, byte [rcx + exist]
+ mov al, byte [rcx + mm_e]
cmp al, 0
je %%exit
- mov rax, [rcx + just]
+ mov rax, [rcx + mm_v]
call %1
%%exit:
%endmacro
%macro m_call 1-2 rax
- ;; %1 = Callable Function with Single Argument, the Unwrapped Monad
- ;; %2 = Monad
+ ;; %1 = Callable Function with Single Argument, the Unwrapped MaybeMonad
+ ;; %2 = MaybeMonad
;; m a -> (a -> !) -> !
lea rax, [%2]
mov rcx, rax
- mov al, byte [rcx + exist]
+ mov al, byte [rcx + mm_e]
cmp al, 0
je %%exit
- mov rax, [rcx + just]
+ mov rax, [rcx + mm_v]
call %1
%%exit:
%endmacro
%macro alloc_m 0
- alloc Monad_size
+ alloc MaybeMonad_size
%endm
%macro free_m 0-1 rax
- free %1, Monad_size
+ free %1, MaybeMonad_size
%endm
%endif