简体   繁体   中英

Is tacit programming possible in Purescript?

隐性编程是否也称为无点样式,例如http://en.wikipedia.org/wiki/Tacit_programming Purescript中的一个选项?

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM