
On Saturday, April 16, 2016 at 10:10:37 PM UTC+2, Roman Cheplyaka wrote:
On 04/16/2016 10:22 PM, Alexey Muranov wrote:
Could you show me, please, how to use scoped type variables to avoid MR in this example?
All MR does is it prevents a binding from being generalized. Another way to achieve that would be to give that binding a (monomorphic) type signature. Without scoped t.v., you can't give a signature to 'len' while keeping 'f' polymorphic in the return type. With scoped t.v., you can:
f :: forall a b . Num a => [b] -> (a,a) f xs = (len, len) where len :: a len = genericLength xs
Great, thanks for the explanation (i'll think about it). If i have understood correctly, having scoped type variables, MR is no longer needed at all then. Alexey.