Open gelisam opened 6 years ago
Template Haskell has some strange limitations. The following works:
listMaybes :: Num a => [a] -> [Maybe a] listMaybes xs = $$(surjective [||\covers -> ((\x -> covers $ \(Just _) -> Just x) <$> xs) ++ [covers $ \Nothing -> Nothing] ||])
But the following doesn't:
-- error: No instance for (Num a) arising from the literal ‘0’ listMaybes :: Num a => [a] -> [Maybe a] listMaybes xs = $$(surjective [||\covers -> ((\x -> covers $ \(Just _) -> Just x) <$> xs) ++ [covers $ \Nothing -> Nothing] ++ [Just 0] ||])
Template Haskell has some strange limitations. The following works:
But the following doesn't: