v217
v217

Reputation: 805

Is tacit programming possible in Purescript?

Is tacit programming also known as point-free style see e.g. http://en.wikipedia.org/wiki/Tacit_programming an option in Purescript?

Upvotes: 4

Views: 213

Answers (1)

stholzm
stholzm

Reputation: 3455

Looking at the PureScript Prelude source, I'd say so:

instance functorFn :: Functor ((->) r) where
  map = compose  -- point-free!

Your example in http://try.purescript.org/?session=3538ae1c-eece-8f50-ad0c-e1504846a793:

foldr f z Nil = z
foldr f z (x:xs) = f x (subfold xs)
  where subfold = foldr f z

sum = foldr (+) 0

main = trace $ show $ sum (1:2:3:4:Nil)  -- prints: 10

(needed to define foldr myself because I could not import any modules)

Upvotes: 4

Related Questions