-
Book Overview & Buying
-
Table Of Contents
Haskell Data Analysis cookbook
By :
Even a custom-defined data type can be hashed easily. Dealing with hashed digests is often useful when the data itself is too space consuming to manage directly. By referencing a data by its digest, we can easily skip the cost of carrying around whole data types. This is especially useful in data analysis.
Install the
Data.Hashable package from Cabal as follows:
$ cabal install hashable
Use the GHC language extension DeriveGeneric to autodefine the hash functions for our custom data types as follows:
{-# LANGUAGE DeriveGeneric #-}Import the relevant packages using the following lines of code:
import GHC.Generics (Generic) import Data.Hashable
Create a custom data type and let GHC autodefine its hashable instance as follows:
data Point = Point Int Int
deriving (Eq, Generic)
instance Hashable PointIn main, create three points. Let two of them be the same, and let the third point be different, as shown in the following code snippet...
Change the font size
Change margin width
Change background colour