On Tue, Mar 27, 2012 at 8:16 PM, Boyko Bantchev <boyk...@gmail.com> wrote: >> In essence the Haskell definition of "Functor" is meaningless until we >> nail down the definition of "Composition". >> Of course, if we are working in Haskell, it comes with an >> implementation and, thus, a definition for composition. > > The definition of composition in Haskell comes with the definition > (not an implementation) of the language, and that definition is the > one of mathematics (the same is in ML and other languages): > > (f∘g)(x) ≡ f(g(x))
Definitions do not eliminate ambiguity. One issue, here, is that the definitions of f, g and x are contextual. A variant on this issue is that in the realm of general mathematics, a function that maps from A to B can also map from C to D. And, A and C might have a non-empty intersection and yet not have a subset relationship between them and composition might be valid for A and not C. And, this contextual distinction is relevant in the context of discussions involving J. All of these J phrases can be used to represent composition between functions represented by f and g, if f and g are verbs: f@g f@:g f&g f&:g ([: f g) f(g(x)) If f and/or g represent functions but are not verbs, then [typically] different phrases must be used. Note also that that last phrase represents composition if x is a noun. It might also represent composition if x was an appropriate adverb (for example: x=:1 :'@u') >> Still, for the examples here, I imagine we could define an operation >> on some of the structures here which we could think of as a >> composition operator. > > The domain of a composition operator are functions themselves, > not the data structures that are domains of those functions. > A 'composition' that has to do with data structures is anything > else but composition of functions. You seem to be saying that context is irrelevant. If so, I am not sure why I should agree with this statement. >> Or, we could think of some of J's conjunctions (especially >> @ @: & and &:) as being compositions. Hooks and forks might >> also be thought of as compositions. > > Speaking informally, we really call all these and other J constructs > 'compositions', but this is irrelevant here. The structure > preservation rule > > fmap (f ∘ g) ≡ (fmap f) ∘ (fmap g) > > refers to the usual notion of composition in mathematics, and there > is a reason for that. We cannot arbitrarily pick up any operation > in its place just because we like to call it a composition. I am not picking arbitrary operations. >> Haskell, on the other hand, is a compiler ... > > It is a language, and its definition does not prescribe a specific > kind of language processor. And certainly there are interpreters. Nevertheless, some operations can be performed in the compilers which fail in the interpreters. And, some operations can be performed efficiently in compiled haskell and are inefficient in interpreted haskell. -- Raul ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm