1 {-# OPTIONS_GHC -fno-warn-orphans #-}
6 import Control.Applicative
7 import Lambda.Parser.Fancy
11 cP = tRead "(λa d c.(λa.e) b (λc.d)) ((λa.(λd.a) (λd c.b ((λa.a) a)) (a ((λa.(λd.e) ((λe.(λd b.a) (λa c.(λa a d.(λd.b (λa d.c) e) (λb b.c a (a d (λb d d e a.d (λb b.d))))) ((λb.a) c)) (d ((λc.(λd.a (λe.e)) (c d)) ((λe.b) a))) c (λa.d (e (λe.(λd c.b) a))) (c (b a)) a (λe.(λa b e b a.d) b)) ((λe.b) (λa.b)) ((λe d.b) b) e) b) ((λc c.a e) (λb.(λb.e) a)))) (λe.e) b (λd c e e c a.c)) a)"
14 cY = tRead "λf.(λx.f (x x)) (λx.f (x x))"
20 cS = tRead "λx y z.x z (y z)"
22 instance Arbitrary Term
23 where arbitrary = sized aTerm
25 aVarName :: Gen String
26 aVarName = oneof . map (pure . (:[])) $ ['a'..'e']
28 aTypeName :: Gen String
29 aTypeName = oneof . map (pure . (:[])) $ ['A'..'E']
32 aComb = oneof . map pure $ [cS, cK, cI, cY]
35 aVar = liftA Var aVarName
37 aTerm :: Int -> Gen Term
41 , liftA2 Lam aVarName $ aTerm (n - 1)
42 , liftA2 App (aTerm (n `div` 2)) (aTerm (n `div` 2))
43 , liftA3 Let aVar (aTerm (n / 2)) (aTerm (n / 2))]