
16 Apr
2016
16 Apr
'16
8:10 p.m.
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 Roman