The require pattern

With require, you are advised to design your modules as if they were to be imported qualified. As Jasper Van der Jeugt suggests in his talk.

Example

Instead of writing a module like this

data Person = Person
  { personName :: String
  , personAge  :: Int
  }

getPersonCode :: Person -> String
getPersonCode p =
  personName p <> (show $ personAge p)

(String used for simplification)

You are advised to put all these definitions in a separate module. Calling it Person, and removing all the prefixes:

module Person where

data Person = Person
  { name :: String
  , age  :: Int
  }

getCode :: Person -> String
getCode p =
  name p <> (show $ age p)

This way, the code becomes simpler, allowing you to separate concerns in larger applications.

Using the person module from another one

Now, to use these definitions, we use require.

require Person

foo :: Person -> Person -> Int
foo p1 p2 =
  length (Person.getCode p1 <> Person.name p2)