Data.Typeable を使用するすべての関数に対して、単なる固定文字列を超える部分的な解決策があります。
{-# LANGUAGE ScopedTypeVariables #-}
import Data.Typeable
instance (Typeable a, Typeable b) => Show (a->b) where
show _ = show $ typeOf (undefined :: a -> b)
ghciで
> let test :: Int->Int; test x = x + x
> test
Int -> Int
残念ながら、型シグネチャがないと、型はデフォルトになります。
> let test x = x + x
> test
Integer -> Integer
このソリューションは、複数の関数アリティで機能します。これは、 whereと同様に記述できる whicha -> b -> c
と同じであるためです。a -> (b -> c)
a -> d
d = b -> c
> let m10 a b c d e f g h i j = a * b * c * d * e * f * g * h* i * j
> m10
Integer -> Integer -> Integer -> Integer -> Integer -> Integer -> Integer
-> Integer -> Integer -> Integer -> Integer
このメソッドは機能しませんが、関数のパラメーターが型付け可能なクラスを持っているかどうかが不明な場合は機能しませんが、その間map (+1)
は機能しmap
ません。
> map (+1)
[Integer] -> [Integer]
> map
<interactive>:233:1:
...
の内部Data.Data
と 1 つまたは 2 つの実験を一瞥した後、リファクタリングして、より一般化された、より多くの機能をカバーできるように思われます。