Create a monad with two functions- increment decrement


Problem

Create a Haskell program that behaves like a counter that can increment or decrement a value
Create a monad with two functions: increment decrement
Use a return function to return the result.
Use a bind function to use the result as the input for another function.
See below for an example of how to create a 'twoStep' function that takes two steps forward and one step backward.
See the output below for an example of the output:
IGLT-0079:7 - Haskell tim.bazett-jones$ ghci
GHCi, version 7.10.2: https://www.haskell.org/ghc/ :? for help
Prelude> :load counter.hs
[1 of 1] Compiling Main ( counter.hs, interpreted )
Ok, modules loaded: Main.
*Main> let twoStep x = x >>== increment >>== increment >>== decrement >>== rtn
*Main> twoStep (Result 4)
Result 5
*Main>

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: Create a monad with two functions- increment decrement
Reference No:- TGS03256992

Expected delivery within 24 Hours