Skip to content

Instantly share code, notes, and snippets.

@mpickering
Created June 11, 2018 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mpickering/c190fc25260a3460f4633d0248659192 to your computer and use it in GitHub Desktop.
Save mpickering/c190fc25260a3460f4633d0248659192 to your computer and use it in GitHub Desktop.
module Foo where
qux :: [Int] -> [Int] -> [(Int, Int)]
qux as bs = map (\(a, b) -> (0, b + 1)) (zipWith (\a b -> (b, a)) as bs)
qux3 :: [Int] -> [Int] -> [Int] -> [(Int, Int, Int)]
qux3 as bs cs = map (\(a, b, c) -> (0, b + 1, c+a)) (zipWith3 (\a b c -> (c, b, a)) as bs cs)
qux4 :: [Int] -> [Int] -> [Int] -> [(Int, Int, Int)]
qux4 as bs cs = map (\(a, b, c) -> (0, b + 1, c+a)) (myZipWith3 (\a b c -> (c, b, a)) as bs cs)
myZipWith3 :: (a -> b -> c -> z) -> [a] -> [b] -> [c] -> [z]
myZipWith3 f xs ys zs = zipWith id (zipWith f xs ys) zs
[1 of 1] Compiling Foo ( zw3.hs, zw3.o )
==================== Tidy Core ====================
Result size of Tidy Core
= {terms: 137, types: 225, coercions: 0, joins: 0/1}
-- RHS size: {terms: 40, types: 51, coercions: 0, joins: 0/1}
myZipWith3
:: forall a b c z. (a -> b -> c -> z) -> [a] -> [b] -> [c] -> [z]
[GblId,
Arity=4,
Caf=NoCafRefs,
Str=<L,C(C1(C1(U)))><S,1*U><L,1*U><L,1*U>,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True, Guidance=IF_ARGS [60 0 0 0] 230 0}]
myZipWith3
= \ (@ a_a1dW)
(@ b_a1dX)
(@ c_a1dY)
(@ z_a1dZ)
(f_aYt :: a_a1dW -> b_a1dX -> c_a1dY -> z_a1dZ)
(xs_aYu :: [a_a1dW])
(ys_aYv :: [b_a1dX])
(zs_aYw :: [c_a1dY]) ->
letrec {
go2_a1r9 [Occ=LoopBreaker]
:: [a_a1dW] -> [b_a1dX] -> [c_a1dY] -> [z_a1dZ]
[LclId, Arity=3, Str=<S,1*U><L,1*U><L,1*U>, Unf=OtherCon []]
go2_a1r9
= \ (ds_a1ra :: [a_a1dW])
(_ys_a1rb :: [b_a1dX])
(eta_B1 :: [c_a1dY]) ->
case ds_a1ra of {
[] -> GHC.Types.[] @ z_a1dZ;
: ipv_a1rg ipv1_a1rh ->
case _ys_a1rb of {
[] -> GHC.Types.[] @ z_a1dZ;
: ipv2_a1rn ipv3_a1ro ->
case eta_B1 of {
[] -> GHC.Types.[] @ z_a1dZ;
: y_a1se ys1_a1sf ->
GHC.Types.:
@ z_a1dZ
(f_aYt ipv_a1rg ipv2_a1rn y_a1se)
(go2_a1r9 ipv1_a1rh ipv3_a1ro ys1_a1sf)
}
}
}; } in
go2_a1r9 xs_aYu ys_aYv zs_aYw
-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
Foo.$trModule4 :: GHC.Prim.Addr#
[GblId,
Caf=NoCafRefs,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 0}]
Foo.$trModule4 = "main"#
-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0}
Foo.$trModule3 :: GHC.Types.TrName
[GblId,
Caf=NoCafRefs,
Str=m1,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}]
Foo.$trModule3 = GHC.Types.TrNameS Foo.$trModule4
-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
Foo.$trModule2 :: GHC.Prim.Addr#
[GblId,
Caf=NoCafRefs,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 0}]
Foo.$trModule2 = "Foo"#
-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0}
Foo.$trModule1 :: GHC.Types.TrName
[GblId,
Caf=NoCafRefs,
Str=m1,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}]
Foo.$trModule1 = GHC.Types.TrNameS Foo.$trModule2
-- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0}
Foo.$trModule :: GHC.Types.Module
[GblId,
Caf=NoCafRefs,
Str=m,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}]
Foo.$trModule = GHC.Types.Module Foo.$trModule3 Foo.$trModule1
-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0}
Foo.qux6 :: Int
[GblId,
Caf=NoCafRefs,
Str=m,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}]
Foo.qux6 = GHC.Types.I# 0#
-- RHS size: {terms: 16, types: 16, coercions: 0, joins: 0/0}
Foo.qux2 :: (Int, Int, Int) -> (Int, Int, Int)
[GblId,
Arity=1,
Caf=NoCafRefs,
Str=<S,1*U(1*U(U),1*U(U),1*U(U))>m,
Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True,
Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False)
Tmpl= \ (ds_d1qg [Occ=Once!] :: (Int, Int, Int)) ->
case ds_d1qg of
{ (a_aYn [Occ=Once], b_aYo [Occ=Once!], c_aYp [Occ=Once]) ->
(Foo.qux6,
case b_aYo of { GHC.Types.I# x_a1sT [Occ=Once] ->
GHC.Types.I# (GHC.Prim.+# x_a1sT 1#)
},
GHC.Num.$fNumInt_$c+ c_aYp a_aYn)
}}]
Foo.qux2
= \ (ds_d1qg :: (Int, Int, Int)) ->
case ds_d1qg of { (a_aYn, b_aYo, c_aYp) ->
(Foo.qux6,
case b_aYo of { GHC.Types.I# x_a1sT ->
GHC.Types.I# (GHC.Prim.+# x_a1sT 1#)
},
GHC.Num.$fNumInt_$c+ c_aYp a_aYn)
}
-- RHS size: {terms: 7, types: 6, coercions: 0, joins: 0/0}
Foo.qux1 :: Int -> Int -> Int -> (Int, Int, Int)
[GblId,
Arity=3,
Caf=NoCafRefs,
Str=<L,U><L,U><L,U>m,
Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True,
Guidance=ALWAYS_IF(arity=3,unsat_ok=True,boring_ok=True)
Tmpl= \ (a_aYq [Occ=Once] :: Int)
(b_aYr [Occ=Once] :: Int)
(c_aYs [Occ=Once] :: Int) ->
(c_aYs, b_aYr, a_aYq)}]
Foo.qux1
= \ (a_aYq :: Int) (b_aYr :: Int) (c_aYs :: Int) ->
(c_aYs, b_aYr, a_aYq)
-- RHS size: {terms: 10, types: 21, coercions: 0, joins: 0/0}
qux4 :: [Int] -> [Int] -> [Int] -> [(Int, Int, Int)]
[GblId,
Arity=3,
Caf=NoCafRefs,
Str=<S,1*U><L,1*U><L,1*U>,
Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True,
Guidance=ALWAYS_IF(arity=3,unsat_ok=True,boring_ok=False)
Tmpl= \ (as_aYk [Occ=Once] :: [Int])
(bs_aYl [Occ=Once] :: [Int])
(cs_aYm [Occ=Once] :: [Int]) ->
GHC.Base.build
@ (Int, Int, Int)
(\ (@ b1_a1sx)
(c_a1sy [Occ=Once, OS=OneShot]
:: (Int, Int, Int) -> b1_a1sx -> b1_a1sx)
(n_a1sz [Occ=Once, OS=OneShot] :: b1_a1sx) ->
GHC.Base.foldr
@ (Int, Int, Int)
@ b1_a1sx
(GHC.Base.mapFB
@ (Int, Int, Int) @ b1_a1sx @ (Int, Int, Int) c_a1sy Foo.qux2)
n_a1sz
(myZipWith3
@ Int
@ Int
@ Int
@ (Int, Int, Int)
Foo.qux1
as_aYk
bs_aYl
cs_aYm))}]
qux4
= \ (as_aYk :: [Int]) (bs_aYl :: [Int]) (cs_aYm :: [Int]) ->
map
@ (Int, Int, Int)
@ (Int, Int, Int)
Foo.qux2
(myZipWith3
@ Int @ Int @ Int @ (Int, Int, Int) Foo.qux1 as_aYk bs_aYl cs_aYm)
-- RHS size: {terms: 10, types: 21, coercions: 0, joins: 0/0}
qux3 :: [Int] -> [Int] -> [Int] -> [(Int, Int, Int)]
[GblId,
Arity=3,
Caf=NoCafRefs,
Str=<S,1*U><L,1*U><L,1*U>,
Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True,
Guidance=ALWAYS_IF(arity=3,unsat_ok=True,boring_ok=False)
Tmpl= \ (as_aYb [Occ=Once] :: [Int])
(bs_aYc [Occ=Once] :: [Int])
(cs_aYd [Occ=Once] :: [Int]) ->
GHC.Base.build
@ (Int, Int, Int)
(\ (@ b1_a1sx)
(c_a1sy [Occ=Once, OS=OneShot]
:: (Int, Int, Int) -> b1_a1sx -> b1_a1sx)
(n_a1sz [Occ=Once, OS=OneShot] :: b1_a1sx) ->
GHC.Base.foldr
@ (Int, Int, Int)
@ b1_a1sx
(GHC.Base.mapFB
@ (Int, Int, Int) @ b1_a1sx @ (Int, Int, Int) c_a1sy Foo.qux2)
n_a1sz
(zipWith3
@ Int
@ Int
@ Int
@ (Int, Int, Int)
Foo.qux1
as_aYb
bs_aYc
cs_aYd))}]
qux3
= \ (as_aYb :: [Int]) (bs_aYc :: [Int]) (cs_aYd :: [Int]) ->
map
@ (Int, Int, Int)
@ (Int, Int, Int)
Foo.qux2
(zipWith3
@ Int @ Int @ Int @ (Int, Int, Int) Foo.qux1 as_aYb bs_aYc cs_aYd)
Rec {
-- RHS size: {terms: 25, types: 27, coercions: 0, joins: 0/0}
Foo.qux_go2 [Occ=LoopBreaker] :: [Int] -> [Int] -> [(Int, Int)]
[GblId, Arity=2, Caf=NoCafRefs, Str=<S,1*U><L,1*U>]
Foo.qux_go2
= \ (ds_a1ra :: [Int]) (_ys_a1rb :: [Int]) ->
case ds_a1ra of {
[] -> GHC.Types.[] @ (Int, Int);
: ipv_a1rg ipv1_a1rh ->
case _ys_a1rb of {
[] -> GHC.Types.[] @ (Int, Int);
: ipv2_a1rn ipv3_a1ro ->
GHC.Types.:
@ (Int, Int)
(Foo.qux6,
case ipv_a1rg of { GHC.Types.I# x_a1sT ->
GHC.Types.I# (GHC.Prim.+# x_a1sT 1#)
})
(Foo.qux_go2 ipv1_a1rh ipv3_a1ro)
}
}
end Rec }
-- RHS size: {terms: 5, types: 4, coercions: 0, joins: 0/0}
qux :: [Int] -> [Int] -> [(Int, Int)]
[GblId,
Arity=2,
Caf=NoCafRefs,
Str=<S,1*U><L,1*U>,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True,
Guidance=ALWAYS_IF(arity=2,unsat_ok=True,boring_ok=True)}]
qux
= \ (as_aSJ :: [Int]) (bs_aSK :: [Int]) ->
Foo.qux_go2 as_aSJ bs_aSK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment