[Haskell-cafe] Alternative name for return

Andreas Abel andreas.abel at ifi.lmu.de
Tue Aug 13 17:38:45 CEST 2013


On 06.08.2013 10:46, Adam Gundry wrote:
> On 06/08/13 06:14, J. Stutterheim wrote:
>> Suppose we now have the opportunity to change the name of the
>> `return` function in Monad, what would be a "better"  name for it?
>> (for some definition of better)
>
> Rather than proposing a different name, I'm going to challenge the
> premise of your question. Perhaps it would be better if `return` had no
> name at all. Consider the following:
>
>      return f `ap` s `ap` t
>
>      f <$> s <*> t
>
>      do { sv <- s
>         ; tv <- t
>         ; return (f sv tv) }

Indeed, I wished the 0-ary case would be more alike to the unary and 
binary case, cf.

   return f0
   f1 <$> a1
   f2 <$> a1 <*> a2

What is needed is a nice syntax for "idiom brackets".

> These are all different ways of spelling
>
>      f s t
>
> plus the necessary applicative or monadic bureaucracy. But why couldn't
> we write just the plain application, and let the type system deal with
> the plumbing of effects?

I would not think this is practically possible.  For instance, if

   f :: a -> b -> c

then it could be a binary function or a unary function in the context 
monad reading from a, thus, application

   f x

is ambiguous or too sensitive, especially with type inference.

> I realise that this may be too open a research area for your project...


-- 
Andreas Abel  <><      Du bist der geliebte Mensch.

Theoretical Computer Science, University of Munich
Oettingenstr. 67, D-80538 Munich, GERMANY

andreas.abel at ifi.lmu.de
http://www2.tcs.ifi.lmu.de/~abel/




More information about the Haskell-Cafe mailing list