-
Notifications
You must be signed in to change notification settings - Fork 30
/
Adhoc.test
36 lines (31 loc) · 902 Bytes
/
Adhoc.test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# 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