编程 haskell 题目如下:使用符号 <+> 表示加法,起到加号的作用 例如 Main> 1 <+> 2 3

2025-05-01 15:59:49
推荐回答(1个)
回答1:

instance Show (a -> b) where
show f = ""
instance Eq (a -> b) where
f == g = False
instance (Integral a, Integral b) => Num (a -> b) where
f + g = \x -> f x + g x
f - g = \x -> f x - g x
f * g = \x -> f x * g x
fromInteger n = \m -> fromIntegral m + fromIntegral n
abs f = undefined
signum f = undefined
(<+>) :: Int -> Int -> Int
(<+>) x y = x + y