What is the correct way to define an already existing (e.g. in Prelude) operator between a user-defined type and an existing type?
问题 Suppose I have a custom type wrapping an existing type, newtype T = T Int deriving Show and suppose I want to be able to add up T s, and that adding them up should result in adding the wrapped values up; I would do this via instance Num T where (T t1) + (T t2) = T (t1 + t2) -- all other Num's methods = undefined I think we are good so far. Please, tell me if there are major concerns up to this point. Now let's suppose that I want to be able to multiply a T by an Int and that the result should