|
|
|
|
|
by andrus
4347 days ago
|
|
The EitherIO data type given is data EitherIO e a = EitherIO {
runEitherIO :: IO (Either e a)
}
But, for the sake of clarity, it can be written as data EitherIO e a = MakeEitherIO {
runEitherIO :: IO (Either e a)
}
The author pointed out two functions that this EitherIO declaration gave us. One is a constructor, MakeEitherIO, with type IO (Either e a) -> EitherIO e a
In other words, MakeEitherIO takes a value of type IO (Either e a) and returns a value of type EitherIO e a (you could think of this as "wrapping" the original IO value).The second function, runEitherIO, is an accessor function for EitherIO's named record field "runEitherIO". It has type EitherIO e a -> IO (Either e a)
That is, runEitherIO takes a value of type EitherIO and returns the internal value of type IO (Either e a) (you could think of this as "unwrapping" the IO value).I hope that helps! |
|