3 ms·
I guess the idea is: data Foo a b c = FooBar a b | FooBaz c or data Foo a b = FooBar a b | FooBaz [a] But I agree that writing explici
by NOGDP 6y ago
I guess the idea is:
data Foo a b c = FooBar a b
| FooBaz c
or
data Foo a b = FooBar a b
| FooBaz [a]
But I agree that writing explicit type annotations is overall better practice.
- a1369209993 6y agoThat declares 'Foo' with kind * -> * -> * -> * , ie a generic type. Whereas I was declaring with kind * , a specific type that might have infered components. Compare: quux :: a -> a quux x = x # quux takes any type genericly frob y = y () ++ [()] # frob takes some specific type, but we don't need to specify which (spoiler alert: it's () -> [()]) Edit: actually the type is generic (not polymorphic) as well.
- NOGDP 6y agoWhy does the kind matter? Both of your examples use type inference and polymorphism - the type 'a' is inferred when quux is used, the type for the second example is inferred from the polymorphic types of (++) and `$`, and both allow to code more freely while in flux.