In one of my posts I surmised that tacit verb programming
should be an instance of monadic computations, where monadic 
is meant in the Haskell sense of the word.  Since the claim
is that monads are all-pervasive, just not usually seen as
such, it's interesting to recognize which, if any, J programs
could be proved to be (instances of) monadic computations.

To get a gist of the importance of monads, I recall first that
the category theory, and Haskell monads are a particular
kind of category, attempts to provide a general theory of 
processes.  To begin, let us consider the following 
description of four classes of objects in J:

   nouns:        data
   verbs:        processes that do something with data
   conjuctions:  ways to combine processes
   adverbs:      (a) making new processes from processes;
                (b) encoding of data into processes.

How far this analogy can get us, or, more precisely, are 
there any nontrivial instances of monadic computations in J?

Monadic type is generally defined in terms of two operations,
Lift and Bind, which are usually called in Haskell 
return and >>=, respectively.   These two have to satisfy
also the 3 monadic laws in order to become monads.  

I've tried to prove these 3 laws in a J example of taking
Lift to be ("_) and Bind to be @, and found that they do not 
fulfill all three laws (I'll be very happy to provide details 
if there is interest.)

The fruitful part of the endeavor was that, in order for
any combination of verbs and conjunctions to become 
instances of monadic computations, three extensions 
of J parsing rules would suffice:

1)  CONJ ADV VN * --> CONJ (VN ADV) * *

    where VN stands for "verb or noun";

    If I remember correctly, Dan and Jose were also 
    asking for inclusion of this rule or a rule similar to it.

 It would simplify some expressions:

   f@(g/)  ===  f@/g

The second one turned out to be fairly non-trivial---
the simplest form of it I could come up with is:

2)  END ADV CONJ VN1 VN2  -->  END VN1 CONJ VN2 ADV

   where END is either ( or ) or =: or =. or end of stack.

 It's a curiously working rule, e.g:

   / @ f g  ===  f...@g /

 In short, it requires that adverb-conjunction pair be
 able to take its arguments from the right.
 
 An implementation of this rule obviously requires looking
 at the five elements at the stack.  Perhaps less obviously,
 I don't think it is implementable by any choice of the
 four elements rules compatible with the current ones.

3) This extension is pertinent specifically to the
   example of ("_) as Lift and @ or @: as Bind, namely:

   f @ x  ===  f x       f @: x  === f x

where x is a noun, which I think is fairly natural to J,
especially considering the rule 2:)

These extensions are fully backward compatible with 
the current J.  All of these findings do not preclude 
another formulations of Bind and Lift that would satisfy 
monadic laws and be compatible with J as it is now, 
and I'd be very interested to hear of any such results.

More general question, especially interesting if it turns 
out that there are no non-trivial examples of monadic 
processes in J, is whether there is another kind of category 
that does describe computations written in tacit J.

-- 
View this message in context: 
http://old.nabble.com/Monads-and-Categories-in-J-tp27195812s24193p27195812.html
Sent from the J Programming mailing list archive at Nabble.com.

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to