Function to output function name

后端 未结 5 1480
离开以前
离开以前 2020-12-17 22:20

Is it possible in Haskell to implement a function which returns its own function name?

A possible type could be (a -> b) -> String.

5条回答
  •  孤城傲影
    2020-12-17 23:11

    To clarify something mentioned in dons' post: no functions have names in Haskell. There are bindings which may bind functions, but if I had such a function (call it getName) as you seek then what would you expect this to return:

    let f x = x
        g   = f
        h   = f
    in  getName g == getName h
    

提交回复
热议问题