Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7962907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:28:37+00:00 2026-06-04T05:28:37+00:00

I have the following program: data Peano = Zero | Succ Peano deriving (Show)

  • 0

I have the following program:

data Peano = Zero | Succ Peano deriving (Show)

add Zero     b = b
add (Succ a) b = add a (Succ b)

mul Zero     b = Zero
mul (Succ a) b = add b (mul a b)

four x = let two = Succ (Succ Zero) in mul two two

I want to get something like this from GHC:

add =
  \ ds b ->
    case ds of
      Zero ->
        b
      Succ a ->
        add
          a
          (Succ b)

mul =
  \ ds b ->
    case ds of 
      Zero ->
        Zero
      Succ a ->
        add
          b
          (mul a b)

four =
    let
      two =
        Succ
           (Succ Zero)
    in
    mul two two

The best I managed to get is

ghci -ddump-simpl -dsuppress-module-prefixes -dsuppress-uniques foo.hs

but it steel required a lot of manual removal of GHC generated stuff to get the code above. Is there a switch for GHC or a third party script that does the cleanup?

Is there a way at least to get rid of case {tick (main:Main, 8)} @ (State# RealWorld) of _ { __DEFAULT ->?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T05:28:38+00:00Added an answer on June 4, 2026 at 5:28 am

    You’re in luck! There is a tool for the job: ghc-core.

    ghc-core wraps ghc with a command line wrapper that displays GHC’s optimised core and assembly output in a human readable, colourised manner, in a pager.

    Usage – just replace ghc with ghc-core:

       ghc-core A.hs  
    
       ghc-core -fvia-C -optc-O3 A.hs
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this following program in Python. import re data = '''component FA_8 is
I have the following program where two variables are to be passed by reference
I have the following dataset, I want to select distinct rows. since the data
Ok I have the following working program. It opens of a file of data
I have a program returning data in the following format: <CFData 0x1001219c0 [0x7fff7027aee0]>{length =
I have a program returning data in the following format: <CFData 0x1001219c0 [0x7fff7027aee0]>{length =
I currently have the following array in a Java program, byte[] data = new
I have following simple program: import std.stdio; int main(string[] argv) { writeln(Hello, world!); return
I have the following program to open lot's of sockets, and hold them open
I have the following program to browse all virtual directories and their sub directories

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.