Course / HaskDB

Other
5 stars 1 forks source link

Using newtype instead of data #2

Closed piyush-kurur closed 12 years ago

piyush-kurur commented 12 years ago

I noticed that in many places you are using datatypes of the following kind

     data Foo = Foo Int

If your datatype has only one type field. It is better to use newtype (as it is more efficient)

      newtype Foo = Foo Int

Here as far as implementation is concerned Foo is essentially Int where as data Foo = Foo Int will have an additional thunk.