1 {-# OPTIONS_GHC -XModalTypes -fflatten -funsafe-skolemize -dcore-lint -XScopedTypeVariables -fsimpleopt-before-flatten #-}
2 module Demo ({-sample1,sample2,-}sample5,sample6) where
4 sample5 :: forall c . (Int -> <{Int}>@c) -> <{Int -> Int -> Int}>@c -> <{Int -> Int}>@c
5 sample5 const <[ (*) ]> =
7 let foo = (~~(const 3) * foo) * y
10 sample6 :: forall c . (Int -> <{Int}>@c) -> <{Int -> Int -> Int}>@c -> <{Int -> Int}>@c
11 sample6 const <{ (*) }> = pow 6
13 --pow :: Int -> <{ Int -> Int }>@a
14 pow 0 = <{ \x -> ~~(const 1) }>
16 pow n = <{ \x -> x * ~~(pow (n - 1)) x }>
21 <{Int -> Int -> Int}>@c ->
41 (~~mult (~~mult y y) (~~mult y y))
42 (~~mult (~~mult y y) (~~mult y y))
52 foo 0 = const (12::Int)
53 foo n = <{ let bar = ~~(foo (n-1))
65 foo 0 = const (12::Int)
66 foo n = <{ let recurs = ~~(foo (n-1))
67 in ~~mult recurs recurs
88 <{ \y -> ~~(foo 2 <{y}>) }>
90 foo 0 y = const (12::Int)
91 foo n y = <{ let recurs = ~~(foo (n-1) y)
92 in ~~mult recurs recurs
136 -- demo const mult = <{ \(y::Int) -> ~~mult y ~~(const 12) }>
137 -- demo' n = <{ ~~mult ~~(demo' (n-1)) ~~(demo' (n-1)) }>
142 let twelve = ~~mult twelve y
148 <{ \y -> let y = ~~(const 4) in ~~mult (~~mult y y) (~~mult y y) }>
154 let four = ~~mult four ~~(const 4)
155 -- twelve = {- {- ~~mult four -} ~~(const 12) -} four
162 <{ let twelve = ~~(const (12::Int))
163 in let four = ~~(const (4::Int))
164 in ~~mult four twelve }>
168 demo const mult = demo' 3
172 demo' n = <{ ~~mult ~~(demo' (n-1)) ~~(demo' (n-2)) }>
176 --demo const mult = <{ \y -> ~~(demo' 0) }>