On Sat, Nov 29, 2008 at 8:01 AM, Tracy Harms <[EMAIL PROTECTED]> wrote: > Taking tacit expression as a pure-functional portion of the J > language, how can this solution be effected? For some weeks I've been > trying, unsuccessfully, to envision J equivalents to Haskell's monads > and arrows.
I am not sure that J's type system allows for monads. Haskell's monads are built on streams which, in the Haskell world have the same data type as lists, but a different data type from the elements which make up the lists. In J, elements and lists have the same data types but different shapes. However, J's type system does not support streams (infinities in shapes). (Thus, for example, in J you can not directly define the data structure representing all the results you would get from 1!:1 bind 1 or even from <@(1!:1 bind 1).) If you adopted a sufficiently expressive convention for the representation of streams in J, you could build up monads from there, but this would probably be very inefficient. Also, personally, I find the use of side effects no more distasteful than the use of infinities. (I am not opposed to using infinities, but implementations of infinities are as quirky as implementations of side effects.) That said, if you have a generator (like 1!:1 bind 1 or 1!:1 bind 1 ; ] or some function built up from there), you can easily apply it repeatedly, using recursion or ^: and if you are satisfied with that, you could call any such recursion or repetition a monad. But you do not get the syntactic sugar of Haskell's monads from this. -- Raul ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
