Skip to content

STG prettyprinter doesn't print the evaluated binding of case

Given

module Foo where

data Result a = MkResult a | NoResult | Failure String

instance Functor Result where
  fmap f (MkResult x) = MkResult (f x)
  fmap _ NoResult = NoResult
  fmap _ (Failure desc) = Failure desc

compiled with ghc-9.8.1 -O -fforce-recomp -ddump-stg-final Foo.hs, I see

Foo.$fFunctorResult_$cfmap
  :: forall a b. (a -> b) -> Foo.Result a -> Foo.Result b
[GblId, Arity=2, Str=<MC(1,L)><1L>, Unf=OtherCon []] =
    {} \r [f_sDO ds_sDP]
        case ds_sDP of {
          Foo.MkResult x_sDR [Occ=Once1] ->
              let {
                sat_sDS [Occ=Once1] :: b_axK
                [LclId] =
                    {x_sDR, f_sDO} \u [] f_sDO x_sDR;
              } in  Foo.MkResult [sat_sDS];
          Foo.NoResult -> Foo.NoResult [];
          Foo.Failure desc_sDT [Occ=Once1] -> wild_sDQ<TagProper>;
        };

where is wild_sDQ<TagProper> bound? I suspect it should be

Foo.$fFunctorResult_$cfmap
  :: forall a b. (a -> b) -> Foo.Result a -> Foo.Result b
[GblId, Arity=2, Str=<MC(1,L)><1L>, Unf=OtherCon []] =
    {} \r [f_sDO ds_sDP]
        case ds_sDP of wild_sDQ { --- < here
          Foo.MkResult x_sDR [Occ=Once1] ->

it would fit, as there are _sDP, _sDR uniques right around that missing binder.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information