[Haskell-cafe] Function application layout
Alexander Solla
alex.solla at gmail.com
Thu May 26 01:27:39 CEST 2011
2011/5/25 Jonas Almström Duregård <jonas.duregard at chalmers.se>
> Hi Alexander,
>
>
> > This is "exactly" the applicative style, where idiom brackets come from.
>
> I disagree. Layout has at least two advantages over applicative here:
>
> 1) Applicative costs (at least) three additional characters per function
> parameter.
>
I don't think so. Presumably, you would replace them with spaces, if you
were indenting to "tabular" form.
> 2) You can not have arbitrary infix operators in the parameters when using
> applicative.
True.
>
> Also your example is not really equivalent to f (x a) (y b) (z c) is it?
It is up to isomorphism, if you use the identity functor:
newtype Id a = Id { unId :: a }
tryItOut :: Id Int
tryItOut = (+) <$> 1 <*> 2
>
>
> > Idiom brackets abstract the <$> (fmap) and (<*>) operators away.
>
> But from what I can tell it also reintroduces the parenthesis? How would
> you write f (x a) (y b) in idiom brackets?
>
I prefer the applicative style, so I would use that.
>
> /J
>
>
> On 25 May 2011 22:06, Alexander Solla <alex.solla at gmail.com> wrote:
> >
> >
> > 2011/5/25 Jonas Almström Duregård <jonas.duregard at chalmers.se>
> >>
> >> I don't see the similarity (from reading this:
> >> http://www.haskell.org/haskellwiki/Idiom_brackets). My suggestion is
> >> just a way of using layout to avoid parenthesis.
> >>
> >
> > This is "exactly" the applicative style, where idiom brackets come from.
> > Use Control.Applicative:
> > f <$> x a
> > <*> y b
> > <*> z c
> > You can use the identity functor to recover "plain old" function
> > application. Idiom brackets abstract the <$> (fmap) and (<*>) operators
> > away.
> > And yes, you are right that applicative style is very useful.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110525/2d6e3404/attachment-0001.htm>
More information about the Haskell-Cafe
mailing list