Catamorphism in Scala

4
Daniel Spiewak @djspiewak

@debasishg @crstry @mergeconflict @jsuereth @nuttycom @dibblego The smart constructor just a constructor that returns the ADT type

2012-09-24 00:29:40
mergeconflict @mergeconflict

@djspiewak Curious why pattern matching is cheaper. Isn't it compiled to chain of PartialFunction orElse? /cc @debasishg @crstry @jsuereth

2012-09-24 00:30:29
Daniel Spiewak @djspiewak

@mergeconflict @debasishg @crstry @jsuereth Absolutely not! That would be horrifying. Pattern matching is compiled to jumps.

2012-09-24 00:30:49
Daniel Spiewak @djspiewak

@mergeconflict @debasishg @crstry @jsuereth It is similar to switch/case compilation, but O(n) instead of O(1).

2012-09-24 00:31:03
mergeconflict @mergeconflict

@debasishg Ok, so: why would one ever prefer fold? Ignoring performance, seems patmat is more flexible and readable anyway. /cc djspiewak

2012-09-24 01:01:28
Debasish (দেবাশিস্) Ghosh 🇮🇳 @debasishg

@mergeconflict 1. Laziness, u can't have by name params in case classes. Second reason is better type inf as w/ smart constructors in scalaz

2012-09-24 01:04:13
Daniel Spiewak @djspiewak

@techtangents @debasishg It is Church encoding, but that carries other connotations.

2012-09-24 05:47:49
Tony Morris @dibblego

@djspiewak @debasishg @crstry @mergeconflict @jsuereth @nuttycom smart constructor is a lot more than that, but I am lost in this discussion

2012-09-24 06:14:50