On Mon, Jan 5, 2009 at 3:16 PM, Brandon S. Allbery KF8NH
<[email protected]> wrote:
> On 2009 Jan 5, at 13:57, David Menendez wrote:
>>
>> 2009/1/5 Ross Mellgren <[email protected]>:
>>>
>>> If for some reason you absolutely need to avoid parentheses (mostly as a
>>> thought exercise, I guess), you'd have to have a flipped version of
>>> intercalate:
>>
>> Or a version of ($) that associates differently.
>>
>> infixl 0 $$
>>
>> f $$ x = f x
>>
>> *Main Data.ByteString> :t \x y z -> intercalate $$ intercalate x y $$ z
>> \x y z -> intercalate $$ intercalate x y $$ z :: ByteString
>> -> [ByteString]
>> -> [ByteString]
>> -> ByteString
>
>
> ...at which point we're reinventing Applicative, no?
Is "const" a reinvention of "return"?
You could write the above code with (<*>), but you'd need to convert
back and forth from Identity in order to get the proper Applicative
instance.
runIdentity $ Identity B.intercalate <*> Identity (B.intercalate x
y) <*> Identity z
At that point, you might as well save the noise and write,
B.intercalate (B.intercalate x y) z
--
Dave Menendez <[email protected]>
<http://www.eyrie.org/~zednenem/>
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe