Is it possible to emulate a function using your own data type?

前端 未结 3 1709
南方客
南方客 2021-01-11 16:37

Is it possible to emulate a function with your own data type with some GHC extension? What I want to do is e.g.

(imaginary syntax)

data MyFunc = MyFu         


        
3条回答
  •  被撕碎了的回忆
    2021-01-11 17:18

    No, the syntax f e cannot be overloaded. The f has to have type S -> T.

    But you can still do a lot with EDSLs if you do a deep embedding, i.e., you let your functions build syntax trees instead of computing.

提交回复
热议问题