-
-
Save Solonarv/44618a66d54562346b3a to your computer and use it in GitHub Desktop.
Sample GHC Core output when dealing with multiple classes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module A where | |
class Foo a where foo :: a -> String | |
instance Show a => Foo [a] where foo = ($ "") . showList |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module B where | |
class Bar a where foo :: a -> a | |
instance Bar [a] where foo = reverse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func [InlPrag=NOINLINE] | |
:: forall a_aIx. (Foo a_aIx, Bar a_aIx) => a_aIx -> String | |
[GblId, Arity=2, Str=DmdType] | |
func = | |
\ (@ a5_aMq) ($dFoo_aMs :: Foo a5_aMq) ($dBar_aMt :: Bar a5_aMq) -> | |
. @ a5_aMq | |
@ String | |
@ a5_aMq | |
($dFoo_aMs | |
`cast` (A.NTCo:Foo[0] <a5_aMq>_N | |
:: Foo a5_aMq ~R# (a5_aMq -> String))) | |
($dBar_aMt | |
`cast` (B.NTCo:Bar[0] <a5_aMq>_N | |
:: Bar a5_aMq ~R# (a5_aMq -> a5_aMq))) | |
a_rPr :: Int | |
[GblId, Caf=NoCafRefs, Str=DmdType] | |
a_rPr = GHC.Types.I# 1 | |
a1_rPY :: Int | |
[GblId, Caf=NoCafRefs, Str=DmdType] | |
a1_rPY = GHC.Types.I# 2 | |
a2_rPZ :: Int | |
[GblId, Caf=NoCafRefs, Str=DmdType] | |
a2_rPZ = GHC.Types.I# 3 | |
a3_rQ0 :: [Int] | |
[GblId, Caf=NoCafRefs, Str=DmdType] | |
a3_rQ0 = GHC.Types.: @ Int a2_rPZ (GHC.Types.[] @ Int) | |
a4_rQ1 :: [Int] | |
[GblId, Caf=NoCafRefs, Str=DmdType] | |
a4_rQ1 = GHC.Types.: @ Int a1_rPY a3_rQ0 | |
lst :: [Int] | |
[GblId, Caf=NoCafRefs, Str=DmdType] | |
lst = GHC.Types.: @ Int a_rPr a4_rQ1 | |
main :: IO () | |
[GblId, Str=DmdType] | |
main = | |
putStrLn | |
(func | |
@ [Int] (A.$fFoo[] @ Int GHC.Show.$fShowInt) (B.$fBar[] @ Int) lst) | |
:Main.main :: IO () | |
[GblId, Str=DmdType] | |
:Main.main = GHC.TopHandler.runMainIO @ () main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import A | |
import B | |
func :: (Foo a, Bar a) => a -> String | |
func = A.foo . B.foo | |
{-# NOINLINE func #-} | |
lst :: [Int] | |
lst = [1,2,3] | |
main = putStrLn (func lst) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment