Re:“Transducers” by Rich Hickey at Strange Loop [video]
by tel on Saturday September 20, 2014 @02:09PM
(#8345141)
The "kind of" being really pertinent. In particular, this forgoes the guarantee that the only thing the transducer is allowed to do is return a value from the reduction. Hickey notes that this is a law of writing a proper transducer. Higher rank types ensure that this law is properly encoded directly into the system.
That said, I'm pretty sure you know this :)
For example, the following code needs Higher Ranked Types to typecheck:
But it can obviously be written in an untyped language if you wanted to. Just erase all those type annotations: The deal with higher-ranked types is basically a tradeoff between the flexibility of the type system and the power of type inference. If you restrict yourself to rank-1 types (that is, none of your function arguments are polymorphic) then the compiler can infer all all types in the program without you having to write any type signatures. If you want to use higher ranked types then the compiler can't infer everything anymore so you might need to add some type annotations yourself.