[Haskell-cafe] Shrink function names
Viktor Dukhovni
ietf-dane at dukhovni.org
Sun Sep 19 14:54:23 UTC 2021
On Sun, Sep 19, 2021 at 07:58:22AM -0400, Brandon Allbery wrote:
> On Sun, Sep 19, 2021 at 3:02 AM Viktor Dukhovni <ietf-dane at dukhovni.org>
> wrote:
>
> > I don't know how to suppress unexported constructor names appearing in the
> > compiled code, perhaps someone else does, or it might not be possible...
>
> I would ask if there's a "deriving Show" involved.
My test code does not.
$ rm foo.o foo.hi
$ ghc -fhide-source-paths -dno-typeable-binds -dsuppress-type-signatures -optl-s -O2 foo.hs
[1 of 1] Compiling Main
Linking foo ...
$ strings -a foo | grep -i secret
main:Main.AnotherSecret
$ cat foo.hs
module Main (main) where
import System.Environment
import Data.Maybe
data SecretName = AnotherSecret String Int
secretName :: [String] -> Maybe SecretName
secretName = fmap (AnotherSecret <$> id <*> (+ 42) . read) . listToMaybe
{-# NOINLINE secretName #-}
main :: IO ()
main = secretName <$> getArgs >>= mapM_ (\ (AnotherSecret a b) -> print (a, b))
With a deriving (Show) instance, I see a second occurence:
main:Main.AnotherSecret
AnotherSecret
--
Viktor.
More information about the Haskell-Cafe
mailing list