Haskell - Unable to define a State monad like function using a Monad like definition
问题 I am trying to understand the concept of Monad by attempting to write generic version of functions that might be then include side effects to log, change state. Here is what I came up with: (The code is bit long, but it is there to show how I approached understanding monad - and this approach may not be correct) data Maybe' a = Nothing' | Just' a deriving Show sqrt' :: (Floating a, Ord a) => a -> Maybe' a sqrt' x = if x < 0 then Nothing' else Just' (sqrt x) inv' :: (Floating a, Ord a) => a ->