Man or boy test: Difference between revisions

→‎{{header|Haskell}}: Shed one import. (liftA2 -> <$> ... <*>)
(→‎{{header|Haskell}}: Shed one import. (liftA2 -> <$> ... <*>))
Line 1,802:
Haskell is a pure language, so the impure effects of updating ''k'' must be wrapped in the IO or ST [[Monads|monad]]:
 
<lang haskell>import ControlData.ApplicativeIORef (liftA2modifyIORef, newIORef, readIORef)
import Data.IORef (modifyIORef, newIORef, readIORef)
 
a
Line 1,814 ⟶ 1,813:
a k b x1 x2 x3 x4
if k <= 0
then liftA2 (+) <$> x4 <*> x5
else b
where
9,655

edits