Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Text.Show.Functions only return <function>?

The standard package to show functions only returns a constant string:

λ> :m +Text.Show.Functions 
λ> show (+1)
"<function>"

GHCi's :type command is much more useful:

λ> :t (+1)
(+1) :: Num a => a -> a

Is it impossible to get such a level of detail at runtime? Does the compilation process leave any kind of information at all about functions, except for them being functions?

like image 792
Tobia Avatar asked Sep 26 '26 08:09

Tobia


1 Answers

Not exactly the same level of details, but you can use typeOf from Data.Typeable:

Prelude> import Data.Typeable
Prelude Data.Typeable> typeOf (+1)
Integer -> Integer
like image 192
Yuras Avatar answered Sep 28 '26 04:09

Yuras



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!