In GHCi:
Prelude> (+3) 25Prelude> (* 3) 26Prelude> (/ 3) 20.666666666666666666Prelude> (-3) 2There is no instance for (Num (t → t1)) arising from the literal it ': it = (- 3) 23' at <interactive>:1:2Possible fix: add an instance declaration for (Num (t -> t1))In the expression: 3In the expression: (- 3) 2In the definition of
3' at <interactive>:1:2Possible fix: add an instance declaration for (Num (t -> t1))In the expression: 3In the expression: (- 3) 2In the definition of
How can I fix the latter so that it returns -1?
Haskell grammar does not allow you to use -. Use the function instead subtract:
-
subtract
(subtract 3) 2
grddev, Haskell 98 Report:
-e , Haskell, negate (e). - - ; . - negate, . - .
-e
negate (e)
negate
, , : , - , :info (+) :info (-) .
:info (+)
:info (-)
subtract, grddev, infix:
Prelude> let (#) = (-) Prelude> (# 3) 2 -1
subtract , , .
(-) 3 2
1. -1, 3 -, ,
flip (-) 3 2
, :
(+ -3)
, .
Source: https://habr.com/ru/post/1758017/More articles:Scala среда программирования - scalaKext low-level hotkey to kill WindowServer? - low-leveljquery с панелью обновления - javascriptAndroid sdk & timers (Chronometer vs. Thread) - javaNeed help getting an HTML website in Java - javaIs it possible to update the contents of Show Table Data without closing and reopening? - sql-serverC ++ inline methods with the same if statement - c ++Posting a JSON string using dojo.xhrPost - javascriptSitecore: Force Paste as Unformatted Text - formattingWhat C # data types are not WCF serializable? - c #All Articles