[Haskell-beginners] numerical types, the $ operator

Brent Yorgey byorgey at seas.upenn.edu
Sat Mar 28 18:39:29 EDT 2009

On Sat, Mar 28, 2009 at 05:53:54PM -0400, John Dorsey wrote:
> > > How would an experienced guy write this without parentheses?
> > 
> > I'm fairly certain it's impossible to write it without using
> > parentheses.  I would probably just write
> > 
> >   x - fromInteger (floor x)
> Never impossible!
> flip subtract x . fromInteger $ floor x
> case floor x of y -> x - fromInteger y
> let y = floor x in x - fromInteger y

Hah, you fell right into my trap!  ;)

Well, I actually hadn't thought of these, but I figured someone would find a way to do it.

> I guess I wouldn't choose any of these for readability, though.  Brent's
> version is succinct.

Right, the point being, parentheses are not something to be avoided at
all costs.  They should be used as much as necessary to aid
readability, no more, no less.


More information about the Beginners mailing list