Created
February 26, 2019 15:53
-
-
Save chessai/b104c921943f2560a2cf424c589d0c6e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
{-# OPTIONS_GHC -fforce-recomp -ddump-simpl -fno-worker-wrapper -dsuppress-all #-} | |
module Main (main) where | |
import System.Environment (getArgs) | |
main :: IO () | |
main = do | |
[x,y] <- map read <$> getArgs | |
let f1 = f x A B | |
f2 = f y B f1 | |
print f2 | |
data T = A | B | C | D | E | F | G | |
deriving (Show) | |
{-# NOINLINE n #-} | |
n :: T -> T | |
n A = B | |
n B = C | |
n _ = A | |
f :: Int -> T -> T -> T | |
f sel x y = | |
-- function large enough to avoid being simply inlined | |
let j z = n . n . n . n . n . n $ z | |
in case sel of | |
-- j is always tailcalled | |
0 -> j x | |
_ -> j y | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment