{"id":15639961,"url":"https://github.com/ocharles/what-it-do","last_synced_at":"2025-10-08T06:14:38.073Z","repository":{"id":66319174,"uuid":"136917072","full_name":"ocharles/what-it-do","owner":"ocharles","description":"Automatically trace all (showable) binds in do expressions","archived":false,"fork":false,"pushed_at":"2018-06-11T11:33:52.000Z","size":6,"stargazers_count":84,"open_issues_count":0,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-30T07:38:28.922Z","etag":null,"topics":["ghc","haskell","source-plugin"],"latest_commit_sha":null,"homepage":null,"language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ocharles.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-11T11:29:37.000Z","updated_at":"2024-03-17T22:29:35.000Z","dependencies_parsed_at":"2023-02-24T17:15:36.523Z","dependency_job_id":null,"html_url":"https://github.com/ocharles/what-it-do","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ocharles/what-it-do","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ocharles%2Fwhat-it-do","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ocharles%2Fwhat-it-do/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ocharles%2Fwhat-it-do/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ocharles%2Fwhat-it-do/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ocharles","download_url":"https://codeload.github.com/ocharles/what-it-do/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ocharles%2Fwhat-it-do/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265319576,"owners_count":23746364,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ghc","haskell","source-plugin"],"created_at":"2024-10-03T11:29:06.378Z","updated_at":"2025-10-08T06:14:33.010Z","avatar_url":"https://github.com/ocharles.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hey GHC, `what-it-do`?\n\n`what-it-do` is a GHC source plugin that rewrites `do` expressions to `trace`\nall binds. For example, given the following code:\n\n```haskell\nmain =\n  do \n    a \u003c- return ( 42 :: Int )\n    b \u003c- return ( a * 2 )\n    f \u003c- return ( \\b -\u003e return ( b - 1 ) )\n    c \u003c- f ( a * b )\n    print c\n```\n\nWe can trace all binds by using `debugDo` from `what-it-do`, and enabling the plugin:\n\n```haskell\n{-# OPTIONS -fplugin=WhatItDo #-}\nimport WhatItDo (traceDo)\nmain =\n  traceDo (do \n    a \u003c- return 42\n    b \u003c- return ( a * 2 )\n    f \u003c- return ( \\b -\u003e return ( b - 1 ) )\n    c \u003c- f ( a * b )\n    print c)\n```\n\nNow, when this code runs, we see:\n\n```\n(Test.hs:5:5-29) a = 42\n(Test.hs:6:5-25) b = 84\n(Test.hs:8:5-20) c = 3527\n3527\n```\n\nMagic!\n\n## Wha... how is this possible?\n\nUnder the hood, `what-it-do` has rewritten the original `do` expression to:\n\n```haskell\nmain =\n  do \n    a \u003c- return ( 42 :: Int ) \u003e\u003e= \\x -\u003e trace ( show x ) ( return x )\n    b \u003c- return ( a * 2 ) \u003e\u003e= \\x -\u003e trace ( show x ) ( return x )\n    f \u003c- return ( \\b -\u003e return ( b - 1 ) )\n    c \u003c- f ( a * b ) \u003e\u003e= \\x -\u003e trace ( show x ) ( return x )\n    print c\n```\n\nNotice that because the plugin has access to the type-checker, we only trace\nthings that can be shown. The binding to `f` doesn't get traced, because we\ncan't show what `f` is.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Focharles%2Fwhat-it-do","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Focharles%2Fwhat-it-do","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Focharles%2Fwhat-it-do/lists"}