Project

General

Profile

Actions

Feature #56

open

More dot operators

Feature #56: More dot operators

Added by SpiceGuid - over 17 years ago. Updated over 17 years ago.

Status:
New
Priority:
Low
Assignee:
-
Category:
Libraries
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Platform:
Resolution:
Triage Stage:

Description

I am enamoured with the Anubis overloaded dot operator.

I believe the Anubis 'Kleisli applicator' or 'Maybe monad' syntax is the less intrusive one i have ever seen. It encourages a really elegant exceptionless style, so i just beg more in the same vein.

public define $A -> $C
   $B -> $C g.$A -> $B f
     =
   ($A x) |-> g(f(x)).

public define Maybe($U)
   (Maybe($T),Maybe($T)) ab.($T,$T) -> Maybe($U) f
     =
   if ab is (a,b) then 
   if a is 
     {
     failure     then failure, 
     success(a1) then
       if b is 
         {
         failure     then failure, 
         success(b1) then f(a1,b1)
         }
     }.

public define Result($E,$U)
   (Result($E,$T),Result($E,$T)) ab.($T,$T) -> Result($E,$U) f
     =
   if ab is (a,b) then 
   if a is 
     {
     error(e) then error(e), 
     ok(a1)   then
       if b is 
         {
         error(e) then error(e), 
         ok(b1)   then f(a1,b1)
         }
     }.

Updated by SpiceGuid - over 17 years ago Actions #1

I am enamoured with the Anubis overloaded dot operator.

I believe the Anubis 'Kleisli applicator' or 'Maybe monad' syntax is the less intrusive one i have ever seen. It encourages a really elegant exceptionless style, so i just beg more in the same vein.

public define $A -> $C
   $B -> $C g.$A -> $B f
     =
   ($A x) |-> g(f(x)).

public define Maybe($U)
   (Maybe($T),Maybe($T)) ab.($T,$T) -> Maybe($U) f
     =
   if ab is (a,b) then 
   if a is 
     {
     failure     then failure, 
     success(a1) then
       if b is 
         {
         failure     then failure, 
         success(b1) then f(a1,b1)
         }
     }.

public define Result($E,$U)
   (Result($E,$T),Result($E,$T)) ab.($T,$T) -> Result($E,$U) f
     =
   if ab is (a,b) then 
   if a is 
     {
     error(e) then error(e), 
     ok(a1)   then
       if b is 
         {
         error(e) then error(e), 
         ok(b1)   then f(a1,b1)
         }
     }.

Moreover i propose an 'exception catch' fonctionality :

public define ($E -> Result($E,$T)) -> Result($E,$T)
   try_with (Result($E,$T) x) 
     =
   ($E -> Result($E,$T) error_handler) |->
   if x is 
     {
     error(e) then error_handler(e), 
     ok(v)    then x
     }.

Updated by Alain Prouté over 17 years ago Actions #2

  • Assignee deleted (Alain Prouté)
  • Platform deleted (All)
Actions

Also available in: PDF Atom