This is not just newtype , it works the same with data . What you don't seem to know about is called field syntax,
newtype ZipList a = ZipList { getZipList :: [a] }
almost coincides with
newtype ZipList a = ZipList [a] getZipList :: ZipList a -> [a] getZipList (ZipList xs) = xs
but the syntax of the named field allows for more convenient updating and pattern matching - in particular, it is much more convenient for named fields in data types with several fields.
The named field (implicitly) defines an access function that extracts the contained data from the wrapped value.
source share