# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # --adhoc "forall f g xs. map f (map g xs) = map (f . g) xs" --adhoc "forall p xs. length (filter p xs) = count p xs" -u Adhoc.foo --adhoc-type "MyMaybe a = Maybe a" --adhoc "MyNothing = Nothing" --adhoc "forall x. MyJust x = Just x" === module Adhoc where main :: IO () -main = print $ foo (bar [1..10]) +main = print $ bar [1..10] - 2 foo :: Int -> Int foo x = x - 2 bar :: [Int] -> Int -bar ys = length (filter even zs) +bar ys = count even zs where - zs = map (+1) (map (*3) ys) + zs = map ((+1) . (*3)) ys data MyMaybe a = MyNothing | MyJust a -baz :: Maybe a -> MyMaybe a +baz :: Maybe a -> Maybe a -baz Nothing = MyNothing +baz Nothing = Nothing -baz (Just y) = MyJust y +baz (Just y) = Just y