开发者

how to write the identity function in haskell

开发者 https://www.devze.com 2023-01-05 19:32 出处:网络
I have a function with type like this: functionX :: [String] -> ([Integer] -> [Integer]) It is kind of like a mapping function 开发者_JAVA技巧that maps a specific String to a function with ty

I have a function with type like this:

functionX :: [String] -> ([Integer] -> [Integer])

It is kind of like a mapping function 开发者_JAVA技巧that maps a specific String to a function with type as so. Because I need to handle the call functionX [], which I think this call should return something called identity function, or whatever, how can I write it?


id is predefined as the identity function in haskell. It has type id :: a -> a.

If you wanted, you could define your own easily:

myIdentityFunction :: a -> a
myIdentityFunction a = a
0

精彩评论

暂无评论...
验证码 换一张
取 消