On Sat, Apr 9, 2011 at 6:38 AM, Viktor Cerovski <[email protected]> wrote: > I don't understand why this thread moved from Programming > to Chat. Anyhow...
This thread has never been in Programming, I started it in Chat because it was about non-J subject matter. > Yes, and all I was saying is since the Haskell is statically typed, > we must consider type signatures, which is an interesting exercise > even or especially if we consider run-time typing. Let's take your > type signature for insert > > insert :: (Array -> Array -> Array) -> Array -> Array > > [technical point: concrete type names in Haskell should > be capitalized, or else array would have had the same > meaning as a] Ok, I had not realized that. > and ask how can we model Array ? Well, it should be at least > a union of J scalars and arrays, ie: > > type Array = Jscalar | Jarray No, I disagree here. A J scalar is a J array with rank 0, so this does not make sense to me. If I modeled a J array in haskell, it would need: A list of dimensions (each dimension would be a non-negative integer) A list of implementation types List of data elements corresponding to each implementation type (one of which would be the same length as the product of the dimensions and the remainder of which would all be empty). > This is not related to the beginning of the insertion > because the inserted verb could produce results of varying > ranks at any or all points during the execution of u/y. But we do not need to treat differing ranks as differing Haskell types if we do not want to do so. > Can we at least say that the left argument of u will always > have the same type, namely that of item of y? > I think that's true, but not necessarily a nice feature of J. Certainly. > Consider for instance u/&.:> > This could have been a full-fledged reduce like in LISP, > had there not been the automatic fill that happens the moment > argument gets unboxed [I talk about reduce from LISP rather > than foldr from Haskell just because the analogy with the > former can be pushed further in the case of J due to the > dynamic typing]. Well.. that is pretty much the point of boxes. Only boxed items correspond to an element of a LISP list. -- Raul ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
