I can never do too many Haskell tutorials.  There is always something to refine and learn.  So, I am working through chapter 10 of Real World Haskell, and everything makes sense.butWhy donewtype Parse a = Parse { runParse :: ParseState -> Either String (a, ParseState) }identity :: a -> Parse aidentity a = Parse (\s -> Right (a, s))getState :: Parse ParseStategetState = Parse (\s -> Right (s, s))putState :: Parse ()putState = Parse (\s -> Right ((), s))Why not simply dotype Parse a = ParseState -> Either String (a, ParseState)identity :: a -> Parse aidentity a = \s -> Right (a, s)getState :: Parse ParseStategetState = \s -> Right (s, s)putState :: Parse ()putState = \s -> Right ((), s)In other words, what is the purpose of the wrap and unwrap pattern in here (which I see used in a lot of different places in Haskell)?  We get the same Parse Whatever data type, but without the extra indirection.
Why have a wrapper constructor when storing a function in a data type?
haskell
The answer is that Haskell doesn't have arbitrary type lambdas, so when we want to eventually make our Parse type an instance of Monad, a newtype is required.