Reputation: 119
Hello i would like to print the names of functions in a list. Is it somehow possible to do so?
my example:
import Text.Show.Functions
f1 x = if x == 1 then 1 else 0
f2 x = if x == 2 then 1 else 0
f3 x = if x == 1 then 2 else 0
fs = [f1,f2,f3]
fs
writes out [<function>,<function>,<function>]
but I want [f1,f2,f3]
Upvotes: 1
Views: 414
Reputation: 153352
No, it is not possible. If you want named functions, you will have to whip them up yourself; e.g.
data Named a = Named { name :: String, val :: a }
instance Show (Named a) where show = name
fs = [Named "f1" f1, Named "f2" f2, Named "f3" f3]
Upvotes: 4