не понимаю:
genericHead f e = \case
(x:_) -> f x
[] -> e
headPrelude = genericHead id (error "Prelude.head: empty list")
main = let emp = ([] :: [Int]) in do
handle print $ headPrelude emp
Не компилируется с
Couldn't match type ‘Int’ with ‘IO ()’
Expected type: [IO ()]
Actual type: [Int]
In the first argument of ‘headPrelude’, namely ‘emp’
In the second argument of ‘($)’, namely ‘headPrelude emp’
:t handle
Обсуждают сегодня