7 ms·
I have mixed feelings on this. On one hand I did want this notation while learning haskell. Partly because there are a bunch of places in haskell's type system
by Tarean 9y ago
I have mixed feelings on this. On one hand I did want this notation while learning haskell. Partly because there are a bunch of places in haskell's type system where repeating a variable implicitly gives equality constraints.
On the other hand something like
drop _ [] = []
drop x (y:xs)
| x == y = drop x xs
| otherwise = y : drop x xs
is often more readable at a glance to me since I don't have to parse variable names to see control flow structures.
Also, in statically typed languages what happens if equality doesn't work for a value.
- catnaroek 9y agoThe inferred type of drop _ [] = [] drop x (x:xs) = drop x xs drop x (y:xs) = y : drop x xs should be drop :: Eq a => a -> [a] -> [a] of course.