What you think is missing is the functionality provided by the syntax of the entry. In Haskell, there are several ways to determine the data type. You are probably familiar with statements such as:
data MyType = MyType String Int
where the type MyType , which is the type of the sum (i.e., any value of this type has the filled fields String and Int ). If we want to work with this type, we may want to look at the String and Int components separately, so we will define access functions for this:
getLabel :: MyType -> String getLabel (MyType s _) = s getNum :: MyType -> Int getNum (MyType _ i) = i
For large data types (with many fields) this can become very tedious, and writing such a function in general is very common: often we have a simple type where the constructor wraps the content, and we want a convenient way to access this content by its own type (that is, without a wrapper).
Because this desire to access fields is so common, Haskell provides syntax for the entry. When you use the write syntax, you essentially name the fields inside the data type, and functions to retrieve the values in these fields are automatically generated. Thus, we can override our data type earlier:
data MyType' = MyType' { myLabel :: String, myNum :: Int }
and Haskell automatically generates the access functions myLabel :: MyType' -> String and myNum :: MyType' -> Int . These functions then have the same functionality as the getLabel and getNum functions that we defined earlier.
Take State as an example, we could define it as follows:
newtype State' sa = State' (s -> (a, s))
and wrote a function to access the contents:
getStateFun :: State' sa -> (s -> (a, s)) getStateFun (State' f) = f
which will allow us to remove State' "wrapping" from our value. But this is less convenient than using the write syntax that is used in your example: the value stored in the State shell is set by the name of the runState field, and Haskell generates an access function, so the code compiles and runs without a problem. runState then basically does the same thing as getStateFun .
This is also clearly explained in the section “Record Syntax” in this chapter of “Learn You A Haskell For Great Good” .