I have made the following haskell program which will do some basic operations of load, read and increment. I am getting a type error. Can someone please tell why type error is there and how can i resolve it.
module ExampleProblem (Value,read',load,incr) where
newtype Value a = Value Int deriving (Eq,Read,Show)
read':: Value Int -> Int
read' (Value a) = a
load:: Int -> Value Int
load a = Value a
incr:: Value Int -> Value Int
incr (Value a) = Value (a+1)
main =  do
        (Value ab) <- (load 42)
        if (read'( Value ab) /= 42)
        then show "Failure to load"
        else do
             Value b <- incr( Value ab)
             Value c <- incr( Value b)
             if ((Value c) == Value 44)
             then show "Example finished"
             else show "error"
             return
The error i get is:
Couldn't match expected type `Int' with actual type `Value t0'
In the pattern: Value ab
In a stmt of a 'do' expression: (Value ab) <- (load 42)
In the expression:
  do { (Value ab) <- (load 42);
       if (read' (Value ab) /= 42) then
           show "Failure to load"
       else
           do { Value b <- incr (Value ab);
                .... } }
And when i made a separate file in which i had written the main function i was getting the error of scope although i was importing the module ExampleProblem.
Not in scope: data constructor `Value'