Which is the use of curly braces in Haskell?

Curly braces is used in the syntax for record types. In this code, pattern matching is used to deconstruct the record type argument into its component fields.


The Handle__ data type was probably defined with record syntax, like this:

data Handle__ =
  Handle__
  { haCharBuffer :: IORef (...something...)
  , haBuffers :: IORef (...something...)
  , haBufferMode :: BufferMode
  }

The curly braces are used to match against the fields of the record type. So, the declaration says: "Check if the argument is of the Handle__ constructor; in that case, store the value of haCharBuffer in ref, the value of haBuffers in spare_ref and the value of haBufferMode in mode"

When you write Handle__ {..} it's the same thing as saying Handle__ { haCharBuffer = haCharBuffer, haBuffers = haBuffers, haBufferMode = haBufferMode }; all the fields in the data structure are bound to their field names.