concept leader in category haskell

appears as: The leader, leader
Get Programming with Haskell

This is an excerpt from Manning's book Get Programming with Haskell.

The leader is the first 24 bytes of the record, as shown in figure 26.4.

Figure 26.4. The leader in your record highlighted
Listing 26.10. Declaring the length of the leader to be 24
leaderLength :: Int leaderLength = 24

Getting the leader from a MARC record is as straightforward as taking the first 24 characters of the MarcRecord.

Listing 26.11. getLeader grabs the first 24 bytes of the record
getLeader :: MarcRecordRaw -> MarcLeaderRaw getLeader record = B.take leaderLength record

Just as the first 24 bytes of the MARC record is the leader, the first 5 bytes of the leader contain a number telling you the length of the record. For example, in figure 26.4 you see that the record starts with 01292, which means this record is 1,292 bytes long. To get the length of your entire record, you need to take these first five characters and then convert them to an Int type. You’ll create a useful helper function, rawToInt, which will safely convert your ByteString to Text, then convert that Text to a String, and finally use read to parse an Int.