0

I am not familiar with Haskell but want to check out some of its definitions. I am looking at the Set and see this:

data Set a    = Bin {-# UNPACK #-} !Size !a !(Set a) !(Set a)
              | Tip

Wondering what that comment is doing (if it's doing some sort of code injection magic), and what the meaning of the exclamation marks is and the overall statement of !Size !a !(Set a) !(Set a).

Lance
  • 75,200
  • 93
  • 289
  • 503

1 Answers1

3

This is a GHC pragma:

The UNPACK indicates to the compiler that it should unpack the contents of a constructor field into the constructor itself, removing a level of indirection.

src: https://downloads.haskell.org/~ghc/7.0.3/docs/html/users_guide/pragmas.html

The meaning of those exclamations marks is to enforce strictness on those fields.

tgrez
  • 704
  • 5
  • 10