Skip to content

Instantly share code, notes, and snippets.

@barrucadu
Created July 22, 2015 13:38
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 barrucadu/a59df62cd16074559e35 to your computer and use it in GitHub Desktop.
Save barrucadu/a59df62cd16074559e35 to your computer and use it in GitHub Desktop.
Inline core
Foo.f1 :: [Int]
[GblId,
Str=DmdType,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=False, ConLike=False,
WorkFree=False, Expandable=False, Guidance=IF_ARGS [] 30 0}]
Foo.f1 = GHC.Enum.eftInt 0 9223372036854775807
Rec {
Foo.f_go [Occ=LoopBreaker]
:: [(Int, Int)] -> [(Int, Int)] -> [(Int, Int)]
[GblId, Arity=2, Caf=NoCafRefs, Str=DmdType <S,1*U><L,1*U>]
Foo.f_go =
\ (ds_a14a :: [(Int, Int)]) (_ys_a14b :: [(Int, Int)]) ->
case ds_a14a of _ [Occ=Dead] {
[] -> GHC.Types.[] @ (Int, Int);
: ipv_a14g ipv1_a14h ->
case _ys_a14b of _ [Occ=Dead] {
[] -> GHC.Types.[] @ (Int, Int);
: ipv2_a14n ipv3_a14o ->
GHC.Types.: @ (Int, Int) ipv2_a14n (Foo.f_go ipv1_a14h ipv3_a14o)
}
}
end Rec }
Foo.$wf [InlPrag=[0]] :: [Int] -> GHC.Prim.Int#
[GblId,
Arity=1,
Str=DmdType <L,1*U>,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True, Guidance=IF_ARGS [0] 120 0}]
Foo.$wf =
\ (w_s1kP :: [Int]) ->
let {
ys_s1j4 [Dmd=<S,U>] :: [(Int, Int)]
[LclId, Str=DmdType]
ys_s1j4 = zip @ Int @ Int Foo.f1 w_s1kP } in
GHC.List.$wlenAcc
@ (Int, Int)
(Foo.f_go
ys_s1j4
(case ys_s1j4 of _ [Occ=Dead] {
[] -> GHC.List.scanl2 @ (Int, Int);
: ds1_a138 xs_a139 -> xs_a139
}))
0
f [InlPrag=INLINE[0]] :: [Int] -> Int
[GblId,
Arity=1,
Str=DmdType <L,1*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= \ (w_s1kP [Occ=Once] :: [Int]) ->
case Foo.$wf w_s1kP of ww_s1kS { __DEFAULT ->
GHC.Types.I# ww_s1kS
}}]
f =
\ (w_s1kP :: [Int]) ->
case Foo.$wf w_s1kP of ww_s1kS { __DEFAULT ->
GHC.Types.I# ww_s1kS
}
Foo.f1 :: [Int]
[GblId,
Str=DmdType,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=False, ConLike=False,
WorkFree=False, Expandable=False, Guidance=IF_ARGS [] 30 0}]
Foo.f1 = GHC.Enum.eftInt 0 9223372036854775807
Rec {
Foo.f_go [Occ=LoopBreaker]
:: [((Int, Int), (Int, Int))] -> [(Int, Int)]
[GblId, Arity=1, Caf=NoCafRefs, Str=DmdType <S,1*U>]
Foo.f_go =
\ (ds_a13o :: [((Int, Int), (Int, Int))]) ->
case ds_a13o of _ [Occ=Dead] {
[] -> GHC.Types.[] @ (Int, Int);
: y_a13t ys_a13u ->
case y_a13t of _ [Occ=Dead] { (ds1_d12V, i_an2) ->
GHC.Types.: @ (Int, Int) i_an2 (Foo.f_go ys_a13u)
}
}
end Rec }
Foo.$wf [InlPrag=[0]] :: [Int] -> GHC.Prim.Int#
[GblId,
Arity=1,
Str=DmdType <L,1*U>,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True, Guidance=IF_ARGS [0] 140 0}]
Foo.$wf =
\ (w_s1l3 :: [Int]) ->
let {
ys_s1j4 [Dmd=<S,U>] :: [(Int, Int)]
[LclId, Str=DmdType]
ys_s1j4 = zip @ Int @ Int Foo.f1 w_s1l3 } in
GHC.List.$wlenAcc
@ (Int, Int)
(Foo.f_go
(zip
@ (Int, Int)
@ (Int, Int)
ys_s1j4
(case ys_s1j4 of _ [Occ=Dead] {
[] -> GHC.List.scanl2 @ (Int, Int);
: ds1_a138 xs_a139 -> xs_a139
})))
0
f [InlPrag=INLINE[0]] :: [Int] -> Int
[GblId,
Arity=1,
Str=DmdType <L,1*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= \ (w_s1l3 [Occ=Once] :: [Int]) ->
case Foo.$wf w_s1l3 of ww_s1l6 { __DEFAULT ->
GHC.Types.I# ww_s1l6
}}]
f =
\ (w_s1l3 :: [Int]) ->
case Foo.$wf w_s1l3 of ww_s1l6 { __DEFAULT ->
GHC.Types.I# ww_s1l6
}
module Foo where
f :: [Int] -> Int
f xs = length is where
is = [ i | (_, i) <- pairs ys ] :: [(Int,Int)]
ys = zip [0..] xs :: [(Int, Int)]
{-# INLINE pairs #-}
pairs xs = zip xs $ tail xs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment