zaxis wrote:

> then how to use `X` ? Would you mind explaining the newtype X in detail ?

You can just think of a newtype as a normal datatype:

> data X a = X (ReaderT XConf (StateT XState IO) a)

I.e. construction and pattern matching work indentically.

Every newtype you will find will have exactly one constructor with

exactly one field. Only datatypes that have one constructor with one

field can be made newtypes.

You can only use generalized deriving on newtypes:

http://www.haskell.org/ghc/docs/6.10-latest/html/users_guide/deriving.htmlThere are some other differences between datatypes and newtypes which

are only sometimes important. They are to do with efficiency and bottom.

You can read about them here:

http://www.haskell.org/tutorial/moretypes.htmlHTH,

Martijn.

_______________________________________________

Haskell-Cafe mailing list

[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe