diff --git a/CHANGELOG.md b/CHANGELOG.md
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -93,3 +93,17 @@
 
 * Fixed BOPT deconstruction in deconstructSAM_V1_6 (writeSAM_V1_6).
 * Added extra writeSAM_V1_6 test cases.
+
+## 0.9.0.0 -- 2023-10-31
+
+* Fixed writeSAM_V1_6 function.
+* Added additional test cases for writeSAM_V1_6.
+
+## 0.10.0.0 -- 2024-07-15
+
+* Fixed SAM parsing of optional fields.
+* Reorganized/refactored SAM modules.
+* Added BAM parsing.
+* Added internal modules.
+* Updated copyright in all modules.
+* Updated LICENSE with updated year.
diff --git a/LICENSE b/LICENSE
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2023, Matthew Mosior
+Copyright (c) 2024, Matthew Mosior
 
 All rights reserved.
 
diff --git a/hs-samtools.cabal b/hs-samtools.cabal
--- a/hs-samtools.cabal
+++ b/hs-samtools.cabal
@@ -20,7 +20,7 @@
 -- PVP summary:     +-+------- breaking API changes
 --                  | | +----- non-breaking API additions
 --                  | | | +--- code changes with no API change
-version:            0.9.0.0
+version:            0.10.0.0
 
 -- A short (one-line) description of the package.
 synopsis: Read and write SAM, BAM, and CRAM files.
@@ -65,15 +65,65 @@
     import:           warnings
 
     -- Modules exported by the library.
-    exposed-modules: Data.SAM.Version1_6.Base,
+    exposed-modules: Data.BAM.Version1_6.Base,
+                     Data.BAM.Version1_6.BAM,
+                     Data.BAM.Version1_6.BAM.BAMAlignments,
+                     Data.BAM.Version1_6.BAM.BAMHeader,
+                     Data.BAM.Version1_6.BAM.Alignment,
+                     Data.BAM.Version1_6.BAM.Alignment.Base,
+                     Data.BAM.Version1_6.BAM.Alignment.OptionalFields.Base,
+                     Data.BAM.Version1_6.BAM.Alignment.OptionalFields.AOPT,
+                     Data.BAM.Version1_6.BAM.Alignment.OptionalFields.BigCOPT,
+                     Data.BAM.Version1_6.BAM.Alignment.OptionalFields.BigIOPT,
+                     Data.BAM.Version1_6.BAM.Alignment.OptionalFields.BigSOPT,
+                     Data.BAM.Version1_6.BAM.Alignment.OptionalFields.SmallCOPT,
+                     Data.BAM.Version1_6.BAM.Alignment.OptionalFields.SmallIOPT,
+                     Data.BAM.Version1_6.BAM.Alignment.OptionalFields.SmallSOPT,
+                     Data.BAM.Version1_6.BAM.Alignment.OptionalFields.FOPT,
+                     Data.BAM.Version1_6.BAM.Alignment.OptionalFields.HOPT,
+                     Data.BAM.Version1_6.BAM.Alignment.OptionalFields.ZOPT,
+                     Data.BAM.Version1_6.BAM.Alignment.OptionalFields.BOPT,
+                     Data.BAM.Version1_6.BAM.Header, 
+                     Data.BAM.Version1_6.BAM.Header.CO,
+                     Data.BAM.Version1_6.BAM.Header.HD,
+                     Data.BAM.Version1_6.BAM.Header.PG,
+                     Data.BAM.Version1_6.BAM.Header.RG,
+                     Data.BAM.Version1_6.BAM.Header.SQ, 
+                     Data.BAM.Version1_6.BAM.ReferenceInformation,
+                     Data.BAM.Version1_6.BAM.ReferenceInformation.Base,
+                     Data.BAM.Version1_6.BGZFBlock,
+                     Data.BAM.Version1_6.GZipHeader,
+                     Data.BAM.Version1_6.Read.Base,
+                     Data.BAM.Version1_6.Read.Error,
+                     Data.BAM.Version1_6.Read.Parser.BGZFBlock,
+                     Data.BAM.Version1_6.Read.Parser.BAM.Base,
+                     Data.BAM.Version1_6.Read.Parser.BAM.BAMAlignments,
+                     Data.BAM.Version1_6.Read.Parser.BAM.BAMHeader,
+                     Data.BAM.Version1_6.Read.Parser.BAM.Alignment.Base,
+                     Data.BAM.Version1_6.Read.Parser.BAM.Alignment.OptionalFields.AOPT,
+                     Data.BAM.Version1_6.Read.Parser.BAM.Alignment.OptionalFields.BigCOPT,
+                     Data.BAM.Version1_6.Read.Parser.BAM.Alignment.OptionalFields.BigIOPT,
+                     Data.BAM.Version1_6.Read.Parser.BAM.Alignment.OptionalFields.BigSOPT,
+                     Data.BAM.Version1_6.Read.Parser.BAM.Alignment.OptionalFields.SmallCOPT,
+                     Data.BAM.Version1_6.Read.Parser.BAM.Alignment.OptionalFields.SmallIOPT,
+                     Data.BAM.Version1_6.Read.Parser.BAM.Alignment.OptionalFields.SmallSOPT,
+                     Data.BAM.Version1_6.Read.Parser.BAM.Alignment.OptionalFields.FOPT,
+                     Data.BAM.Version1_6.Read.Parser.BAM.Alignment.OptionalFields.HOPT,
+                     Data.BAM.Version1_6.Read.Parser.BAM.Alignment.OptionalFields.ZOPT,
+                     Data.BAM.Version1_6.Read.Parser.BAM.Alignment.OptionalFields.BOPT,
+                     Data.BAM.Version1_6.Read.Parser.BAM.ReferenceInformation.Base,
+                     Data.BAM.Version1_6.Write.Base,
+                     Data.BAM.Version1_6.Write.Error,
+                     Data.SAM.Version1_6.Base,
                      Data.SAM.Version1_6.Alignment,
                      Data.SAM.Version1_6.Alignment.Base,
-                     Data.SAM.Version1_6.Alignment.AOPT,
-                     Data.SAM.Version1_6.Alignment.FOPT,
-                     Data.SAM.Version1_6.Alignment.HOPT,
-                     Data.SAM.Version1_6.Alignment.IOPT,
-                     Data.SAM.Version1_6.Alignment.ZOPT,
-                     Data.SAM.Version1_6.Alignment.BOPT,
+                     Data.SAM.Version1_6.Alignment.OptionalFields.Base,
+                     Data.SAM.Version1_6.Alignment.OptionalFields.AOPT,
+                     Data.SAM.Version1_6.Alignment.OptionalFields.FOPT,
+                     Data.SAM.Version1_6.Alignment.OptionalFields.HOPT,
+                     Data.SAM.Version1_6.Alignment.OptionalFields.IOPT,
+                     Data.SAM.Version1_6.Alignment.OptionalFields.ZOPT,
+                     Data.SAM.Version1_6.Alignment.OptionalFields.BOPT,
                      Data.SAM.Version1_6.Header, 
                      Data.SAM.Version1_6.Header.CO,
                      Data.SAM.Version1_6.Header.HD,
@@ -83,12 +133,12 @@
                      Data.SAM.Version1_6.Read.Base,
                      Data.SAM.Version1_6.Read.Error,
                      Data.SAM.Version1_6.Read.Parser.Alignment.Base,
-                     Data.SAM.Version1_6.Read.Parser.Alignment.AOPT,
-                     Data.SAM.Version1_6.Read.Parser.Alignment.IOPT,
-                     Data.SAM.Version1_6.Read.Parser.Alignment.FOPT,
-                     Data.SAM.Version1_6.Read.Parser.Alignment.ZOPT,
-                     Data.SAM.Version1_6.Read.Parser.Alignment.HOPT,
-                     Data.SAM.Version1_6.Read.Parser.Alignment.BOPT,
+                     Data.SAM.Version1_6.Read.Parser.Alignment.OptionalFields.AOPT,
+                     Data.SAM.Version1_6.Read.Parser.Alignment.OptionalFields.IOPT,
+                     Data.SAM.Version1_6.Read.Parser.Alignment.OptionalFields.FOPT,
+                     Data.SAM.Version1_6.Read.Parser.Alignment.OptionalFields.ZOPT,
+                     Data.SAM.Version1_6.Read.Parser.Alignment.OptionalFields.HOPT,
+                     Data.SAM.Version1_6.Read.Parser.Alignment.OptionalFields.BOPT,
                      Data.SAM.Version1_6.Read.Parser.Header.HD.Base,
                      Data.SAM.Version1_6.Read.Parser.Header.HD.VN,
                      Data.SAM.Version1_6.Read.Parser.Header.HD.SO,
@@ -131,26 +181,37 @@
                      Data.SAM.Version1_6.Write.Base
 
     -- Modules included in this library but not exported.
-    -- other-modules:
+    other-modules: Data.BAM.Version1_6.Internal,
+                   Data.BAM.Version1_6.Read.Parser.BAM.Alignment.Internal,
+                   Data.BAM.Version1_6.Write.Internal,
+                   Data.SAM.Version1_6.Internal
 
     -- LANGUAGE extensions used by modules in this package.
     -- other-extensions:
 
     -- Other library packages from which modules are imported.
-    build-depends:    base                 ^>=4.17.1.0, 
-                      ascii                >= 1.7.0 && < 1.8,
-                      attoparsec           >= 0.14.4 && < 0.15,
-                      bitvec               >= 1.1.4 && < 1.2,
-                      bytestring           >= 0.11.4 && < 0.12,
-                      containers           >= 0.6.7 && < 0.7,
-                      crypton              >= 0.33 && < 0.34,
-                      generic-deriving     >= 1.14.5 && < 1.15,
-                      parser-combinators   >= 1.3.0 && < 1.4,
-                      pcre-heavy           >= 1.0.0 && < 1.1,
-                      regex-tdfa           >= 1.3.2 && < 1.4,
-                      streamly             >= 0.9.0 && < 0.10,
-                      streamly-bytestring  >= 0.2.0 && < 0.3,
-                      streamly-core        >= 0.1.0 && < 0.2 
+    build-depends: base                >= 4.18.2 && < 4.19,
+                   array               >= 0.5.6 && < 0.6,
+                   ascii               >= 1.7.0 && < 1.8,
+                   base16              >= 1.0 && < 1.1,
+                   binary              >= 0.8.9 && < 0.9,
+                   bytestring          >= 0.11.5 && < 0.12,
+                   containers          >= 0.6.7 && < 0.7,
+                   attoparsec          >= 0.14.4 && < 0.15,
+                   bitvec              >= 1.1.5 && < 1.2,
+                   crypton             >= 1.0.0 && < 1.1,
+                   deepseq             >= 1.4.8 && < 1.5,
+                   digest              >= 0.0.2 && < 0.1,
+                   generic-deriving    >= 1.14.5 && < 1.15,
+                   mason               >= 0.2.6 && < 0.3,
+                   parsers             >= 0.12.11 && < 0.13,
+                   parser-combinators  >= 1.3.0 && < 1.4,
+                   pcre-heavy          >= 1.0.0 && < 1.1,
+                   regex-tdfa          >= 1.3.2 && < 1.4,
+                   streamly            >= 0.10.0 && < 0.11,
+                   streamly-bytestring >= 0.2.1 && < 0.3,
+                   streamly-core       >= 0.2.1 && < 0.3,
+                   zlib                >= 0.7.1 && < 0.8
 
     -- Directories containing source files.
     hs-source-dirs:   src
@@ -181,7 +242,7 @@
     main-is:          Main.hs
 
     -- Test dependencies.
-    build-depends: base ^>=4.17.1.0,
+    build-depends: base,
                    bytestring,
                    containers,
                    hspec,
diff --git a/src/Data/BAM/Version1_6/BAM.hs b/src/Data/BAM/Version1_6/BAM.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/BAM.hs
@@ -0,0 +1,63 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE StrictData            #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.BAM
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.BAM ( -- * BAM_V1_6_BAM version 1.6 data type
+                                 BAM_V1_6_BAM(..)
+                               ) where
+
+import Data.BAM.Version1_6.BAM.BAMHeader
+import Data.BAM.Version1_6.BAM.BAMAlignments
+
+import Data.Data
+import Generics.Deriving.Base
+
+-- | Custom @"BAM_V1_6_BAM"@ (BAM version 1.6) data type.
+--
+-- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data BAM_V1_6_BAM = BAM_V1_6_BAM
+  { bam_v1_6_bam_bamheader          :: Maybe BAM_V1_6_BAM_BAMHeader
+  , bam_v1_6_bam_bamalignments      :: Maybe BAM_V1_6_BAM_BAMAlignments
+  , bam_v1_6_bam_endoffilemarker    :: Bool
+  } deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_BAM where
+  BAM_V1_6_BAM bam_v1_6_bam_bamheader1
+               bam_v1_6_bam_bamalignments1
+               bam_v1_6_bam_endoffilemarker1 ==
+    BAM_V1_6_BAM bam_v1_6_bam_bamheader2
+                 bam_v1_6_bam_bamalignments2
+                 bam_v1_6_bam_endoffilemarker2 =
+      bam_v1_6_bam_bamheader1          == bam_v1_6_bam_bamheader2     &&
+      bam_v1_6_bam_bamalignments1      == bam_v1_6_bam_bamalignments2 &&
+      bam_v1_6_bam_endoffilemarker1    == bam_v1_6_bam_endoffilemarker2
+
+instance Show BAM_V1_6_BAM where
+  show (BAM_V1_6_BAM header
+                     alignments
+                     endoffilemarker
+       ) =
+    "BAM_V1_6_BAM { "                       ++
+    "bam_v1_6_bam_bamheader = "             ++
+    (show header)                           ++
+    " , bam_v1_6_bam_alignments = "         ++
+    (show alignments)                       ++
+    " , bam_v1_6_bam_endoffilemarker = "    ++
+    (show endoffilemarker)                  ++
+    " }"
diff --git a/src/Data/BAM/Version1_6/BAM/Alignment.hs b/src/Data/BAM/Version1_6/BAM/Alignment.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/BAM/Alignment.hs
@@ -0,0 +1,38 @@
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.BAM.Alignment
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = WARNING
+--
+-- This module is considered __internal__.
+--
+-- The Package Versioning Policy __does not apply__.
+--
+-- The contents of this module may change __in any way whatsoever__
+-- and __without any warning__ between minor versions of this package.
+--
+-- Authors importing this library are expected to track development
+-- closely.
+--
+-- All credit goes to the author(s)/maintainer(s) of the
+-- [containers](https://hackage.haskell.org/package/containers) library
+-- for the above warning text.
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.BAM.Alignment ( -- * BAM version 1.6 alignment mandatory and optional data types (RE-EXPORT)
+                                           module Data.BAM.Version1_6.BAM.Alignment.Base
+                                         ) where
+
+-- | Re-exports.
+import Data.BAM.Version1_6.BAM.Alignment.Base
diff --git a/src/Data/BAM/Version1_6/BAM/Alignment/Base.hs b/src/Data/BAM/Version1_6/BAM/Alignment/Base.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/BAM/Alignment/Base.hs
@@ -0,0 +1,176 @@
+{-# LANGUAGE DeriveDataTypeable          #-}
+{-# LANGUAGE DeriveGeneric               #-}
+{-# LANGUAGE FlexibleContexts            #-}
+{-# LANGUAGE FlexibleInstances           #-}
+{-# LANGUAGE MultiParamTypeClasses       #-}
+{-# LANGUAGE OverloadedStrings           #-}
+{-# LANGUAGE StrictData                  #-}
+{-# LANGUAGE TypeFamilies                #-}
+{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.BAM.Alignment.Base
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.BAM.Alignment.Base ( -- * BAM version 1.6 alignment mandatory and optional data types
+                                                BAM_V1_6_BAM_Alignment(..)
+                                              ) where
+
+import Data.BAM.Version1_6.BAM.Alignment.OptionalFields.Base
+
+import Data.ByteString
+import Data.Int
+import Data.Sequence
+import Data.Word
+import Data.Data
+import Generics.Deriving.Base
+
+-- | Custom BAM (version 1.6) @"BAM_V1_6_BAM_Alignment"@ data type.
+--
+-- See section 4.2 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data BAM_V1_6_BAM_Alignment = BAM_V1_6_BAM_Alignment
+  { bam_v1_6_bam_alignment_block_size     :: Word32                                    -- ^ Total length of the alignment
+                                                                                       -- record, excluding this field.
+  , bam_v1_6_bam_alignment_refID          :: Int32                                     -- ^ Reference sequence ID, -1 <= refID <= n_ref;
+                                                                                       -- -1 for a read without a mapping position.
+  , bam_v1_6_bam_alignment_pos            :: Int32                                     -- ^ 0-based leftmost coordinate (= POS - 1).
+  , bam_v1_6_bam_alignment_l_read_name    :: Word8                                     -- ^ Length of read_name below (= length(QNAME) + 1).
+  , bam_v1_6_bam_alignment_mapq           :: Word8                                     -- ^ Mapping quality (= MAPQ).
+  , bam_v1_6_bam_alignment_bin            :: Word16                                    -- ^ BAI index bin, see Section 4.2.1.
+  , bam_v1_6_bam_alignment_n_cigar_op     :: Word16                                    -- ^ Number of operations in CIGAR,
+                                                                                       -- see section 4.2.2.
+  , bam_v1_6_bam_alignment_flag           :: Word16                                    -- ^ Bitwise flags (= FLAG).
+  , bam_v1_6_bam_alignment_l_seq          :: Word32                                    -- ^ Length of SEQ.
+  , bam_v1_6_bam_alignment_next_refID     :: Int32                                     -- ^ Ref-ID of the next seqment
+                                                                                       -- (-1 <= next_refID <= n_ref).
+  , bam_v1_6_bam_alignment_next_pos       :: Int32                                     -- ^ 0-based leftmost pos of the
+                                                                                       -- next segment (= PNEXT - 1).
+  , bam_v1_6_bam_alignment_tlen           :: Int32                                     -- ^ Template length (= TLEN).
+  , bam_v1_6_bam_alignment_read_name      :: ByteString                                -- ^ Read name; NUL-terminated
+                                                                                       -- (QNAME with trailing 0x00/'\0').
+  , bam_v1_6_bam_alignment_cigar          :: Seq Word32                                -- ^ CIGAR; op_len<<4<<|op.
+                                                                                       -- 'MIDNSHP=X' -> '012345678'.
+  , bam_v1_6_bam_alignment_seq            :: Seq Word8                                 -- ^ 4-bit encoded read:
+                                                                                       -- '=ACMGRSVTWYHKDBN' -> [0,15].
+                                                                                       -- See section 4.2.3.
+  , bam_v1_6_bam_alignment_qual           :: ByteString                                -- ^ Phred-scaled base qualities.
+                                                                                       -- See section 4.2.3.
+  , bam_v1_6_bam_alignment_optionalfields :: Seq BAM_V1_6_BAM_Alignment_OptionalFields -- ^ List of auxiliary data. 
+                                                                                       -- See section 4.2.4
+  } deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_BAM_Alignment where
+  BAM_V1_6_BAM_Alignment bam_v1_6_bam_alignment_block_size1
+                         bam_v1_6_bam_alignment_refID1
+                         bam_v1_6_bam_alignment_pos1
+                         bam_v1_6_bam_alignment_l_read_name1
+                         bam_v1_6_bam_alignment_mapq1
+                         bam_v1_6_bam_alignment_bin1
+                         bam_v1_6_bam_alignment_n_cigar_op1
+                         bam_v1_6_bam_alignment_flag1
+                         bam_v1_6_bam_alignment_l_seq1
+                         bam_v1_6_bam_alignment_next_refID1
+                         bam_v1_6_bam_alignment_next_pos1
+                         bam_v1_6_bam_alignment_tlen1
+                         bam_v1_6_bam_alignment_read_name1
+                         bam_v1_6_bam_alignment_cigar1
+                         bam_v1_6_bam_alignment_seq1
+                         bam_v1_6_bam_alignment_qual1
+                         bam_v1_6_bam_alignment_optional_fields1 ==
+    BAM_V1_6_BAM_Alignment bam_v1_6_bam_alignment_block_size2
+                           bam_v1_6_bam_alignment_refID2
+                           bam_v1_6_bam_alignment_pos2
+                           bam_v1_6_bam_alignment_l_read_name2
+                           bam_v1_6_bam_alignment_mapq2
+                           bam_v1_6_bam_alignment_bin2
+                           bam_v1_6_bam_alignment_n_cigar_op2
+                           bam_v1_6_bam_alignment_flag2
+                           bam_v1_6_bam_alignment_l_seq2
+                           bam_v1_6_bam_alignment_next_refID2
+                           bam_v1_6_bam_alignment_next_pos2
+                           bam_v1_6_bam_alignment_tlen2
+                           bam_v1_6_bam_alignment_read_name2
+                           bam_v1_6_bam_alignment_cigar2
+                           bam_v1_6_bam_alignment_seq2
+                           bam_v1_6_bam_alignment_qual2
+                           bam_v1_6_bam_alignment_optional_fields2 =
+      bam_v1_6_bam_alignment_block_size1      ==  bam_v1_6_bam_alignment_block_size2  &&
+      bam_v1_6_bam_alignment_refID1           ==  bam_v1_6_bam_alignment_refID2       &&
+      bam_v1_6_bam_alignment_pos1             ==  bam_v1_6_bam_alignment_pos2         &&
+      bam_v1_6_bam_alignment_l_read_name1     ==  bam_v1_6_bam_alignment_l_read_name2 &&
+      bam_v1_6_bam_alignment_mapq1            ==  bam_v1_6_bam_alignment_mapq2        &&
+      bam_v1_6_bam_alignment_bin1             ==  bam_v1_6_bam_alignment_bin2         &&
+      bam_v1_6_bam_alignment_n_cigar_op1      ==  bam_v1_6_bam_alignment_n_cigar_op2  &&
+      bam_v1_6_bam_alignment_flag1            ==  bam_v1_6_bam_alignment_flag2        &&
+      bam_v1_6_bam_alignment_l_seq1           ==  bam_v1_6_bam_alignment_l_seq2       &&
+      bam_v1_6_bam_alignment_next_refID1      ==  bam_v1_6_bam_alignment_next_refID2  &&
+      bam_v1_6_bam_alignment_next_pos1        ==  bam_v1_6_bam_alignment_next_pos2    &&
+      bam_v1_6_bam_alignment_tlen1            ==  bam_v1_6_bam_alignment_tlen2        &&
+      bam_v1_6_bam_alignment_read_name1       ==  bam_v1_6_bam_alignment_read_name2   &&
+      bam_v1_6_bam_alignment_cigar1           ==  bam_v1_6_bam_alignment_cigar2       &&
+      bam_v1_6_bam_alignment_seq1             ==  bam_v1_6_bam_alignment_seq2         &&
+      bam_v1_6_bam_alignment_qual1            ==  bam_v1_6_bam_alignment_qual2        &&
+      bam_v1_6_bam_alignment_optional_fields1 ==  bam_v1_6_bam_alignment_optional_fields2
+
+instance Show BAM_V1_6_BAM_Alignment where
+  show ( BAM_V1_6_BAM_Alignment block_size
+                                refID
+                                pos
+                                l_read_name
+                                mapq
+                                bin
+                                n_cigar_op
+                                flag
+                                l_seq
+                                next_refID
+                                next_pos
+                                tlen
+                                read_name
+                                cigar
+                                seq
+                                qual
+                                optionalfields
+       ) =
+    "BAM_V1_6_BAM_Alignment { "                   ++
+    "bam_v1_6_bam_alignment_block_size = "        ++
+    (show block_size)                             ++
+    " , bam_v1_6_bam_alignment_refID = "          ++
+    (show refID)                                  ++
+    " , bam_v1_6_bam_alignment_pos = "            ++
+    (show pos)                                    ++
+    " , bam_v1_6_bam_alignment_l_read_name = "    ++
+    (show l_read_name)                            ++
+    " , bam_v1_6_bam_alignment_mapq = "           ++
+    (show mapq)                                   ++
+    " , bam_v1_6_bam_alignment_bin = "            ++
+    (show bin)                                    ++
+    " , bam_v1_6_bam_alignment_n_cigar_op = "     ++
+    (show n_cigar_op)                             ++
+    " , bam_v1_6_bam_alignment_flag = "           ++
+    (show flag)                                   ++
+    " , bam_v1_6_bam_alignment_l_seq = "          ++
+    (show l_seq)                                  ++
+    " , bam_v1_6_bam_alignment_next_refID = "     ++
+    (show next_refID)                             ++
+    " , bam_v1_6_bam_alignment_next_pos = "       ++
+    (show next_pos)                               ++
+    " , bam_v1_6_bam_alignment_tlen = "           ++
+    (show tlen)                                   ++
+    " , bam_v1_6_bam_alignment_read_name = "      ++
+    (show read_name)                              ++
+    " , bam_v1_6_bam_alignment_cigar = "          ++
+    (show cigar)                                  ++
+    " , bam_v1_6_bam_alignment_seq = "            ++
+    (show seq)                                    ++
+    " , bam_v1_6_bam_alignment_qual = "           ++
+    (show qual)                                   ++
+    " , bam_v1_6_bam_alignment_optionalfields = " ++
+    (show optionalfields)                         ++
+    " }"
diff --git a/src/Data/BAM/Version1_6/BAM/Alignment/OptionalFields/AOPT.hs b/src/Data/BAM/Version1_6/BAM/Alignment/OptionalFields/AOPT.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/BAM/Alignment/OptionalFields/AOPT.hs
@@ -0,0 +1,72 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE StrictData            #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.BAM.Alignment.OptionalFields.AOPT
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = WARNING
+--
+-- This module is considered __internal__.
+--
+-- The Package Versioning Policy __does not apply__.
+--
+-- The contents of this module may change __in any way whatsoever__
+-- and __without any warning__ between minor versions of this package.
+--
+-- Authors importing this library are expected to track development
+-- closely.
+--
+-- All credit goes to the author(s)/maintainer(s) of the
+-- [containers](https://hackage.haskell.org/package/containers) library
+-- for the above warning text.
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.BAM.Alignment.OptionalFields.AOPT ( -- * BAM version 1.6 alignment optional fields data type
+                                                               BAM_V1_6_BAM_Alignment_OptionalFields_AOPT(..)
+                                                             ) where
+
+import Data.ByteString
+import Data.Word
+import Data.Data
+import Generics.Deriving.Base
+
+
+-- | Custom BAM (version 1.6) @"BAM_V1_6_Alignment_OptionalFields_AOPT"@ data type.
+--
+-- See section 4.2 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data BAM_V1_6_BAM_Alignment_OptionalFields_AOPT = BAM_V1_6_BAM_Alignment_OptionalFields_AOPT
+  { bam_v1_6_bam_alignment_optionalfields_aopt_tag   :: ByteString
+  , bam_v1_6_bam_alignment_optionalfields_aopt_value :: Word8
+  } deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_BAM_Alignment_OptionalFields_AOPT where
+  BAM_V1_6_BAM_Alignment_OptionalFields_AOPT bam_v1_6_bam_alignment_optionalfields_aopt_tag1
+                                             bam_v1_6_bam_alignment_optionalfields_aopt_value1 ==
+    BAM_V1_6_BAM_Alignment_OptionalFields_AOPT bam_v1_6_bam_alignment_optionalfields_aopt_tag2
+                                               bam_v1_6_bam_alignment_optionalfields_aopt_value2 =
+      bam_v1_6_bam_alignment_optionalfields_aopt_tag1   == bam_v1_6_bam_alignment_optionalfields_aopt_tag2 &&
+      bam_v1_6_bam_alignment_optionalfields_aopt_value1 == bam_v1_6_bam_alignment_optionalfields_aopt_value2
+
+instance Show BAM_V1_6_BAM_Alignment_OptionalFields_AOPT where
+  show (BAM_V1_6_BAM_Alignment_OptionalFields_AOPT tag
+                                                   value
+       ) =
+    "BAM_V1_6_BAM_Alignment_OptionalFields_AOPT { "          ++
+    "bam_v1_6_bam_alignment_optionalfields_aopt_tag = "      ++
+    (show tag)                                               ++
+    " , bam_v1_6_bam_alignment_optionalfields_aopt_value = " ++
+    (show value)                                             ++
+    " }"
diff --git a/src/Data/BAM/Version1_6/BAM/Alignment/OptionalFields/BOPT.hs b/src/Data/BAM/Version1_6/BAM/Alignment/OptionalFields/BOPT.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/BAM/Alignment/OptionalFields/BOPT.hs
@@ -0,0 +1,416 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE StrictData            #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.BAM.Alignment.OptionalFields.BOPT
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = WARNING
+--
+-- This module is considered __internal__.
+--
+-- The Package Versioning Policy __does not apply__.
+--
+-- The contents of this module may change __in any way whatsoever__
+-- and __without any warning__ between minor versions of this package.
+--
+-- Authors importing this library are expected to track development
+-- closely.
+--
+-- All credit goes to the author(s)/maintainer(s) of the
+-- [containers](https://hackage.haskell.org/package/containers) library
+-- for the above warning text.
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.BAM.Alignment.OptionalFields.BOPT ( -- * SAM version 1.6 alignment optional fields data type
+                                                               BAM_V1_6_BAM_Alignment_OptionalFields_BOPT(..),
+                                                               BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Int8(..),
+                                                               BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Word8(..),
+                                                               BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Int16(..),
+                                                               BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Word16(..),
+                                                               BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Int32(..),
+                                                               BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Word32(..),
+                                                               BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Float(..),
+                                                               BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_SumType(..)
+                                                             ) where
+
+import Data.ByteString hiding (count)
+import Data.Data
+import Data.Int
+import Data.Sequence
+import Data.Word
+import Generics.Deriving.Base
+
+-- | Custom BAM (version 1.6) @"BAM_V1_6_BAM_Alignment_OptionalFields_BOPT"@ data type.
+--
+-- See section 4.2 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data BAM_V1_6_BAM_Alignment_OptionalFields_BOPT = BAM_V1_6_BAM_Alignment_OptionalFields_BOPT
+  { bam_v1_6_bam_alignment_optionalfields_bopt_int8   :: Maybe BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Int8
+  , bam_v1_6_bam_alignment_optionalfields_bopt_word8  :: Maybe BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Word8
+  , bam_v1_6_bam_alignment_optionalfields_bopt_int16  :: Maybe BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Int16
+  , bam_v1_6_bam_alignment_optionalfields_bopt_word16 :: Maybe BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Word16
+  , bam_v1_6_bam_alignment_optionalfields_bopt_int32  :: Maybe BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Int32
+  , bam_v1_6_bam_alignment_optionalfields_bopt_word32 :: Maybe BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Word32
+  , bam_v1_6_bam_alignment_optionalfields_bopt_float  :: Maybe BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Float
+  } deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_BAM_Alignment_OptionalFields_BOPT where
+  BAM_V1_6_BAM_Alignment_OptionalFields_BOPT bam_v1_6_bam_alignment_optionalfields_bopt_int81
+                                             bam_v1_6_bam_alignment_optionalfields_bopt_word81
+                                             bam_v1_6_bam_alignment_optionalfields_bopt_int161
+                                             bam_v1_6_bam_alignment_optionalfields_bopt_word161
+                                             bam_v1_6_bam_alignment_optionalfields_bopt_int321
+                                             bam_v1_6_bam_alignment_optionalfields_bopt_word321
+                                             bam_v1_6_bam_alignment_optionalfields_bopt_float1 ==
+    BAM_V1_6_BAM_Alignment_OptionalFields_BOPT bam_v1_6_bam_alignment_optionalfields_bopt_int82
+                                               bam_v1_6_bam_alignment_optionalfields_bopt_word82
+                                               bam_v1_6_bam_alignment_optionalfields_bopt_int162
+                                               bam_v1_6_bam_alignment_optionalfields_bopt_word162
+                                               bam_v1_6_bam_alignment_optionalfields_bopt_int322
+                                               bam_v1_6_bam_alignment_optionalfields_bopt_word322
+                                               bam_v1_6_bam_alignment_optionalfields_bopt_float2 =
+      bam_v1_6_bam_alignment_optionalfields_bopt_int81   == bam_v1_6_bam_alignment_optionalfields_bopt_int82   &&
+      bam_v1_6_bam_alignment_optionalfields_bopt_word81  == bam_v1_6_bam_alignment_optionalfields_bopt_word82  &&
+      bam_v1_6_bam_alignment_optionalfields_bopt_int161  == bam_v1_6_bam_alignment_optionalfields_bopt_int162  &&
+      bam_v1_6_bam_alignment_optionalfields_bopt_word161 == bam_v1_6_bam_alignment_optionalfields_bopt_word162 &&
+      bam_v1_6_bam_alignment_optionalfields_bopt_int321  == bam_v1_6_bam_alignment_optionalfields_bopt_int322  &&
+      bam_v1_6_bam_alignment_optionalfields_bopt_word321 == bam_v1_6_bam_alignment_optionalfields_bopt_word322 &&
+      bam_v1_6_bam_alignment_optionalfields_bopt_float1  == bam_v1_6_bam_alignment_optionalfields_bopt_float2
+
+instance Show BAM_V1_6_BAM_Alignment_OptionalFields_BOPT where
+  show (BAM_V1_6_BAM_Alignment_OptionalFields_BOPT int8
+                                                   word8
+                                                   int16
+                                                   word16
+                                                   int32
+                                                   word32
+                                                   float
+       ) =
+    "BAM_V1_6_BAM_Alignment_OptionalFields_BOPT { "           ++
+    "bam_v1_6_bam_alignment_optionalfields_bopt_int8 = "      ++
+    (show int8)                                               ++
+    " , bam_v1_6_bam_alignment_optionalfields_bopt_word8 = "  ++
+    (show word8)                                              ++
+    " , bam_v1_6_bam_alignment_optionalfields_bopt_int16 = "  ++
+    (show int16)                                              ++
+    " , bam_v1_6_bam_alignment_optionalfields_bopt_word16 = " ++
+    (show word16)                                             ++
+    " , bam_v1_6_bam_alignment_optionalfields_bopt_int32 = "  ++
+    (show int32)                                              ++
+    " , bam_v1_6_bam_alignment_optionalfields_bopt_word32 = " ++
+    (show word32)                                             ++
+    " , bam_v1_6_bam_alignment_optionalfields_bopt_float = "  ++
+    (show float)                                              ++
+    " }"
+
+-- | __c__CsSiIf of the last optional field (type B).
+--
+-- See section 4.2 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Int8 = BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Int8
+  { bam_v1_6_bam_alignment_optionalfields_bopt_int8_tag   :: ByteString
+  , bam_v1_6_bam_alignment_optionalfields_bopt_int8_type  :: ByteString
+  , bam_v1_6_bam_alignment_optionalfields_bopt_int8_count :: Word32
+  , bam_v1_6_bam_alignment_optionalfields_bopt_int8_value :: Seq Int8
+  } deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Int8 where
+  BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Int8 bam_v1_6_bam_alignment_optionalfields_bopt_int8_tag1
+                                                  bam_v1_6_bam_alignment_optionalfields_bopt_int8_type1
+                                                  bam_v1_6_bam_alignment_optionalfields_bopt_int8_count1
+                                                  bam_v1_6_bam_alignment_optionalfields_bopt_int8_value1 ==
+    BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Int8 bam_v1_6_bam_alignment_optionalfields_bopt_int8_tag2
+                                                    bam_v1_6_bam_alignment_optionalfields_bopt_int8_type2
+                                                    bam_v1_6_bam_alignment_optionalfields_bopt_int8_count2
+                                                    bam_v1_6_bam_alignment_optionalfields_bopt_int8_value2 =
+      bam_v1_6_bam_alignment_optionalfields_bopt_int8_tag1 == bam_v1_6_bam_alignment_optionalfields_bopt_int8_tag2     &&
+      bam_v1_6_bam_alignment_optionalfields_bopt_int8_type1 == bam_v1_6_bam_alignment_optionalfields_bopt_int8_type2   &&
+      bam_v1_6_bam_alignment_optionalfields_bopt_int8_count1 == bam_v1_6_bam_alignment_optionalfields_bopt_int8_count2 &&
+      bam_v1_6_bam_alignment_optionalfields_bopt_int8_value1 == bam_v1_6_bam_alignment_optionalfields_bopt_int8_value2
+
+instance Show BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Int8 where
+  show (BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Int8 tag
+                                                        bopttype
+                                                        count
+                                                        value
+       ) =
+    "BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Int8 { "          ++
+    "bam_v1_6_bam_alignment_optionalfields_bopt_int8_tag  = "     ++
+    (show tag)                                                    ++
+    " , bam_v1_6_bam_alignment_optionalfields_bopt_int8_type = "  ++
+    (show bopttype)                                               ++
+    " , bam_v1_6_bam_alignment_optionalfields_bopt_int8_count = " ++
+    (show count)                                                  ++
+    " , bam_v1_6_bam_alignment_optionalfields_bopt_int8_value = " ++
+    (show value)                                                  ++
+    " }"
+
+-- | c__C__sSiIf of the last optional field (type B).
+--
+-- See section 4.2 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Word8 = BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Word8
+  { bam_v1_6_bam_alignment_optionalfields_bopt_word8_tag   :: ByteString
+  , bam_v1_6_bam_alignment_optionalfields_bopt_word8_type  :: ByteString
+  , bam_v1_6_bam_alignment_optionalfields_bopt_word8_count :: Word32
+  , bam_v1_6_bam_alignment_optionalfields_bopt_word8_value :: Seq Word8
+  } deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Word8 where
+  BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Word8 bam_v1_6_bam_alignment_optionalfields_bopt_word8_tag1
+                                                   bam_v1_6_bam_alignment_optionalfields_bopt_word8_type1
+                                                   bam_v1_6_bam_alignment_optionalfields_bopt_word8_count1
+                                                   bam_v1_6_bam_alignment_optionalfields_bopt_word8_value1 ==
+    BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Word8 bam_v1_6_bam_alignment_optionalfields_bopt_word8_tag2
+                                                     bam_v1_6_bam_alignment_optionalfields_bopt_word8_type2
+                                                     bam_v1_6_bam_alignment_optionalfields_bopt_word8_count2
+                                                     bam_v1_6_bam_alignment_optionalfields_bopt_word8_value2 =
+      bam_v1_6_bam_alignment_optionalfields_bopt_word8_tag1 == bam_v1_6_bam_alignment_optionalfields_bopt_word8_tag2     &&
+      bam_v1_6_bam_alignment_optionalfields_bopt_word8_type1 == bam_v1_6_bam_alignment_optionalfields_bopt_word8_type2   &&
+      bam_v1_6_bam_alignment_optionalfields_bopt_word8_count1 == bam_v1_6_bam_alignment_optionalfields_bopt_word8_count2 &&
+      bam_v1_6_bam_alignment_optionalfields_bopt_word8_value1 == bam_v1_6_bam_alignment_optionalfields_bopt_word8_value2
+
+instance Show BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Word8 where
+  show (BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Word8 tag
+                                                         bopttype
+                                                         count
+                                                         value
+       ) =
+    "BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Word8 { "          ++
+    "bam_v1_6_bam_alignment_optionalfields_bopt_word8_tag  = "     ++
+    (show tag)                                                     ++
+    " , bam_v1_6_bam_alignment_optionalfields_bopt_word8_type = "  ++
+    (show bopttype)                                                ++
+    " , bam_v1_6_bam_alignment_optionalfields_bopt_word8_count = " ++
+    (show count)                                                   ++
+    " , bam_v1_6_bam_alignment_optionalfields_bopt_word8_value = " ++
+    (show value)                                                   ++
+    " }"
+
+-- | cC__s__SiIf of the last optional field (type B).
+--
+-- See section 4.2 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Int16 = BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Int16
+  { bam_v1_6_bam_alignment_optionalfields_bopt_int16_tag   :: ByteString
+  , bam_v1_6_bam_alignment_optionalfields_bopt_int16_type  :: ByteString
+  , bam_v1_6_bam_alignment_optionalfields_bopt_int16_count :: Word32
+  , bam_v1_6_bam_alignment_optionalfields_bopt_int16_value :: Seq Int16
+  } deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Int16 where
+  BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Int16 bam_v1_6_bam_alignment_optionalfields_bopt_int16_tag1
+                                                   bam_v1_6_bam_alignment_optionalfields_bopt_int16_type1
+                                                   bam_v1_6_bam_alignment_optionalfields_bopt_int16_count1
+                                                   bam_v1_6_bam_alignment_optionalfields_bopt_int16_value1 ==
+    BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Int16 bam_v1_6_bam_alignment_optionalfields_bopt_int16_tag2
+                                                     bam_v1_6_bam_alignment_optionalfields_bopt_int16_type2
+                                                     bam_v1_6_bam_alignment_optionalfields_bopt_int16_count2
+                                                     bam_v1_6_bam_alignment_optionalfields_bopt_int16_value2 =
+      bam_v1_6_bam_alignment_optionalfields_bopt_int16_tag1 == bam_v1_6_bam_alignment_optionalfields_bopt_int16_tag2     &&
+      bam_v1_6_bam_alignment_optionalfields_bopt_int16_type1 == bam_v1_6_bam_alignment_optionalfields_bopt_int16_type2   &&
+      bam_v1_6_bam_alignment_optionalfields_bopt_int16_count1 == bam_v1_6_bam_alignment_optionalfields_bopt_int16_count2 &&
+      bam_v1_6_bam_alignment_optionalfields_bopt_int16_value1 == bam_v1_6_bam_alignment_optionalfields_bopt_int16_value2
+
+instance Show BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Int16 where
+  show (BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Int16 tag
+                                                         bopttype
+                                                         count
+                                                         value
+       ) =
+    "BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Int16 { "          ++
+    "bam_v1_6_bam_alignment_optionalfields_bopt_int16_tag  = "     ++
+    (show tag)                                                     ++
+    " , bam_v1_6_bam_alignment_optionalfields_bopt_int16_type = "  ++
+    (show bopttype)                                                ++
+    " , bam_v1_6_bam_alignment_optionalfields_bopt_int16_count = " ++
+    (show count)                                                   ++
+    " , bam_v1_6_bam_alignment_optionalfields_bopt_int16_value = " ++
+    (show value)                                                   ++
+    " }"
+
+-- | cCs__S__iIf of the last optional field (type B).
+--
+-- See section 4.2 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Word16 = BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Word16
+  { bam_v1_6_bam_alignment_optionalfields_bopt_word16_tag   :: ByteString
+  , bam_v1_6_bam_alignment_optionalfields_bopt_word16_type  :: ByteString
+  , bam_v1_6_bam_alignment_optionalfields_bopt_word16_count :: Word32
+  , bam_v1_6_bam_alignment_optionalfields_bopt_word16_value :: Seq Word16
+  } deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Word16 where
+  BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Word16 bam_v1_6_bam_alignment_optionalfields_bopt_word16_tag1
+                                                    bam_v1_6_bam_alignment_optionalfields_bopt_word16_type1
+                                                    bam_v1_6_bam_alignment_optionalfields_bopt_word16_count1
+                                                    bam_v1_6_bam_alignment_optionalfields_bopt_word16_value1 ==
+    BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Word16 bam_v1_6_bam_alignment_optionalfields_bopt_word16_tag2
+                                                      bam_v1_6_bam_alignment_optionalfields_bopt_word16_type2
+                                                      bam_v1_6_bam_alignment_optionalfields_bopt_word16_count2
+                                                      bam_v1_6_bam_alignment_optionalfields_bopt_word16_value2 =
+      bam_v1_6_bam_alignment_optionalfields_bopt_word16_tag1 == bam_v1_6_bam_alignment_optionalfields_bopt_word16_tag2     &&
+      bam_v1_6_bam_alignment_optionalfields_bopt_word16_type1 == bam_v1_6_bam_alignment_optionalfields_bopt_word16_type2   &&
+      bam_v1_6_bam_alignment_optionalfields_bopt_word16_count1 == bam_v1_6_bam_alignment_optionalfields_bopt_word16_count2 &&
+      bam_v1_6_bam_alignment_optionalfields_bopt_word16_value1 == bam_v1_6_bam_alignment_optionalfields_bopt_word16_value2
+
+instance Show BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Word16 where
+  show (BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Word16 tag
+                                                          bopttype
+                                                          count
+                                                          value
+       ) =
+    "BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Word16 { "          ++
+    "bam_v1_6_bam_alignment_optionalfields_bopt_word16_tag  = "     ++
+    (show tag)                                                      ++
+    " , bam_v1_6_bam_alignment_optionalfields_bopt_word16_type = "  ++
+    (show bopttype)                                                 ++
+    " , bam_v1_6_bam_alignment_optionalfields_bopt_word16_count = " ++
+    (show count)                                                    ++
+    " , bam_v1_6_bam_alignment_optionalfields_bopt_word16_value = " ++
+    (show value)                                                    ++
+    " }"
+
+-- | cCsS__i__If of the last optional field (type B).
+--
+-- See section 4.2 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Int32 = BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Int32
+  { bam_v1_6_bam_alignment_optionalfields_bopt_int32_tag   :: ByteString
+  , bam_v1_6_bam_alignment_optionalfields_bopt_int32_type  :: ByteString
+  , bam_v1_6_bam_alignment_optionalfields_bopt_int32_count :: Word32
+  , bam_v1_6_bam_alignment_optionalfields_bopt_int32_value :: Seq Int32
+  } deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Int32 where
+  BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Int32 bam_v1_6_bam_alignment_optionalfields_bopt_int32_tag1
+                                                   bam_v1_6_bam_alignment_optionalfields_bopt_int32_type1
+                                                   bam_v1_6_bam_alignment_optionalfields_bopt_int32_count1
+                                                   bam_v1_6_bam_alignment_optionalfields_bopt_int32_value1 ==
+    BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Int32 bam_v1_6_bam_alignment_optionalfields_bopt_int32_tag2
+                                                     bam_v1_6_bam_alignment_optionalfields_bopt_int32_type2
+                                                     bam_v1_6_bam_alignment_optionalfields_bopt_int32_count2
+                                                     bam_v1_6_bam_alignment_optionalfields_bopt_int32_value2 =
+      bam_v1_6_bam_alignment_optionalfields_bopt_int32_tag1 == bam_v1_6_bam_alignment_optionalfields_bopt_int32_tag2     &&
+      bam_v1_6_bam_alignment_optionalfields_bopt_int32_type1 == bam_v1_6_bam_alignment_optionalfields_bopt_int32_type2   &&
+      bam_v1_6_bam_alignment_optionalfields_bopt_int32_count1 == bam_v1_6_bam_alignment_optionalfields_bopt_int32_count2 &&
+      bam_v1_6_bam_alignment_optionalfields_bopt_int32_value1 == bam_v1_6_bam_alignment_optionalfields_bopt_int32_value2
+
+instance Show BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Int32 where
+  show (BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Int32 tag
+                                                         bopttype
+                                                         count
+                                                         value
+       ) =
+    "BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Int32 { "          ++
+    "bam_v1_6_bam_alignment_optionalfields_bopt_int32_tag  = "     ++
+    (show tag)                                                     ++
+    " , bam_v1_6_bam_alignment_optionalfields_bopt_int32_type = "  ++
+    (show bopttype)                                                ++
+    " , bam_v1_6_bam_alignment_optionalfields_bopt_int32_count = " ++
+    (show count)                                                   ++
+    " , bam_v1_6_bam_alignment_optionalfields_bopt_int32_value = " ++
+    (show value)                                                   ++
+    " }"
+
+-- | cCsSi__I__f of the last optional field (type B).
+--
+-- See section 4.2 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Word32 = BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Word32
+  { bam_v1_6_bam_alignment_optionalfields_bopt_word32_tag   :: ByteString
+  , bam_v1_6_bam_alignment_optionalfields_bopt_word32_type  :: ByteString
+  , bam_v1_6_bam_alignment_optionalfields_bopt_word32_count :: Word32
+  , bam_v1_6_bam_alignment_optionalfields_bopt_word32_value :: Seq Word32
+  } deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Word32 where
+  BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Word32 bam_v1_6_bam_alignment_optionalfields_bopt_word32_tag1
+                                                    bam_v1_6_bam_alignment_optionalfields_bopt_word32_type1
+                                                    bam_v1_6_bam_alignment_optionalfields_bopt_word32_count1
+                                                    bam_v1_6_bam_alignment_optionalfields_bopt_word32_value1 ==
+    BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Word32 bam_v1_6_bam_alignment_optionalfields_bopt_word32_tag2
+                                                      bam_v1_6_bam_alignment_optionalfields_bopt_word32_type2
+                                                      bam_v1_6_bam_alignment_optionalfields_bopt_word32_count2
+                                                      bam_v1_6_bam_alignment_optionalfields_bopt_word32_value2 =
+      bam_v1_6_bam_alignment_optionalfields_bopt_word32_tag1 == bam_v1_6_bam_alignment_optionalfields_bopt_word32_tag2     &&
+      bam_v1_6_bam_alignment_optionalfields_bopt_word32_type1 == bam_v1_6_bam_alignment_optionalfields_bopt_word32_type2   &&
+      bam_v1_6_bam_alignment_optionalfields_bopt_word32_count1 == bam_v1_6_bam_alignment_optionalfields_bopt_word32_count2 &&
+      bam_v1_6_bam_alignment_optionalfields_bopt_word32_value1 == bam_v1_6_bam_alignment_optionalfields_bopt_word32_value2
+
+instance Show BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Word32 where
+  show (BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Word32 tag
+                                                          bopttype
+                                                          count
+                                                          value
+       ) =
+    "BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Word32 { "          ++
+    "bam_v1_6_bam_alignment_optionalfields_bopt_word32_tag  = "     ++
+    (show tag)                                                      ++
+    " , bam_v1_6_bam_alignment_optionalfields_bopt_word32_type = "  ++
+    (show bopttype)                                                 ++
+    " , bam_v1_6_bam_alignment_optionalfields_bopt_word32_count = " ++
+    (show count)                                                    ++
+    " , bam_v1_6_bam_alignment_optionalfields_bopt_word32_value = " ++
+    (show value)                                                    ++
+    " }"
+
+-- | cCsSiI__f__ of the last optional field (type B).
+--
+-- See section 4.2 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Float = BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Float
+  { bam_v1_6_bam_alignment_optionalfields_bopt_float_tag   :: ByteString
+  , bam_v1_6_bam_alignment_optionalfields_bopt_float_type  :: ByteString
+  , bam_v1_6_bam_alignment_optionalfields_bopt_float_count :: Word32
+  , bam_v1_6_bam_alignment_optionalfields_bopt_float_value :: Seq Float
+  } deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Float where
+  BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Float bam_v1_6_bam_alignment_optionalfields_bopt_float_tag1
+                                                   bam_v1_6_bam_alignment_optionalfields_bopt_float_type1
+                                                   bam_v1_6_bam_alignment_optionalfields_bopt_float_count1
+                                                   bam_v1_6_bam_alignment_optionalfields_bopt_float_value1 ==
+    BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Float bam_v1_6_bam_alignment_optionalfields_bopt_float_tag2
+                                                     bam_v1_6_bam_alignment_optionalfields_bopt_float_type2
+                                                     bam_v1_6_bam_alignment_optionalfields_bopt_float_count2
+                                                     bam_v1_6_bam_alignment_optionalfields_bopt_float_value2 =
+      bam_v1_6_bam_alignment_optionalfields_bopt_float_tag1   == bam_v1_6_bam_alignment_optionalfields_bopt_float_tag2   &&
+      bam_v1_6_bam_alignment_optionalfields_bopt_float_type1  == bam_v1_6_bam_alignment_optionalfields_bopt_float_type2  &&
+      bam_v1_6_bam_alignment_optionalfields_bopt_float_count1 == bam_v1_6_bam_alignment_optionalfields_bopt_float_count2 &&
+      bam_v1_6_bam_alignment_optionalfields_bopt_float_value1 == bam_v1_6_bam_alignment_optionalfields_bopt_float_value2
+
+instance Show BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Float where
+  show (BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Float tag
+                                                         bopttype
+                                                         count
+                                                         value
+       ) =
+    "BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Float { "          ++
+    "bam_v1_6_bam_alignment_optionalfields_bopt_float_tag  = "     ++
+    (show tag)                                                     ++
+    " , bam_v1_6_bam_alignment_optionalfields_bopt_float_type = "  ++
+    (show bopttype)                                                ++
+    " , bam_v1_6_bam_alignment_optionalfields_bopt_float_count = " ++
+    (show count)                                                   ++
+    " , bam_v1_6_bam_alignment_optionalfields_bopt_float_value = " ++
+    (show value)                                                   ++
+    " }"
+
+-- | Sum type that can represent any of the
+-- BAM_V1_6_BAM_Alignment_OptionalFields_BOPT types.
+data BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_SumType =
+    BOPTInt8
+  | BOPTWord8
+  | BOPTInt16
+  | BOPTWord16
+  | BOPTInt32
+  | BOPTWord32
+  | BOPTFloat
+  | BOPTEmpty
+  deriving (Eq,Generic,Typeable)
diff --git a/src/Data/BAM/Version1_6/BAM/Alignment/OptionalFields/Base.hs b/src/Data/BAM/Version1_6/BAM/Alignment/OptionalFields/Base.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/BAM/Alignment/OptionalFields/Base.hs
@@ -0,0 +1,158 @@
+{-# LANGUAGE DeriveDataTypeable          #-}
+{-# LANGUAGE DeriveGeneric               #-}
+{-# LANGUAGE FlexibleContexts            #-}
+{-# LANGUAGE FlexibleInstances           #-}
+{-# LANGUAGE MultiParamTypeClasses       #-}
+{-# LANGUAGE OverloadedStrings           #-}
+{-# LANGUAGE StrictData                  #-}
+{-# LANGUAGE TypeFamilies                #-}
+{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.BAM.Alignment.OptionalFields.Base
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.BAM.Alignment.OptionalFields.Base ( -- * BAM version 1.6 alignment optional fields data type
+                                                               BAM_V1_6_BAM_Alignment_OptionalFields(..)
+                                                             , BAM_V1_6_BAM_Alignment_OptionalFields_SumType(..)
+                                                             ) where
+
+import Data.BAM.Version1_6.BAM.Alignment.OptionalFields.AOPT
+import Data.BAM.Version1_6.BAM.Alignment.OptionalFields.BigCOPT
+import Data.BAM.Version1_6.BAM.Alignment.OptionalFields.BigIOPT
+import Data.BAM.Version1_6.BAM.Alignment.OptionalFields.BigSOPT
+import Data.BAM.Version1_6.BAM.Alignment.OptionalFields.SmallCOPT
+import Data.BAM.Version1_6.BAM.Alignment.OptionalFields.SmallIOPT
+import Data.BAM.Version1_6.BAM.Alignment.OptionalFields.SmallSOPT
+import Data.BAM.Version1_6.BAM.Alignment.OptionalFields.FOPT
+import Data.BAM.Version1_6.BAM.Alignment.OptionalFields.ZOPT
+import Data.BAM.Version1_6.BAM.Alignment.OptionalFields.HOPT
+import Data.BAM.Version1_6.BAM.Alignment.OptionalFields.BOPT
+
+import Data.Data
+import Generics.Deriving.Base
+
+-- | Custom BAM (version 1.6) @"BAM_V1_6_BAM_Alignment_Optional_Fields"@ data type.
+--
+-- See section 4.2 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data BAM_V1_6_BAM_Alignment_OptionalFields = BAM_V1_6_BAM_Alignment_OptionalFields
+  { bam_v1_6_bam_alignment_optionalfields_aopt        :: Maybe BAM_V1_6_BAM_Alignment_OptionalFields_AOPT      -- ^ A - [!-~] -
+                                                                                                               -- Printable character.
+  , bam_v1_6_bam_alignment_optionalfields_smallcopt   :: Maybe BAM_V1_6_BAM_Alignment_OptionalFields_SmallCOPT -- c - [0-9]+ -
+                                                                                                               -- Int8 (signed).
+  , bam_v1_6_bam_alignment_optionalfields_bigcopt     :: Maybe BAM_V1_6_BAM_Alignment_OptionalFields_BigCOPT   -- C - [0-9]+ -
+                                                                                                               -- Word8 (unsigned).
+  , bam_v1_6_bam_alignment_optionalfields_smalliopt   :: Maybe BAM_V1_6_BAM_Alignment_OptionalFields_SmallIOPT -- i - [0-9]+ -
+                                                                                                               -- Int32 (signed).
+  , bam_v1_6_bam_alignment_optionalfields_bigiopt     :: Maybe BAM_V1_6_BAM_Alignment_OptionalFields_BigIOPT   -- I - [0-9]+ -
+                                                                                                               -- Word32 (unsigned).
+  , bam_v1_6_bam_alignment_optionalfields_smallsopt   :: Maybe BAM_V1_6_BAM_Alignment_OptionalFields_SmallSOPT -- s - [0-9]+ -
+                                                                                                               -- Int16 (signed).
+  , bam_v1_6_bam_alignment_optionalfields_bigsopt     :: Maybe BAM_V1_6_BAM_Alignment_OptionalFields_BigSOPT   -- S - [0-9]+ -
+                                                                                                               -- Word16 (unsigned).
+  , bam_v1_6_bam_alignment_optionalfields_fopt        :: Maybe BAM_V1_6_BAM_Alignment_OptionalFields_FOPT      -- ^ f - [-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)? -
+                                                                                                               -- Single-precision floating number.
+  , bam_v1_6_bam_alignment_optionalfields_zopt        :: Maybe BAM_V1_6_BAM_Alignment_OptionalFields_ZOPT      -- ^ Z - [ !-~]* -
+                                                                                                               -- Printable string, including space.
+  , bam_v1_6_bam_alignment_optionalfields_hopt        :: Maybe BAM_V1_6_BAM_Alignment_OptionalFields_HOPT      -- ^ H - ([0-9A-F][0-9A-F])* -
+                                                                                                               -- Byte array in the Hex format.
+  , bam_v1_6_bam_alignment_optionalfields_bopt        :: Maybe BAM_V1_6_BAM_Alignment_OptionalFields_BOPT      -- ^ B - [cCsSiIf]&#8203;(,[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)* -
+                                                                                                               -- Integer or numeric array.
+  } deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_BAM_Alignment_OptionalFields where
+  BAM_V1_6_BAM_Alignment_OptionalFields bam_v1_6_bam_alignment_optionalfields_aopt1
+                                        bam_v1_6_bam_alignment_optionalfields_smallcopt1
+                                        bam_v1_6_bam_alignment_optionalfields_bigcopt1
+                                        bam_v1_6_bam_alignment_optionalfields_smalliopt1
+                                        bam_v1_6_bam_alignment_optionalfields_bigiopt1
+                                        bam_v1_6_bam_alignment_optionalfields_smallsopt1
+                                        bam_v1_6_bam_alignment_optionalfields_bigsopt1
+                                        bam_v1_6_bam_alignment_optionalfields_fopt1
+                                        bam_v1_6_bam_alignment_optionalfields_zopt1
+                                        bam_v1_6_bam_alignment_optionalfields_hopt1
+                                        bam_v1_6_bam_alignment_optionalfields_bopt1 ==
+    BAM_V1_6_BAM_Alignment_OptionalFields bam_v1_6_bam_alignment_optionalfields_aopt2
+                                          bam_v1_6_bam_alignment_optionalfields_smallcopt2
+                                          bam_v1_6_bam_alignment_optionalfields_bigcopt2
+                                          bam_v1_6_bam_alignment_optionalfields_smalliopt2
+                                          bam_v1_6_bam_alignment_optionalfields_bigiopt2
+                                          bam_v1_6_bam_alignment_optionalfields_smallsopt2
+                                          bam_v1_6_bam_alignment_optionalfields_bigsopt2
+                                          bam_v1_6_bam_alignment_optionalfields_fopt2
+                                          bam_v1_6_bam_alignment_optionalfields_zopt2
+                                          bam_v1_6_bam_alignment_optionalfields_hopt2
+                                          bam_v1_6_bam_alignment_optionalfields_bopt2 =
+      bam_v1_6_bam_alignment_optionalfields_aopt1      ==  bam_v1_6_bam_alignment_optionalfields_aopt2        &&
+      bam_v1_6_bam_alignment_optionalfields_smallcopt1 ==  bam_v1_6_bam_alignment_optionalfields_smallcopt2   &&
+      bam_v1_6_bam_alignment_optionalfields_bigcopt1   ==  bam_v1_6_bam_alignment_optionalfields_bigcopt2     &&
+      bam_v1_6_bam_alignment_optionalfields_smalliopt1 ==  bam_v1_6_bam_alignment_optionalfields_smalliopt2   &&
+      bam_v1_6_bam_alignment_optionalfields_bigiopt1   ==  bam_v1_6_bam_alignment_optionalfields_bigiopt2     &&
+      bam_v1_6_bam_alignment_optionalfields_smallsopt1 ==  bam_v1_6_bam_alignment_optionalfields_smallsopt2   &&
+      bam_v1_6_bam_alignment_optionalfields_bigsopt1   ==  bam_v1_6_bam_alignment_optionalfields_bigsopt2     &&
+      bam_v1_6_bam_alignment_optionalfields_fopt1      ==  bam_v1_6_bam_alignment_optionalfields_fopt2        &&
+      bam_v1_6_bam_alignment_optionalfields_zopt1      ==  bam_v1_6_bam_alignment_optionalfields_zopt2        &&
+      bam_v1_6_bam_alignment_optionalfields_hopt1      ==  bam_v1_6_bam_alignment_optionalfields_hopt2        &&
+      bam_v1_6_bam_alignment_optionalfields_bopt1      ==  bam_v1_6_bam_alignment_optionalfields_bopt2
+
+instance Show BAM_V1_6_BAM_Alignment_OptionalFields where
+  show ( BAM_V1_6_BAM_Alignment_OptionalFields aopt
+                                                smallcopt
+                                                bigcopt
+                                                smalliopt
+                                                bigiopt
+                                                smallsopt
+                                                bigsopt
+                                                fopt
+                                                zopt
+                                                hopt
+                                                bopt
+       ) =
+    "BAM_V1_6_BAM_Alignment_OptionalFields { "             ++
+    "bam_v1_6_bam_alignment_optionalfields_aopt = "         ++
+    (show aopt)                                             ++
+    " , bam_v1_6_bam_alignment_optionalfields_smallcopt = " ++
+    (show smallcopt)                                        ++
+    " , bam_v1_6_bam_alignment_optionalfields_bigcopt = "   ++
+    (show bigcopt)                                          ++
+    " , bam_v1_6_bam_alignment_optionalfields_smalliopt = " ++
+    (show smalliopt)                                        ++
+    " , bam_v1_6_bam_alignment_optionalfields_bigiopt = "   ++
+    (show bigiopt)                                          ++
+    " , bam_v1_6_bam_alignment_optionalfields_smallsopt = " ++
+    (show smallsopt)                                        ++
+    " , bam_v1_6_bam_alignment_optionalfields_bigsopt = "   ++
+    (show bigsopt)                                          ++
+    " , bam_v1_6_bam_alignment_optionalfields_fopt = "      ++
+    (show fopt)                                             ++
+    " , bam_v1_6_bam_alignment_optionalfields_zopt = "      ++
+    (show zopt)                                             ++
+    " , bam_v1_6_bam_alignment_optionalfields_hopt = "      ++
+    (show hopt)                                             ++
+    " , bam_v1_6_bam_alignment_optionalfields_bopt = "      ++
+    (show bopt)                                             ++
+    " }"
+
+-- | Sum type that can represent any of the
+-- BAM_V1_6_BAM_Alignment_OptionalFields types.
+data BAM_V1_6_BAM_Alignment_OptionalFields_SumType =
+    AOPT
+  | SmallCOPT
+  | BigCOPT
+  | SmallIOPT
+  | BigIOPT
+  | SmallSOPT
+  | BigSOPT
+  | FOPT
+  | ZOPT
+  | HOPT
+  | BOPT
+  | Empty
+  deriving (Eq,Generic,Typeable)
diff --git a/src/Data/BAM/Version1_6/BAM/Alignment/OptionalFields/BigCOPT.hs b/src/Data/BAM/Version1_6/BAM/Alignment/OptionalFields/BigCOPT.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/BAM/Alignment/OptionalFields/BigCOPT.hs
@@ -0,0 +1,71 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE StrictData            #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.BAM.Alignment.OptionalFields.BigCOPT
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = WARNING
+--
+-- This module is considered __internal__.
+--
+-- The Package Versioning Policy __does not apply__.
+--
+-- The contents of this module may change __in any way whatsoever__
+-- and __without any warning__ between minor versions of this package.
+--
+-- Authors importing this library are expected to track development
+-- closely.
+--
+-- All credit goes to the author(s)/maintainer(s) of the
+-- [containers](https://hackage.haskell.org/package/containers) library
+-- for the above warning text.
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.BAM.Alignment.OptionalFields.BigCOPT ( -- * BAM version 1.6 alignment optional fields data type
+                                                                  BAM_V1_6_BAM_Alignment_OptionalFields_BigCOPT(..)
+                                                                ) where
+
+import Data.ByteString
+import Data.Word
+import Data.Data
+import Generics.Deriving.Base
+
+-- | Custom BAM (version 1.6) @"BAM_V1_6_Alignment_OptionalFields_BigCOPT"@ data type.
+--
+-- See section 4.2 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data BAM_V1_6_BAM_Alignment_OptionalFields_BigCOPT = BAM_V1_6_BAM_Alignment_OptionalFields_BigCOPT
+  { bam_v1_6_bam_alignment_optionalfields_bigcopt_tag   :: ByteString
+  , bam_v1_6_bam_alignment_optionalfields_bigcopt_value :: Word8
+  } deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_BAM_Alignment_OptionalFields_BigCOPT where
+  BAM_V1_6_BAM_Alignment_OptionalFields_BigCOPT bam_v1_6_bam_alignment_optionalfields_bigcopt_tag1
+                                                bam_v1_6_bam_alignment_optionalfields_bigcopt_value1 ==
+    BAM_V1_6_BAM_Alignment_OptionalFields_BigCOPT bam_v1_6_bam_alignment_optionalfields_bigcopt_tag2
+                                                  bam_v1_6_bam_alignment_optionalfields_bigcopt_value2 =
+      bam_v1_6_bam_alignment_optionalfields_bigcopt_tag1   == bam_v1_6_bam_alignment_optionalfields_bigcopt_tag2 &&
+      bam_v1_6_bam_alignment_optionalfields_bigcopt_value1 == bam_v1_6_bam_alignment_optionalfields_bigcopt_value2
+
+instance Show BAM_V1_6_BAM_Alignment_OptionalFields_BigCOPT where
+  show (BAM_V1_6_BAM_Alignment_OptionalFields_BigCOPT tag
+                                                      value
+       ) =
+    "BAM_V1_6_BAM_Alignment_OptionalFields_BigCOPT { "          ++
+    "bam_v1_6_bam_alignment_optionalfields_bigcopt_tag = "      ++
+    (show tag)                                                  ++
+    " , bam_v1_6_bam_alignment_optionalfields_bigcopt_value = " ++
+    (show value)                                                ++
+    " }"
diff --git a/src/Data/BAM/Version1_6/BAM/Alignment/OptionalFields/BigIOPT.hs b/src/Data/BAM/Version1_6/BAM/Alignment/OptionalFields/BigIOPT.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/BAM/Alignment/OptionalFields/BigIOPT.hs
@@ -0,0 +1,71 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE StrictData            #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.BAM.Alignment.OptionalFields.BigIOPT
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = WARNING
+--
+-- This module is considered __internal__.
+--
+-- The Package Versioning Policy __does not apply__.
+--
+-- The contents of this module may change __in any way whatsoever__
+-- and __without any warning__ between minor versions of this package.
+--
+-- Authors importing this library are expected to track development
+-- closely.
+--
+-- All credit goes to the author(s)/maintainer(s) of the
+-- [containers](https://hackage.haskell.org/package/containers) library
+-- for the above warning text.
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.BAM.Alignment.OptionalFields.BigIOPT ( -- * BAM version 1.6 alignment optional fields data type
+                                                                  BAM_V1_6_BAM_Alignment_OptionalFields_BigIOPT(..)
+                                                                ) where
+
+import Data.ByteString
+import Data.Word
+import Data.Data
+import Generics.Deriving.Base
+
+-- | Custom BAM (version 1.6) @"BAM_V1_6_BAM_Alignment_OptionalFields_BigIOPT"@ data type.
+--
+-- See section 4.2 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data BAM_V1_6_BAM_Alignment_OptionalFields_BigIOPT = BAM_V1_6_BAM_Alignment_OptionalFields_BigIOPT
+  { bam_v1_6_bam_alignment_optionalfields_bigiopt_tag   :: ByteString
+  , bam_v1_6_bam_alignment_optionalfields_bigiopt_value :: Word32
+  } deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_BAM_Alignment_OptionalFields_BigIOPT where
+  BAM_V1_6_BAM_Alignment_OptionalFields_BigIOPT bam_v1_6_bam_alignment_optionalfields_bigiopt_tag1
+                                                bam_v1_6_bam_alignment_optionalfields_bigiopt_value1 ==
+    BAM_V1_6_BAM_Alignment_OptionalFields_BigIOPT bam_v1_6_bam_alignment_optionalfields_bigiopt_tag2
+                                                  bam_v1_6_bam_alignment_optionalfields_bigiopt_value2 =
+      bam_v1_6_bam_alignment_optionalfields_bigiopt_tag1   == bam_v1_6_bam_alignment_optionalfields_bigiopt_tag2 &&
+      bam_v1_6_bam_alignment_optionalfields_bigiopt_value1 == bam_v1_6_bam_alignment_optionalfields_bigiopt_value2
+
+instance Show BAM_V1_6_BAM_Alignment_OptionalFields_BigIOPT where
+  show (BAM_V1_6_BAM_Alignment_OptionalFields_BigIOPT tag
+                                                      value
+       ) =
+    "BAM_V1_6_BAM_Alignment_OptionalFields_BigIOPT { "          ++
+    "bam_v1_6_bam_alignment_optionalfields_bigiopt_tag = "      ++
+    (show tag)                                                  ++
+    " , bam_v1_6_bam_alignment_optionalfields_bigiopt_value = " ++
+    (show value)                                                ++
+    " }"
diff --git a/src/Data/BAM/Version1_6/BAM/Alignment/OptionalFields/BigSOPT.hs b/src/Data/BAM/Version1_6/BAM/Alignment/OptionalFields/BigSOPT.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/BAM/Alignment/OptionalFields/BigSOPT.hs
@@ -0,0 +1,71 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE StrictData            #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.BAM.Alignment.OptionalFields.BigSOPT
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = WARNING
+--
+-- This module is considered __internal__.
+--
+-- The Package Versioning Policy __does not apply__.
+--
+-- The contents of this module may change __in any way whatsoever__
+-- and __without any warning__ between minor versions of this package.
+--
+-- Authors importing this library are expected to track development
+-- closely.
+--
+-- All credit goes to the author(s)/maintainer(s) of the
+-- [containers](https://hackage.haskell.org/package/containers) library
+-- for the above warning text.
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.BAM.Alignment.OptionalFields.BigSOPT ( -- * BAM version 1.6 alignment optional fields data type
+                                                                  BAM_V1_6_BAM_Alignment_OptionalFields_BigSOPT(..)
+                                                                ) where
+
+import Data.ByteString
+import Data.Word
+import Data.Data
+import Generics.Deriving.Base
+
+-- | Custom BAM (version 1.6) @"BAM_V1_6_Alignment_OptionalFields_BigSOPT"@ data type.
+--
+-- See section 4.2 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data BAM_V1_6_BAM_Alignment_OptionalFields_BigSOPT = BAM_V1_6_BAM_Alignment_OptionalFields_BigSOPT
+  { bam_v1_6_bam_alignment_optionalfields_bigsopt_tag   :: ByteString
+  , bam_v1_6_bam_alignment_optionalfields_bigsopt_value :: Word16
+  } deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_BAM_Alignment_OptionalFields_BigSOPT where
+  BAM_V1_6_BAM_Alignment_OptionalFields_BigSOPT bam_v1_6_bam_alignment_optionalfields_bigsopt_tag1
+                                                bam_v1_6_bam_alignment_optionalfields_bigsopt_value1 ==
+    BAM_V1_6_BAM_Alignment_OptionalFields_BigSOPT bam_v1_6_bam_alignment_optionalfields_bigsopt_tag2
+                                                  bam_v1_6_bam_alignment_optionalfields_bigsopt_value2 =
+      bam_v1_6_bam_alignment_optionalfields_bigsopt_tag1   == bam_v1_6_bam_alignment_optionalfields_bigsopt_tag2 &&
+      bam_v1_6_bam_alignment_optionalfields_bigsopt_value1 == bam_v1_6_bam_alignment_optionalfields_bigsopt_value2
+
+instance Show BAM_V1_6_BAM_Alignment_OptionalFields_BigSOPT where
+  show (BAM_V1_6_BAM_Alignment_OptionalFields_BigSOPT tag
+                                                      value
+       ) =
+    "BAM_V1_6_BAM_Alignment_OptionalFields_BigSOPT { "          ++
+    "bam_v1_6_bam_alignment_optionalfields_bigsopt_tag = "      ++
+    (show tag)                                                  ++
+    " , bam_v1_6_bam_alignment_optionalfields_bigsopt_value = " ++
+    (show value)                                                ++
+    " }"
diff --git a/src/Data/BAM/Version1_6/BAM/Alignment/OptionalFields/FOPT.hs b/src/Data/BAM/Version1_6/BAM/Alignment/OptionalFields/FOPT.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/BAM/Alignment/OptionalFields/FOPT.hs
@@ -0,0 +1,71 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE StrictData            #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.BAM.Alignment.OptionalFields.FOPT
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = WARNING
+--
+-- This module is considered __internal__.
+--
+-- The Package Versioning Policy __does not apply__.
+--
+-- The contents of this module may change __in any way whatsoever__
+-- and __without any warning__ between minor versions of this package.
+--
+-- Authors importing this library are expected to track development
+-- closely.
+--
+-- All credit goes to the author(s)/maintainer(s) of the
+-- [containers](https://hackage.haskell.org/package/containers) library
+-- for the above warning text.
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.BAM.Alignment.OptionalFields.FOPT ( -- * BAM version 1.6 alignment optional fields data type
+                                                               BAM_V1_6_BAM_Alignment_OptionalFields_FOPT(..)
+                                                             ) where
+
+import Data.ByteString
+import Data.Word
+import Data.Data
+import Generics.Deriving.Base
+
+-- | Custom BAM (version 1.6) @"BAM_V1_6_Alignment_OptionalFields_FOPT"@ data type.
+--
+-- See section 4.2 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data BAM_V1_6_BAM_Alignment_OptionalFields_FOPT = BAM_V1_6_BAM_Alignment_OptionalFields_FOPT
+  { bam_v1_6_bam_alignment_optionalfields_fopt_tag   :: ByteString
+  , bam_v1_6_bam_alignment_optionalfields_fopt_value :: Word32
+  } deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_BAM_Alignment_OptionalFields_FOPT where
+  BAM_V1_6_BAM_Alignment_OptionalFields_FOPT bam_v1_6_bam_alignment_optionalfields_fopt_tag1
+                                             bam_v1_6_bam_alignment_optionalfields_fopt_value1 ==
+    BAM_V1_6_BAM_Alignment_OptionalFields_FOPT bam_v1_6_bam_alignment_optionalfields_fopt_tag2
+                                               bam_v1_6_bam_alignment_optionalfields_fopt_value2 =
+      bam_v1_6_bam_alignment_optionalfields_fopt_tag1 == bam_v1_6_bam_alignment_optionalfields_fopt_tag2 &&
+      bam_v1_6_bam_alignment_optionalfields_fopt_value1 == bam_v1_6_bam_alignment_optionalfields_fopt_value2
+
+instance Show BAM_V1_6_BAM_Alignment_OptionalFields_FOPT where
+  show (BAM_V1_6_BAM_Alignment_OptionalFields_FOPT tag
+                                                   value
+       ) =
+    "BAM_V1_6_BAM_Alignment_OptionalFields_FOPT { "          ++
+    "bam_v1_6_bam_alignment_optionalfields_fopt_tag = "      ++
+    (show tag)                                               ++
+    " , bam_v1_6_bam_alignment_optionalfields_fopt_value = " ++
+    (show value)                                             ++
+    " }"
diff --git a/src/Data/BAM/Version1_6/BAM/Alignment/OptionalFields/HOPT.hs b/src/Data/BAM/Version1_6/BAM/Alignment/OptionalFields/HOPT.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/BAM/Alignment/OptionalFields/HOPT.hs
@@ -0,0 +1,71 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE StrictData            #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.BAM.Alignment.OptionalFields.HOPT
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = WARNING
+--
+-- This module is considered __internal__.
+--
+-- The Package Versioning Policy __does not apply__.
+--
+-- The contents of this module may change __in any way whatsoever__
+-- and __without any warning__ between minor versions of this package.
+--
+-- Authors importing this library are expected to track development
+-- closely.
+--
+-- All credit goes to the author(s)/maintainer(s) of the
+-- [containers](https://hackage.haskell.org/package/containers) library
+-- for the above warning text.
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.BAM.Alignment.OptionalFields.HOPT ( -- * BAM version 1.6 alignment optional fields data type
+                                                               BAM_V1_6_BAM_Alignment_OptionalFields_HOPT(..)
+                                                             ) where
+
+import Data.ByteString (ByteString)
+import Data.Data
+import Data.Sequence
+import Generics.Deriving.Base
+
+-- | Custom BAM (version 1.6) @"BAM_V1_6_Alignment_OptionalFields_HOPT"@ data type.
+--
+-- See section 4.2 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data BAM_V1_6_BAM_Alignment_OptionalFields_HOPT = BAM_V1_6_BAM_Alignment_OptionalFields_HOPT
+  { bam_v1_6_bam_alignment_optionalfields_hopt_tag   :: ByteString
+  , bam_v1_6_bam_alignment_optionalfields_hopt_value :: Seq ByteString
+  } deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_BAM_Alignment_OptionalFields_HOPT where
+  BAM_V1_6_BAM_Alignment_OptionalFields_HOPT bam_v1_6_bam_alignment_optionalfields_hopt_tag1
+                                             bam_v1_6_bam_alignment_optionalfields_hopt_value1 ==
+    BAM_V1_6_BAM_Alignment_OptionalFields_HOPT bam_v1_6_bam_alignment_optionalfields_hopt_tag2
+                                               bam_v1_6_bam_alignment_optionalfields_hopt_value2 =
+      bam_v1_6_bam_alignment_optionalfields_hopt_tag1   == bam_v1_6_bam_alignment_optionalfields_hopt_tag2 &&
+      bam_v1_6_bam_alignment_optionalfields_hopt_value1 == bam_v1_6_bam_alignment_optionalfields_hopt_value2
+
+instance Show BAM_V1_6_BAM_Alignment_OptionalFields_HOPT where
+  show (BAM_V1_6_BAM_Alignment_OptionalFields_HOPT tag
+                                                   value
+       ) =
+    "BAM_V1_6_BAM_Alignment_OptionalFields_HOPT { "          ++
+    "bam_v1_6_bam_alignment_optionalfields_hopt_tag = "      ++
+    (show tag)                                               ++
+    " , bam_v1_6_bam_alignment_optionalfields_hopt_value = " ++
+    (show value)                                             ++
+    " }"
diff --git a/src/Data/BAM/Version1_6/BAM/Alignment/OptionalFields/SmallCOPT.hs b/src/Data/BAM/Version1_6/BAM/Alignment/OptionalFields/SmallCOPT.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/BAM/Alignment/OptionalFields/SmallCOPT.hs
@@ -0,0 +1,71 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE StrictData            #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.BAM.Alignment.OptionalFields.SmallCOPT
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = WARNING
+--
+-- This module is considered __internal__.
+--
+-- The Package Versioning Policy __does not apply__.
+--
+-- The contents of this module may change __in any way whatsoever__
+-- and __without any warning__ between minor versions of this package.
+--
+-- Authors importing this library are expected to track development
+-- closely.
+--
+-- All credit goes to the author(s)/maintainer(s) of the
+-- [containers](https://hackage.haskell.org/package/containers) library
+-- for the above warning text.
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.BAM.Alignment.OptionalFields.SmallCOPT ( -- * BAM version 1.6 alignment optional fields data type
+                                                                    BAM_V1_6_BAM_Alignment_OptionalFields_SmallCOPT(..)
+                                                                  ) where
+
+import Data.ByteString
+import Data.Int
+import Data.Data
+import Generics.Deriving.Base
+
+-- | Custom BAM (version 1.6) @"BAM_V1_6_Alignment_OptionalFields_SmallCOPT"@ data type.
+--
+-- See section 4.2 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data BAM_V1_6_BAM_Alignment_OptionalFields_SmallCOPT = BAM_V1_6_BAM_Alignment_OptionalFields_SmallCOPT
+  { bam_v1_6_bam_alignment_optionalfields_smallcopt_tag   :: ByteString
+  , bam_v1_6_bam_alignment_optionalfields_smallcopt_value :: Int8
+  } deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_BAM_Alignment_OptionalFields_SmallCOPT where
+  BAM_V1_6_BAM_Alignment_OptionalFields_SmallCOPT bam_v1_6_bam_alignment_optionalfields_smallcopt_tag1
+                                                  bam_v1_6_bam_alignment_optionalfields_smallcopt_value1 ==
+    BAM_V1_6_BAM_Alignment_OptionalFields_SmallCOPT bam_v1_6_bam_alignment_optionalfields_smallcopt_tag2
+                                                    bam_v1_6_bam_alignment_optionalfields_smallcopt_value2 =
+      bam_v1_6_bam_alignment_optionalfields_smallcopt_tag1   == bam_v1_6_bam_alignment_optionalfields_smallcopt_tag2 &&
+      bam_v1_6_bam_alignment_optionalfields_smallcopt_value1 == bam_v1_6_bam_alignment_optionalfields_smallcopt_value2
+
+instance Show BAM_V1_6_BAM_Alignment_OptionalFields_SmallCOPT where
+  show (BAM_V1_6_BAM_Alignment_OptionalFields_SmallCOPT tag
+                                                        value
+       ) =
+    "BAM_V1_6_BAM_Alignment_OptionalFields_SmallCOPT { "          ++
+    "bam_v1_6_bam_alignment_optionalfields_smallcopt_tag = "      ++
+    (show tag)                                                    ++
+    " , bam_v1_6_bam_alignment_optionalfields_smallcopt_value = " ++
+    (show value)                                                  ++
+    " }"
diff --git a/src/Data/BAM/Version1_6/BAM/Alignment/OptionalFields/SmallIOPT.hs b/src/Data/BAM/Version1_6/BAM/Alignment/OptionalFields/SmallIOPT.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/BAM/Alignment/OptionalFields/SmallIOPT.hs
@@ -0,0 +1,71 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE StrictData            #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.BAM.Alignment.OptionalFields.SmallIOPT
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = WARNING
+--
+-- This module is considered __internal__.
+--
+-- The Package Versioning Policy __does not apply__.
+--
+-- The contents of this module may change __in any way whatsoever__
+-- and __without any warning__ between minor versions of this package.
+--
+-- Authors importing this library are expected to track development
+-- closely.
+--
+-- All credit goes to the author(s)/maintainer(s) of the
+-- [containers](https://hackage.haskell.org/package/containers) library
+-- for the above warning text.
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.BAM.Alignment.OptionalFields.SmallIOPT ( -- * BAM version 1.6 alignment optional fields data type
+                                                                    BAM_V1_6_BAM_Alignment_OptionalFields_SmallIOPT(..)
+                                                                  ) where
+
+import Data.ByteString
+import Data.Int
+import Data.Data
+import Generics.Deriving.Base
+
+-- | Custom BAM (version 1.6) @"BAM_V1_6_BAM_Alignment_OptionalFields_SmallIOPT"@ data type.
+--
+-- See section 4.2 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data BAM_V1_6_BAM_Alignment_OptionalFields_SmallIOPT = BAM_V1_6_BAM_Alignment_OptionalFields_SmallIOPT
+  { bam_v1_6_bam_alignment_optionalfields_smalliopt_tag   :: ByteString
+  , bam_v1_6_bam_alignment_optionalfields_smalliopt_value :: Int32
+  } deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_BAM_Alignment_OptionalFields_SmallIOPT where
+  BAM_V1_6_BAM_Alignment_OptionalFields_SmallIOPT bam_v1_6_bam_alignment_optionalfields_smalliopt_tag1
+                                                  bam_v1_6_bam_alignment_optionalfields_smalliopt_value1 ==
+    BAM_V1_6_BAM_Alignment_OptionalFields_SmallIOPT bam_v1_6_bam_alignment_optionalfields_smalliopt_tag2
+                                                    bam_v1_6_bam_alignment_optionalfields_smalliopt_value2 =
+      bam_v1_6_bam_alignment_optionalfields_smalliopt_tag1   == bam_v1_6_bam_alignment_optionalfields_smalliopt_tag2 &&
+      bam_v1_6_bam_alignment_optionalfields_smalliopt_value1 == bam_v1_6_bam_alignment_optionalfields_smalliopt_value2
+
+instance Show BAM_V1_6_BAM_Alignment_OptionalFields_SmallIOPT where
+  show (BAM_V1_6_BAM_Alignment_OptionalFields_SmallIOPT tag
+                                                        value
+       ) =
+    "BAM_V1_6_BAM_Alignment_OptionalFields_SmallIOPT { "          ++
+    "bam_v1_6_bam_alignment_optionalfields_smalliopt_tag = "      ++
+    (show tag)                                                    ++
+    " , bam_v1_6_bam_alignment_optionalfields_smalliopt_value = " ++
+    (show value)                                                  ++
+    " }"
diff --git a/src/Data/BAM/Version1_6/BAM/Alignment/OptionalFields/SmallSOPT.hs b/src/Data/BAM/Version1_6/BAM/Alignment/OptionalFields/SmallSOPT.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/BAM/Alignment/OptionalFields/SmallSOPT.hs
@@ -0,0 +1,71 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE StrictData            #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.BAM.Alignment.OptionalFields.SmallSOPT
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = WARNING
+--
+-- This module is considered __internal__.
+--
+-- The Package Versioning Policy __does not apply__.
+--
+-- The contents of this module may change __in any way whatsoever__
+-- and __without any warning__ between minor versions of this package.
+--
+-- Authors importing this library are expected to track development
+-- closely.
+--
+-- All credit goes to the author(s)/maintainer(s) of the
+-- [containers](https://hackage.haskell.org/package/containers) library
+-- for the above warning text.
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.BAM.Alignment.OptionalFields.SmallSOPT ( -- * BAM version 1.6 alignment optional fields data type
+                                                                    BAM_V1_6_BAM_Alignment_OptionalFields_SmallSOPT(..)
+                                                                  ) where
+
+import Data.ByteString
+import Data.Int
+import Data.Data
+import Generics.Deriving.Base
+
+-- | Custom BAM (version 1.6) @"BAM_V1_6_Alignment_OptionalFields_SmallSOPT"@ data type.
+--
+-- See section 4.2 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data BAM_V1_6_BAM_Alignment_OptionalFields_SmallSOPT = BAM_V1_6_BAM_Alignment_OptionalFields_SmallSOPT
+  { bam_v1_6_bam_alignment_optionalfields_smallsopt_tag   :: ByteString
+  , bam_v1_6_bam_alignment_optionalfields_smallsopt_value :: Int16
+  } deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_BAM_Alignment_OptionalFields_SmallSOPT where
+  BAM_V1_6_BAM_Alignment_OptionalFields_SmallSOPT bam_v1_6_bam_alignment_optionalfields_smallsopt_tag1
+                                                  bam_v1_6_bam_alignment_optionalfields_smallsopt_value1 ==
+    BAM_V1_6_BAM_Alignment_OptionalFields_SmallSOPT bam_v1_6_bam_alignment_optionalfields_smallsopt_tag2
+                                                    bam_v1_6_bam_alignment_optionalfields_smallsopt_value2 =
+      bam_v1_6_bam_alignment_optionalfields_smallsopt_tag1   == bam_v1_6_bam_alignment_optionalfields_smallsopt_tag2 &&
+      bam_v1_6_bam_alignment_optionalfields_smallsopt_value1 == bam_v1_6_bam_alignment_optionalfields_smallsopt_value2
+
+instance Show BAM_V1_6_BAM_Alignment_OptionalFields_SmallSOPT where
+  show (BAM_V1_6_BAM_Alignment_OptionalFields_SmallSOPT tag
+                                                        value
+       ) =
+    "BAM_V1_6_BAM_Alignment_OptionalFields_SmallSOPT { "          ++
+    "bam_v1_6_bam_alignment_optionalfields_smallsopt_tag = "      ++
+    (show tag)                                                    ++
+    " , bam_v1_6_bam_alignment_optionalfields_smallsopt_value = " ++
+    (show value)                                                  ++
+    " }"
diff --git a/src/Data/BAM/Version1_6/BAM/Alignment/OptionalFields/ZOPT.hs b/src/Data/BAM/Version1_6/BAM/Alignment/OptionalFields/ZOPT.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/BAM/Alignment/OptionalFields/ZOPT.hs
@@ -0,0 +1,72 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE StrictData            #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.BAM.Alignment.OptionalFields.ZOPT
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = WARNING
+--
+-- This module is considered __internal__.
+--
+-- The Package Versioning Policy __does not apply__.
+--
+-- The contents of this module may change __in any way whatsoever__
+-- and __without any warning__ between minor versions of this package.
+--
+-- Authors importing this library are expected to track development
+-- closely.
+--
+-- All credit goes to the author(s)/maintainer(s) of the
+-- [containers](https://hackage.haskell.org/package/containers) library
+-- for the above warning text.
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.BAM.Alignment.OptionalFields.ZOPT ( -- * BAM version 1.6 alignment optional fields data type
+                                                               BAM_V1_6_BAM_Alignment_OptionalFields_ZOPT(..)
+                                                             ) where
+
+import Data.ByteString
+import Data.Word
+import Data.Data
+import Data.Sequence
+import Generics.Deriving.Base
+
+-- | Custom BAM (version 1.6) @"SAM_V1_6_Alignment_OptionalFields_ZOPT"@ data type.
+--
+-- See section 4.2 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data BAM_V1_6_BAM_Alignment_OptionalFields_ZOPT = BAM_V1_6_BAM_Alignment_OptionalFields_ZOPT
+  { bam_v1_6_bam_alignment_optionalfields_zopt_tag   :: ByteString
+  , bam_v1_6_bam_alignment_optionalfields_zopt_value :: Seq Word8
+  } deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_BAM_Alignment_OptionalFields_ZOPT where
+  BAM_V1_6_BAM_Alignment_OptionalFields_ZOPT bam_v1_6_bam_alignment_optionalfields_zopt_tag1
+                                             bam_v1_6_bam_alignment_optionalfields_zopt_value1 ==
+    BAM_V1_6_BAM_Alignment_OptionalFields_ZOPT bam_v1_6_bam_alignment_optionalfields_zopt_tag2
+                                               bam_v1_6_bam_alignment_optionalfields_zopt_value2 =
+      bam_v1_6_bam_alignment_optionalfields_zopt_tag1   == bam_v1_6_bam_alignment_optionalfields_zopt_tag2 &&
+      bam_v1_6_bam_alignment_optionalfields_zopt_value1 == bam_v1_6_bam_alignment_optionalfields_zopt_value2
+
+instance Show BAM_V1_6_BAM_Alignment_OptionalFields_ZOPT where
+  show (BAM_V1_6_BAM_Alignment_OptionalFields_ZOPT tag
+                                                   value
+       ) =
+    "BAM_V1_6_BAM_Alignment_OptionalFields_ZOPT { "          ++
+    "bam_v1_6_bam_alignment_optionalfields_zopt_tag = "      ++
+    (show tag)                                               ++
+    " , bam_v1_6_bam_alignment_optionalfields_zopt_value = " ++
+    (show value)                                             ++
+    " }"
diff --git a/src/Data/BAM/Version1_6/BAM/BAMAlignments.hs b/src/Data/BAM/Version1_6/BAM/BAMAlignments.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/BAM/BAMAlignments.hs
@@ -0,0 +1,49 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE StrictData            #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.BAM.BAMAlignments
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.BAM.BAMAlignments ( -- * BAM_V1_6_BAM_BAMAlignment version 1.6 data type
+                                               BAM_V1_6_BAM_BAMAlignments(..)
+                                             ) where
+
+import Data.BAM.Version1_6.BAM.Alignment
+
+import Data.Data
+import Data.Sequence
+import Generics.Deriving.Base
+
+-- | Custom @"BAM_V1_6_BAM_BAMAlignments"@ (BAM version 1.6) data type.
+--
+-- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+newtype BAM_V1_6_BAM_BAMAlignments = BAM_V1_6_BAM_BAMAlignments
+  { bam_v1_6_bam_bamalignments_alignments :: Seq BAM_V1_6_BAM_Alignment -- ^ List of alignments.
+  } deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_BAM_BAMAlignments where
+  BAM_V1_6_BAM_BAMAlignments bam_v1_6_bamalignments_alignments1 ==
+    BAM_V1_6_BAM_BAMAlignments bam_v1_6_bamalignments_alignments2 =
+      bam_v1_6_bamalignments_alignments1 == bam_v1_6_bamalignments_alignments2 
+
+instance Show BAM_V1_6_BAM_BAMAlignments where
+  show (BAM_V1_6_BAM_BAMAlignments alignments
+       ) =
+    "BAM_V1_6_BAM_BAMAlignments { "        ++
+    "bam_v1_6_bamalignments_alignments = " ++
+    (show alignments)                      ++
+    " }"
diff --git a/src/Data/BAM/Version1_6/BAM/BAMHeader.hs b/src/Data/BAM/Version1_6/BAM/BAMHeader.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/BAM/BAMHeader.hs
@@ -0,0 +1,81 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE StrictData            #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.BAM.BAMHeader
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.BAM.BAMHeader ( -- * BAM_V1_6_BAM_BAMHeader version 1.6 data type
+                                           BAM_V1_6_BAM_BAMHeader(..)
+                                         ) where
+
+import Data.BAM.Version1_6.BAM.ReferenceInformation
+
+import Data.ByteString (ByteString)
+import Data.Data
+import Data.Sequence
+import Data.Word
+import Generics.Deriving.Base
+
+-- | Custom @"BAM_V1_6_BAM_BAMHeader"@ (BAM version 1.6) data type.
+--
+-- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data BAM_V1_6_BAM_BAMHeader = BAM_V1_6_BAM_BAMHeader
+  { bam_v1_6_bam_bamheader_magic                 :: ByteString                             -- ^ BAM magic string (magic).
+                                                                                           -- This should be BAM\1.
+  , bam_v1_6_bam_bamheader_l_text                :: Word32                                 -- ^ Length of the header text, including any NUL padding (l_text).
+  , bam_v1_6_bam_bamheader_text                  :: ByteString                             -- ^ Plain header text in SAM;
+                                                                                           -- not necessarily NUL-terminated.
+  , bam_v1_6_bam_bamheader_n_ref                 :: Word32                                 -- ^ Number of reference sequences (n_ref).
+  , bam_v1_6_bam_bamheader_reference_information :: Seq BAM_V1_6_BAM_Reference_Information -- ^ List of reference information (n = bam_v1_6_bam_n_ref).
+  } deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_BAM_BAMHeader where
+  BAM_V1_6_BAM_BAMHeader bam_v1_6_bam_bamheader_magic1
+                         bam_v1_6_bam_bamheader_l_text1
+                         bam_v1_6_bam_bamheader_text1
+                         bam_v1_6_bam_bamheader_n_ref1
+                         bam_v1_6_bam_bamheader_reference_information1 ==
+    BAM_V1_6_BAM_BAMHeader bam_v1_6_bam_bamheader_magic2
+                           bam_v1_6_bam_bamheader_l_text2
+                           bam_v1_6_bam_bamheader_text2
+                           bam_v1_6_bam_bamheader_n_ref2
+                           bam_v1_6_bam_bamheader_reference_information2 =
+      bam_v1_6_bam_bamheader_magic1                 == bam_v1_6_bam_bamheader_magic2                         &&
+      bam_v1_6_bam_bamheader_l_text1                == bam_v1_6_bam_bamheader_l_text2                        &&
+      bam_v1_6_bam_bamheader_text1                  == bam_v1_6_bam_bamheader_text2                          &&
+      bam_v1_6_bam_bamheader_n_ref1                 == bam_v1_6_bam_bamheader_n_ref2                         &&
+      bam_v1_6_bam_bamheader_reference_information1 == bam_v1_6_bam_bamheader_reference_information2
+
+instance Show BAM_V1_6_BAM_BAMHeader where
+  show (BAM_V1_6_BAM_BAMHeader magic
+                               l_text
+                               text
+                               n_ref
+                               reference_information
+       ) =
+    "BAM_V1_6_BAM_BAMHeader { "                          ++
+    "bam_v1_6_bam_bamheader_magic = "                    ++
+    (show magic)                                         ++
+    " , bam_v1_6_bam_bamheader_l_text = "                ++
+    (show l_text)                                        ++
+    " , bam_v1_6_bam_bamheader_text = "                  ++
+    (show text)                                          ++
+    " , bam_v1_6_bam_bamheader_n_ref = "                 ++
+    (show n_ref)                                         ++
+    " , bam_v1_6_bam_bamheader_reference_information = " ++
+    (show reference_information)                         ++
+    " }"
diff --git a/src/Data/BAM/Version1_6/BAM/Header.hs b/src/Data/BAM/Version1_6/BAM/Header.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/BAM/Header.hs
@@ -0,0 +1,46 @@
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.BAM.Header
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = WARNING
+--
+-- This module is considered __internal__.
+--
+-- The Package Versioning Policy __does not apply__.
+--
+-- The contents of this module may change __in any way whatsoever__
+-- and __without any warning__ between minor versions of this package.
+--
+-- Authors importing this library are expected to track development
+-- closely.
+--
+-- All credit goes to the author(s)/maintainer(s) of the
+-- [containers](https://hackage.haskell.org/package/containers) library
+-- for the above warning text.
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.BAM.Header ( -- * BAM version 1.6 header section data type (RE-EXPORT)
+                                        module Data.BAM.Version1_6.BAM.Header.CO,
+                                        module Data.BAM.Version1_6.BAM.Header.HD,
+                                        module Data.BAM.Version1_6.BAM.Header.PG,
+                                        module Data.BAM.Version1_6.BAM.Header.RG,
+                                        module Data.BAM.Version1_6.BAM.Header.SQ
+                                      ) where
+
+-- | Re-exports.
+import Data.BAM.Version1_6.BAM.Header.CO
+import Data.BAM.Version1_6.BAM.Header.HD
+import Data.BAM.Version1_6.BAM.Header.PG
+import Data.BAM.Version1_6.BAM.Header.RG
+import Data.BAM.Version1_6.BAM.Header.SQ
diff --git a/src/Data/BAM/Version1_6/BAM/Header/CO.hs b/src/Data/BAM/Version1_6/BAM/Header/CO.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/BAM/Header/CO.hs
@@ -0,0 +1,45 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE StrictData            #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.BAM.Header.CO
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.BAM.Header.CO ( -- * BAM version 1.6 One-line text comment data type
+                                           BAM_V1_6_One_Line_Comment(..)
+                                         ) where
+
+import Data.ByteString
+import Data.Data
+import Generics.Deriving.Base
+
+-- | Custom BAM (version 1.6) @"SAM_V1_6_One_Line_Comment"@ data type.
+--
+-- See section 4.2 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+newtype BAM_V1_6_One_Line_Comment = BAM_V1_6_One_Line_Comment { bam_v1_6_one_line_comment_value :: ByteString
+                                                              }
+  deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_One_Line_Comment where
+  BAM_V1_6_One_Line_Comment bam_v1_6_one_line_comment_value1 ==
+    BAM_V1_6_One_Line_Comment bam_v1_6_one_line_comment_value2 =
+      bam_v1_6_one_line_comment_value1 == bam_v1_6_one_line_comment_value2
+
+instance Show BAM_V1_6_One_Line_Comment where
+  show (BAM_V1_6_One_Line_Comment value) = "BAM_V1_6_One_Line_Comment { "       ++
+                                           "bam_v1_6_one_line_comment_value = " ++
+                                           (show value)                         ++
+                                           " }"
diff --git a/src/Data/BAM/Version1_6/BAM/Header/HD.hs b/src/Data/BAM/Version1_6/BAM/Header/HD.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/BAM/Header/HD.hs
@@ -0,0 +1,137 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE StrictData            #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.BAM.Header.HD
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.BAM.Header.HD ( -- * BAM version 1.6 File-level metadata data type
+                                           BAM_V1_6_File_Level_Metadata(..),
+                                           -- * BAM version 1.6 File-Level Metadata data types
+                                           BAM_V1_6_File_Level_Metadata_Format_Version(..),
+                                           BAM_V1_6_File_Level_Metadata_Sorting_Order(..),
+                                           BAM_V1_6_File_Level_Metadata_Alignment_Grouping(..),
+                                           BAM_V1_6_File_Level_Metadata_SubSorting_Order(..)
+                                         ) where
+
+import Data.ByteString
+import Data.Data
+import Generics.Deriving.Base
+
+-- | Custom BAM (version 1.6) @"BAM_V1_6_File_Level_Metadata"@ data type.
+--
+-- See section 4.2 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data BAM_V1_6_File_Level_Metadata = BAM_V1_6_File_Level_Metadata { bam_v1_6_file_level_metadata_format_version     :: BAM_V1_6_File_Level_Metadata_Format_Version
+                                                                 , bam_v1_6_file_level_metadata_sorting_order      :: Maybe BAM_V1_6_File_Level_Metadata_Sorting_Order
+                                                                 , bam_v1_6_file_level_metadata_alignment_grouping :: Maybe BAM_V1_6_File_Level_Metadata_Alignment_Grouping
+                                                                 , bam_v1_6_file_level_metadata_subsorting_order   :: Maybe BAM_V1_6_File_Level_Metadata_SubSorting_Order
+                                                                 }
+   deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_File_Level_Metadata where
+  BAM_V1_6_File_Level_Metadata bam_v1_6_file_level_metadata_format_version1
+                               bam_v1_6_file_level_metadata_sorting_order1
+                               bam_v1_6_file_level_metadata_alignment_grouping1
+                               bam_v1_6_file_level_metadata_subsorting_order1 ==
+    BAM_V1_6_File_Level_Metadata bam_v1_6_file_level_metadata_format_version2
+                                 bam_v1_6_file_level_metadata_sorting_order2
+                                 bam_v1_6_file_level_metadata_alignment_grouping2
+                                 bam_v1_6_file_level_metadata_subsorting_order2 =
+      bam_v1_6_file_level_metadata_format_version1     == bam_v1_6_file_level_metadata_format_version2     &&
+      bam_v1_6_file_level_metadata_sorting_order1      == bam_v1_6_file_level_metadata_sorting_order2      &&
+      bam_v1_6_file_level_metadata_alignment_grouping1 == bam_v1_6_file_level_metadata_alignment_grouping2 &&
+      bam_v1_6_file_level_metadata_subsorting_order1   == bam_v1_6_file_level_metadata_subsorting_order2
+
+instance Show BAM_V1_6_File_Level_Metadata where
+  show (BAM_V1_6_File_Level_Metadata version sorting_order alignment_grouping subsorting_order) =
+    "BAM_V1_6_File_Level_Metadata { "                       ++
+    "bam_v1_6_file_level_metadata_format_version = "        ++
+    (show version)                                          ++
+    " , bam_v1_6_file_level_metadata_sorting_order = "      ++
+    (show sorting_order)                                    ++
+    " , bam_v1_6_file_level_metadata_alignment_grouping = " ++
+    (show alignment_grouping)                               ++
+    " , bam_v1_6_file_level_metadata_subsorting_order = "   ++
+    (show subsorting_order)                                 ++
+    " }" 
+
+-- | VN tag for @"BAM_V1_6_File_Level_Metadata"@.
+newtype BAM_V1_6_File_Level_Metadata_Format_Version = BAM_V1_6_File_Level_Metadata_Format_Version { bam_v1_6_file_level_metadata_format_version_value :: ByteString
+                                                                                                  }
+  deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_File_Level_Metadata_Format_Version where
+  BAM_V1_6_File_Level_Metadata_Format_Version bam_v1_6_file_level_metadata_format_version_value1 ==
+    BAM_V1_6_File_Level_Metadata_Format_Version bam_v1_6_file_level_metadata_format_version_value2 =
+      bam_v1_6_file_level_metadata_format_version_value1 == bam_v1_6_file_level_metadata_format_version_value2
+
+instance Show BAM_V1_6_File_Level_Metadata_Format_Version where
+  show (BAM_V1_6_File_Level_Metadata_Format_Version value) =
+    "BAM_V1_6_File_Level_Metadata_Format_Version { "       ++
+    "bam_v1_6_file_level_metadata_format_version_value = " ++
+    (show value)                                           ++
+    " }"
+
+-- | SO tag for @"BAM_V1_6_File_Level_Metadata"@.
+newtype BAM_V1_6_File_Level_Metadata_Sorting_Order = BAM_V1_6_File_Level_Metadata_Sorting_Order { bam_v1_6_file_level_metadata_sorting_order_value :: ByteString
+                                                                                                }
+  deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_File_Level_Metadata_Sorting_Order where
+  BAM_V1_6_File_Level_Metadata_Sorting_Order bam_v1_6_file_level_metadata_sorting_order_value1 ==
+    BAM_V1_6_File_Level_Metadata_Sorting_Order bam_v1_6_file_level_metadata_sorting_order_value2 =
+      bam_v1_6_file_level_metadata_sorting_order_value1 == bam_v1_6_file_level_metadata_sorting_order_value2
+
+instance Show BAM_V1_6_File_Level_Metadata_Sorting_Order where
+  show (BAM_V1_6_File_Level_Metadata_Sorting_Order value) =
+    "BAM_V1_6_File_Level_Metadata_Sorting_Order { "       ++
+    "bam_v1_6_file_level_metadata_sorting_order_value = " ++
+    (show value)                                          ++
+    " }"
+
+-- | GO tag for @"BAM_V1_6_File_Level_Metadata"@.
+newtype BAM_V1_6_File_Level_Metadata_Alignment_Grouping = BAM_V1_6_File_Level_Metadata_Alignment_Grouping { bam_v1_6_file_level_metadata_alignment_grouping_value :: ByteString
+                                                                                                          }
+  deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_File_Level_Metadata_Alignment_Grouping where
+  BAM_V1_6_File_Level_Metadata_Alignment_Grouping bam_v1_6_file_level_metadata_alignment_grouping_value1 ==
+    BAM_V1_6_File_Level_Metadata_Alignment_Grouping bam_v1_6_file_level_metadata_alignment_grouping_value2 =
+      bam_v1_6_file_level_metadata_alignment_grouping_value1 == bam_v1_6_file_level_metadata_alignment_grouping_value2
+
+instance Show BAM_V1_6_File_Level_Metadata_Alignment_Grouping where
+  show (BAM_V1_6_File_Level_Metadata_Alignment_Grouping value) =
+    "BAM_V1_6_File_Level_Metadata_Alignment_Grouping { "       ++
+    "bam_v1_6_file_level_metadata_alignment_grouping_value = " ++
+    (show value)                                               ++
+    " }"
+
+-- | SS tag for @"BAM_V1_6_File_Level_Metadata"@.
+newtype BAM_V1_6_File_Level_Metadata_SubSorting_Order = BAM_V1_6_File_Level_Metadata_SubSorting_Order { bam_v1_6_file_level_metadata_subsorting_order_value :: ByteString
+                                                                                                      }
+  deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_File_Level_Metadata_SubSorting_Order where
+  BAM_V1_6_File_Level_Metadata_SubSorting_Order bam_v1_6_file_level_metadata_subsorting_order_value1 ==
+    BAM_V1_6_File_Level_Metadata_SubSorting_Order bam_v1_6_file_level_metadata_subsorting_order_value2 =
+      bam_v1_6_file_level_metadata_subsorting_order_value1 == bam_v1_6_file_level_metadata_subsorting_order_value2
+
+instance Show BAM_V1_6_File_Level_Metadata_SubSorting_Order where
+  show (BAM_V1_6_File_Level_Metadata_SubSorting_Order value) =
+    "BAM_V1_6_File_Level_Metadata_SubSorting_Order { "       ++
+    "bam_v1_6_file_level_metadata_subsorting_order_value = " ++
+    (show value)                                             ++
+    " }"
diff --git a/src/Data/BAM/Version1_6/BAM/Header/PG.hs b/src/Data/BAM/Version1_6/BAM/Header/PG.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/BAM/Header/PG.hs
@@ -0,0 +1,185 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE StrictData            #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.BAM.Header.PG
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.BAM.Header.PG ( -- * BAM version 1.6 program data type
+                                           BAM_V1_6_Program(..),
+                                           -- * BAM version 1.6 program data types
+                                           BAM_V1_6_Program_Record_Identifier(..),
+                                           BAM_V1_6_Program_Name(..),
+                                           BAM_V1_6_Program_Command_Line(..),
+                                           BAM_V1_6_Program_Previous_PG_ID(..),
+                                           BAM_V1_6_Program_Description(..),
+                                           BAM_V1_6_Program_Version(..)
+                                         ) where
+
+import Data.ByteString
+import Data.Data
+import Generics.Deriving.Base
+
+-- | Custom BAM (version 1.6) @"BAM_V1_6_Program"@ data type.
+--
+-- See section 4.2 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data BAM_V1_6_Program = BAM_V1_6_Program { bam_v1_6_program_record_identifier :: BAM_V1_6_Program_Record_Identifier
+                                         , bam_v1_6_program_name              :: Maybe BAM_V1_6_Program_Name
+                                         , bam_v1_6_program_command_line      :: Maybe BAM_V1_6_Program_Command_Line
+                                         , bam_v1_6_program_previous_pg_id    :: Maybe BAM_V1_6_Program_Previous_PG_ID
+                                         , bam_v1_6_program_description       :: Maybe BAM_V1_6_Program_Description
+                                         , bam_v1_6_program_version           :: Maybe BAM_V1_6_Program_Version
+                                         }
+  deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_Program where
+  BAM_V1_6_Program bam_v1_6_program_record_identifier1
+                   bam_v1_6_program_name1
+                   bam_v1_6_program_command_line1
+                   bam_v1_6_program_previous_pg_id1
+                   bam_v1_6_program_description1
+                   bam_v1_6_program_version1 ==
+    BAM_V1_6_Program bam_v1_6_program_record_identifier2
+                     bam_v1_6_program_name2
+                     bam_v1_6_program_command_line2
+                     bam_v1_6_program_previous_pg_id2
+                     bam_v1_6_program_description2
+                     bam_v1_6_program_version2 =
+      bam_v1_6_program_record_identifier1 == bam_v1_6_program_record_identifier2 &&
+      bam_v1_6_program_name1              == bam_v1_6_program_name2              &&
+      bam_v1_6_program_command_line1      == bam_v1_6_program_command_line2      &&
+      bam_v1_6_program_previous_pg_id1    == bam_v1_6_program_previous_pg_id2    &&
+      bam_v1_6_program_description1       == bam_v1_6_program_description2       &&
+      bam_v1_6_program_version1           == bam_v1_6_program_version2
+
+instance Show BAM_V1_6_Program where
+  show (BAM_V1_6_Program record_identifier name command_line previous_pg_id description version) =
+    "BAM_V1_6_Program { "                    ++
+    "rbam_v1_6_program_record_identifier = " ++
+    (show record_identifier)                 ++
+    " , bam_v1_6_program_name = "            ++
+    (show name)                              ++
+    " , bam_v1_6_program_command_line = "    ++
+    (show command_line)                      ++
+    " , bam_v1_6_program_previous_pg_id = "  ++
+    (show previous_pg_id)                    ++
+    " , bam_v1_6_program_description = "     ++
+    (show description)                       ++
+    " , bam_v1_6_program_version = "         ++
+    (show version)                           ++
+    " }"
+
+-- | ID tag for @"BAM_V1_6_Program"@.
+newtype BAM_V1_6_Program_Record_Identifier = BAM_V1_6_Program_Record_Identifier { bam_v1_6_program_record_identifier_value :: ByteString
+                                                                                }
+  deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_Program_Record_Identifier where
+  BAM_V1_6_Program_Record_Identifier bam_v1_6_program_record_identifier_value1 ==
+    BAM_V1_6_Program_Record_Identifier bam_v1_6_program_record_identifier_value2 =
+      bam_v1_6_program_record_identifier_value1 == bam_v1_6_program_record_identifier_value2
+
+instance Show BAM_V1_6_Program_Record_Identifier where
+  show (BAM_V1_6_Program_Record_Identifier value) =
+    "BAM_V1_6_Program_Record_Identifier { "       ++
+    "bam_v1_6_program_record_identifier_value = " ++
+    (show value)                                  ++
+    " }"
+
+-- | PN tag for @"BAM_V1_6_Program"@.
+newtype BAM_V1_6_Program_Name = BAM_V1_6_Program_Name { bam_v1_6_program_name_value :: ByteString
+                                                      }
+  deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_Program_Name where
+  BAM_V1_6_Program_Name bam_v1_6_program_name_value1 ==
+    BAM_V1_6_Program_Name bam_v1_6_program_name_value2 =
+      bam_v1_6_program_name_value1 == bam_v1_6_program_name_value2
+
+instance Show BAM_V1_6_Program_Name where
+  show (BAM_V1_6_Program_Name value) =
+    "BAM_V1_6_Program_Name { "       ++
+    "bam_v1_6_program_name_value = " ++
+    (show value)                     ++
+    " }"
+
+-- | CL tag for @"BAM_V1_6_Program"@.
+newtype BAM_V1_6_Program_Command_Line = BAM_V1_6_Program_Command_Line { bam_v1_6_program_command_line_value :: ByteString
+                                                                      }
+  deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_Program_Command_Line where
+  BAM_V1_6_Program_Command_Line bam_v1_6_program_command_line_value1 ==
+    BAM_V1_6_Program_Command_Line bam_v1_6_program_command_line_value2 =
+      bam_v1_6_program_command_line_value1 == bam_v1_6_program_command_line_value2
+
+instance Show BAM_V1_6_Program_Command_Line where
+  show (BAM_V1_6_Program_Command_Line value) =
+    "BAM_V1_6_Program_Command_Line { "       ++
+    "bam_v1_6_program_command_line_value = " ++
+    (show value)                             ++
+    " }"
+
+-- | PP tag for @"BAM_V1_6_Program"@.
+newtype BAM_V1_6_Program_Previous_PG_ID = BAM_V1_6_Program_Previous_PG_ID { bam_v1_6_program_previous_pg_id_value :: ByteString
+                                                                          }
+  deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_Program_Previous_PG_ID where
+  BAM_V1_6_Program_Previous_PG_ID bam_v1_6_program_previous_pg_id_value1 ==
+    BAM_V1_6_Program_Previous_PG_ID bam_v1_6_program_previous_pg_id_value2 =
+      bam_v1_6_program_previous_pg_id_value1 == bam_v1_6_program_previous_pg_id_value2
+
+instance Show BAM_V1_6_Program_Previous_PG_ID where
+  show (BAM_V1_6_Program_Previous_PG_ID value) =
+    "BAM_V1_6_Program_Previous_PG_ID { "       ++
+    "bam_v1_6_program_previous_pg_id_value = " ++
+    (show value)                               ++
+    " }"
+
+-- | DS tag for @"BAM_V1_6_Program"@.
+newtype BAM_V1_6_Program_Description = BAM_V1_6_Program_Description { bam_v1_6_program_description_value :: ByteString
+                                                                    }
+  deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_Program_Description where
+  BAM_V1_6_Program_Description bam_v1_6_program_description_value1 ==
+    BAM_V1_6_Program_Description bam_v1_6_program_description_value2 =
+      bam_v1_6_program_description_value1 == bam_v1_6_program_description_value2
+
+instance Show BAM_V1_6_Program_Description where
+  show (BAM_V1_6_Program_Description value) =
+    "BAM_V1_6_Program_Description { "       ++
+    "bam_v1_6_program_description_value = " ++
+    (show value)                            ++
+    " }"
+
+-- | VN tag for @"BAM_V1_6_Program"@.
+newtype BAM_V1_6_Program_Version = BAM_V1_6_Program_Version { bam_v1_6_program_version_value :: ByteString
+                                                            }
+  deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_Program_Version where
+  BAM_V1_6_Program_Version bam_v1_6_program_version_value1 ==
+    BAM_V1_6_Program_Version bam_v1_6_program_version_value2 =
+      bam_v1_6_program_version_value1 == bam_v1_6_program_version_value2
+
+instance Show BAM_V1_6_Program_Version where
+  show (BAM_V1_6_Program_Version value) =
+    "BAM_V1_6_Program_Version { "       ++
+    "bam_v1_6_program_version_value = " ++
+    (show value)                        ++
+    " }"
diff --git a/src/Data/BAM/Version1_6/BAM/Header/RG.hs b/src/Data/BAM/Version1_6/BAM/Header/RG.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/BAM/Header/RG.hs
@@ -0,0 +1,391 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE StrictData            #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.BAM.Header.RG
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.BAM.Header.RG ( -- * BAM version 1.6 Read group data type
+                                           BAM_V1_6_Read_Group(..),
+                                           -- * BAM version 1.6 Read group data types
+                                           BAM_V1_6_Read_Group_Identifier(..),
+                                           BAM_V1_6_Read_Group_Barcode_Sequence(..),
+                                           BAM_V1_6_Read_Group_Sequencing_Center(..),
+                                           BAM_V1_6_Read_Group_Description(..),
+                                           BAM_V1_6_Read_Group_Run_Date(..),
+                                           BAM_V1_6_Read_Group_Flow_Order(..),
+                                           BAM_V1_6_Read_Group_Key_Sequence(..),
+                                           BAM_V1_6_Read_Group_Library(..),
+                                           BAM_V1_6_Read_Group_Programs(..),
+                                           BAM_V1_6_Read_Group_Predicted_Median_Insert_Size(..),
+                                           BAM_V1_6_Read_Group_Platform(..),
+                                           BAM_V1_6_Read_Group_Platform_Model(..),
+                                           BAM_V1_6_Read_Group_Platform_Unit(..),
+                                           BAM_V1_6_Read_Group_Sample(..)
+                                         ) where
+
+import Data.ByteString
+import Data.Data
+import Generics.Deriving.Base
+
+-- | Custom BAM (version 1.6) @"BAM_V1_6_Read_Group"@ data type.
+--
+-- See section 4.2 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data BAM_V1_6_Read_Group = BAM_V1_6_Read_Group { bam_v1_6_read_group_identifier                   :: BAM_V1_6_Read_Group_Identifier
+                                               , bam_v1_6_read_group_barcode_sequence             :: Maybe BAM_V1_6_Read_Group_Barcode_Sequence
+                                               , bam_v1_6_read_group_sequencing_center            :: Maybe BAM_V1_6_Read_Group_Sequencing_Center
+                                               , bam_v1_6_read_group_description                  :: Maybe BAM_V1_6_Read_Group_Description
+                                               , bam_v1_6_read_group_run_date                     :: Maybe BAM_V1_6_Read_Group_Run_Date
+                                               , bam_v1_6_read_group_flow_order                   :: Maybe BAM_V1_6_Read_Group_Flow_Order
+                                               , bam_v1_6_read_group_key_sequence                 :: Maybe BAM_V1_6_Read_Group_Key_Sequence
+                                               , bam_v1_6_read_group_library                      :: Maybe BAM_V1_6_Read_Group_Library
+                                               , bam_v1_6_read_group_programs                     :: Maybe BAM_V1_6_Read_Group_Programs
+                                               , bam_v1_6_read_group_predicted_median_insert_size :: Maybe BAM_V1_6_Read_Group_Predicted_Median_Insert_Size
+                                               , bam_v1_6_read_group_platform                     :: Maybe BAM_V1_6_Read_Group_Platform
+                                               , bam_v1_6_read_group_platform_model               :: Maybe BAM_V1_6_Read_Group_Platform_Model
+                                               , bam_v1_6_read_group_platform_unit                :: Maybe BAM_V1_6_Read_Group_Platform_Unit
+                                               , bam_v1_6_read_group_sample                       :: Maybe BAM_V1_6_Read_Group_Sample
+                                               }
+  deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_Read_Group where
+  BAM_V1_6_Read_Group bam_v1_6_read_group_identifier1
+                      bam_v1_6_read_group_barcode_sequence1
+                      bam_v1_6_read_group_sequencing_center1
+                      bam_v1_6_read_group_description1
+                      bam_v1_6_read_group_run_date1
+                      bam_v1_6_read_group_flow_order1
+                      bam_v1_6_read_group_key_sequence1
+                      bam_v1_6_read_group_library1
+                      bam_v1_6_read_group_programs1
+                      bam_v1_6_read_group_predicted_median_insert_size1
+                      bam_v1_6_read_group_platform1
+                      bam_v1_6_read_group_platform_model1
+                      bam_v1_6_read_group_platform_unit1
+                      bam_v1_6_read_group_sample1 ==
+    BAM_V1_6_Read_Group bam_v1_6_read_group_identifier2
+                        bam_v1_6_read_group_barcode_sequence2
+                        bam_v1_6_read_group_sequencing_center2
+                        bam_v1_6_read_group_description2
+                        bam_v1_6_read_group_run_date2
+                        bam_v1_6_read_group_flow_order2
+                        bam_v1_6_read_group_key_sequence2
+                        bam_v1_6_read_group_library2
+                        bam_v1_6_read_group_programs2
+                        bam_v1_6_read_group_predicted_median_insert_size2
+                        bam_v1_6_read_group_platform2
+                        bam_v1_6_read_group_platform_model2
+                        bam_v1_6_read_group_platform_unit2
+                        bam_v1_6_read_group_sample2 =
+      bam_v1_6_read_group_identifier1                   == bam_v1_6_read_group_identifier2                   &&
+      bam_v1_6_read_group_barcode_sequence1             == bam_v1_6_read_group_barcode_sequence2             &&
+      bam_v1_6_read_group_sequencing_center1            == bam_v1_6_read_group_sequencing_center2            &&
+      bam_v1_6_read_group_description1                  == bam_v1_6_read_group_description2                  &&
+      bam_v1_6_read_group_run_date1                     == bam_v1_6_read_group_run_date2                     &&
+      bam_v1_6_read_group_flow_order1                   == bam_v1_6_read_group_flow_order2                   &&
+      bam_v1_6_read_group_key_sequence1                 == bam_v1_6_read_group_key_sequence2                 &&
+      bam_v1_6_read_group_library1                      == bam_v1_6_read_group_library2                      &&
+      bam_v1_6_read_group_programs1                     == bam_v1_6_read_group_programs2                     &&
+      bam_v1_6_read_group_predicted_median_insert_size1 == bam_v1_6_read_group_predicted_median_insert_size2 &&
+      bam_v1_6_read_group_platform1                     == bam_v1_6_read_group_platform2                     &&
+      bam_v1_6_read_group_platform_model1               == bam_v1_6_read_group_platform_model2               &&
+      bam_v1_6_read_group_platform_unit1                == bam_v1_6_read_group_platform_unit2                &&
+      bam_v1_6_read_group_sample1                       == bam_v1_6_read_group_sample2
+
+instance Show BAM_V1_6_Read_Group where
+  show (BAM_V1_6_Read_Group group_identifier
+                            barcode_sequence
+                            sequencing_center
+                            description
+                            run_date
+                            flow_order
+                            key_sequence
+                            library
+                            programs
+                            predicted_median_insert_size
+                            platform
+                            platform_model
+                            platform_unit
+                            sample
+       ) =
+    "BAM_V1_6_Read_Group { "                                      ++
+    "bam_v1_6_read_group_identifier = "                           ++
+    (show group_identifier)                                       ++
+    " , bam_v1_6_read_group_barcode_sequence = "                  ++
+    (show barcode_sequence)                                       ++
+    " , bam_v1_6_read_group_sequencing_center = "                 ++
+    (show sequencing_center)                                      ++
+    " , bam_v1_6_read_group_description = "                       ++
+    (show description)                                            ++
+    " , bam_v1_6_read_group_run_date = "                          ++
+    (show run_date)                                               ++
+    " , bam_v1_6_read_group_flow_order = "                        ++
+    (show flow_order)                                             ++
+    " , bam_v1_6_read_group_key_sequence = "                      ++
+    (show key_sequence)                                           ++
+    " , bam_v1_6_read_group_library = "                           ++
+    (show library)                                                ++
+    " , bam_v1_6_read_group_programs = "                          ++
+    (show programs)                                               ++
+    " , bam_v1_6_read_group_show_predicted_median_insert_size = " ++
+    (show predicted_median_insert_size)                           ++
+    " , bam_v1_6_read_group_platform = "                          ++
+    (show platform)                                               ++
+    " , bam_v1_6_read_group_platform_model = "                    ++
+    (show platform_model)                                         ++
+    " , bam_v1_6_read_group_platform_unit = "                     ++
+    (show platform_unit)                                          ++
+    " , bam_v1_6_read_group_sample = "                            ++
+    (show sample)                                                 ++
+    " }"
+
+-- | ID tag for @"BAM_V1_6_Read_Group"@.
+newtype BAM_V1_6_Read_Group_Identifier = BAM_V1_6_Read_Group_Identifier { bam_v1_6_read_group_identifier_value :: ByteString
+                                                                        }
+  deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_Read_Group_Identifier where
+  BAM_V1_6_Read_Group_Identifier bam_v1_6_read_group_identifier_value1 ==
+    BAM_V1_6_Read_Group_Identifier bam_v1_6_read_group_identifier_value2 =
+      bam_v1_6_read_group_identifier_value1 == bam_v1_6_read_group_identifier_value2
+
+instance Show BAM_V1_6_Read_Group_Identifier where
+  show (BAM_V1_6_Read_Group_Identifier value) =
+    "BAM_V1_6_Read_Group_Identifier { "       ++
+    "bam_v1_6_read_group_identifier_value = " ++
+    (show value)                              ++
+    " }"
+
+-- | BC tag for @"BAM_V1_6_Read_Group"@.
+newtype BAM_V1_6_Read_Group_Barcode_Sequence = BAM_V1_6_Read_Group_Barcode_Sequence { bam_v1_6_read_group_barcode_sequence_value :: ByteString
+                                                                                    }
+  deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_Read_Group_Barcode_Sequence where
+  BAM_V1_6_Read_Group_Barcode_Sequence bam_v1_6_read_group_barcode_sequence_value1 ==
+    BAM_V1_6_Read_Group_Barcode_Sequence bam_v1_6_read_group_barcode_sequence_value2 =
+      bam_v1_6_read_group_barcode_sequence_value1 == bam_v1_6_read_group_barcode_sequence_value2
+
+instance Show BAM_V1_6_Read_Group_Barcode_Sequence where
+  show (BAM_V1_6_Read_Group_Barcode_Sequence value) =
+    "BAM_V1_6_Read_Group_Barcode_Sequence { "       ++
+    "bam_v1_6_read_group_barcode_sequence_value = " ++
+    (show value)                                    ++
+    " }"
+
+-- | CN tag for @"BAM_V1_6_Read_Group"@.
+newtype BAM_V1_6_Read_Group_Sequencing_Center = BAM_V1_6_Read_Group_Sequencing_Center { bam_v1_6_read_group_sequencing_center_value :: ByteString
+                                                                                      }
+  deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_Read_Group_Sequencing_Center where
+  BAM_V1_6_Read_Group_Sequencing_Center bam_v1_6_read_group_sequencing_center_value1 ==
+    BAM_V1_6_Read_Group_Sequencing_Center bam_v1_6_read_group_sequencing_center_value2 =
+      bam_v1_6_read_group_sequencing_center_value1 == bam_v1_6_read_group_sequencing_center_value2
+
+instance Show BAM_V1_6_Read_Group_Sequencing_Center where
+  show (BAM_V1_6_Read_Group_Sequencing_Center value) =
+    "BAM_V1_6_Read_Group_Sequencing_Center { "       ++
+    "bam_v1_6_read_group_sequencing_center_value = " ++
+    (show value)                                     ++
+    " }"
+
+-- | DS tag for @"BAM_V1_6_Read_Group"@.
+newtype BAM_V1_6_Read_Group_Description = BAM_V1_6_Read_Group_Description { bam_v1_6_read_group_description_value :: ByteString
+                                                                          }
+  deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_Read_Group_Description where
+  BAM_V1_6_Read_Group_Description bam_v1_6_read_group_description_value1 ==
+    BAM_V1_6_Read_Group_Description bam_v1_6_read_group_description_value2 =
+      bam_v1_6_read_group_description_value1 == bam_v1_6_read_group_description_value2
+
+instance Show BAM_V1_6_Read_Group_Description where
+  show (BAM_V1_6_Read_Group_Description value) =
+    "BAM_V1_6_Read_Group_Description { "       ++
+    "bam_v1_6_read_group_description_value = " ++
+    (show value)                               ++
+    " }"
+
+-- | DT tag for @"BAM_V1_6_Read_Group"@.
+newtype BAM_V1_6_Read_Group_Run_Date = BAM_V1_6_Read_Group_Run_Date { bam_v1_6_read_group_run_date_value :: ByteString
+                                                                    }
+  deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_Read_Group_Run_Date where
+  BAM_V1_6_Read_Group_Run_Date bam_v1_6_read_group_run_date_value1 ==
+    BAM_V1_6_Read_Group_Run_Date bam_v1_6_read_group_run_date_value2 =
+      bam_v1_6_read_group_run_date_value1 == bam_v1_6_read_group_run_date_value2
+
+instance Show BAM_V1_6_Read_Group_Run_Date where
+  show (BAM_V1_6_Read_Group_Run_Date value) =
+    "BAM_V1_6_Read_Group_Run_Date { "       ++
+    "bam_v1_6_read_group_run_date_value = " ++
+    (show value)                            ++
+    " }"
+
+-- | FO tag for @"BAM_V1_6_Read_Group"@.
+newtype BAM_V1_6_Read_Group_Flow_Order = BAM_V1_6_Read_Group_Flow_Order { bam_v1_6_read_group_flow_order_value :: ByteString
+                                                                        }
+  deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_Read_Group_Flow_Order where
+  BAM_V1_6_Read_Group_Flow_Order bam_v1_6_one_line_comment_value1 ==
+    BAM_V1_6_Read_Group_Flow_Order bam_v1_6_read_group_flow_order_value2 =
+      bam_v1_6_one_line_comment_value1 == bam_v1_6_read_group_flow_order_value2
+
+instance Show BAM_V1_6_Read_Group_Flow_Order where
+  show (BAM_V1_6_Read_Group_Flow_Order value) =
+    "BAM_V1_6_Read_Group_Flow_Order { "       ++
+    "bam_v1_6_read_group_flow_order_value = " ++
+    (show value)                              ++
+    " }"
+
+-- | KS tag for @"BAM_V1_6_Read_Group"@.
+newtype BAM_V1_6_Read_Group_Key_Sequence = BAM_V1_6_Read_Group_Key_Sequence { bam_v1_6_read_group_key_sequence_value :: ByteString
+                                                                            }
+  deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_Read_Group_Key_Sequence where
+  BAM_V1_6_Read_Group_Key_Sequence bam_v1_6_read_group_key_sequence_value1 ==
+    BAM_V1_6_Read_Group_Key_Sequence bam_v1_6_read_group_key_sequence_value2 =
+      bam_v1_6_read_group_key_sequence_value1 == bam_v1_6_read_group_key_sequence_value2
+
+instance Show BAM_V1_6_Read_Group_Key_Sequence where
+  show (BAM_V1_6_Read_Group_Key_Sequence value) =
+    "BAM_V1_6_Read_Group_Key_Sequence { "       ++
+    "bam_v1_6_read_group_key_sequence_value = " ++
+    (show value)                                ++
+    " }"
+
+-- | LB tag for @"BAM_V1_6_Read_Group"@.
+newtype BAM_V1_6_Read_Group_Library = BAM_V1_6_Read_Group_Library { bam_v1_6_read_group_library_value :: ByteString
+                                                                  }
+  deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_Read_Group_Library where
+  BAM_V1_6_Read_Group_Library bam_v1_6_read_group_library_value1 ==
+    BAM_V1_6_Read_Group_Library bam_v1_6_read_group_library_value2 =
+      bam_v1_6_read_group_library_value1 == bam_v1_6_read_group_library_value2
+
+instance Show BAM_V1_6_Read_Group_Library where
+  show (BAM_V1_6_Read_Group_Library value) =
+    "BAM_V1_6_Read_Group_Library { "       ++
+    "bam_v1_6_read_group_library_value = " ++
+    (show value)                           ++
+    " }"
+
+-- | PG tag for @"BAM_V1_6_Read_Group"@.
+newtype BAM_V1_6_Read_Group_Programs = BAM_V1_6_Read_Group_Programs { bam_v1_6_read_group_programs_value :: ByteString
+                                                                    }
+  deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_Read_Group_Programs where
+  BAM_V1_6_Read_Group_Programs bam_v1_6_read_group_programs_value1 ==
+    BAM_V1_6_Read_Group_Programs bam_v1_6_read_group_programs_value2 =
+      bam_v1_6_read_group_programs_value1 == bam_v1_6_read_group_programs_value2
+
+instance Show BAM_V1_6_Read_Group_Programs where
+  show (BAM_V1_6_Read_Group_Programs value) =
+    "BAM_V1_6_Read_Group_Programs { "       ++
+    "bam_v1_6_read_group_programs_value = " ++
+    (show value)                            ++
+    " }"
+
+-- | PI tag for @"BAM_V1_6_Read_Group"@.
+newtype BAM_V1_6_Read_Group_Predicted_Median_Insert_Size = BAM_V1_6_Read_Group_Predicted_Median_Insert_Size { bam_v1_6_read_group_predicted_median_insert_size_value :: ByteString
+                                                                                                            }
+  deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_Read_Group_Predicted_Median_Insert_Size where
+  BAM_V1_6_Read_Group_Predicted_Median_Insert_Size bam_v1_6_read_group_predicted_median_insert_size_value1 ==
+    BAM_V1_6_Read_Group_Predicted_Median_Insert_Size bam_v1_6_read_group_predicted_median_insert_size_value2 =
+      bam_v1_6_read_group_predicted_median_insert_size_value1 == bam_v1_6_read_group_predicted_median_insert_size_value2
+
+instance Show BAM_V1_6_Read_Group_Predicted_Median_Insert_Size where
+  show (BAM_V1_6_Read_Group_Predicted_Median_Insert_Size value) =
+    "BAM_V1_6_Read_Group_Predicted_Median_Insert_Size { "       ++
+    "bam_v1_6_read_group_predicted_median_insert_size_value = " ++
+    (show value)                                                ++
+    " }"
+
+-- | PL tag for @"BAM_V1_6_Read_Group"@.
+newtype BAM_V1_6_Read_Group_Platform = BAM_V1_6_Read_Group_Platform { bam_v1_6_read_group_platform_value :: ByteString
+                                                                    }
+  deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_Read_Group_Platform where
+  BAM_V1_6_Read_Group_Platform bam_v1_6_read_group_platform_value1 ==
+    BAM_V1_6_Read_Group_Platform bam_v1_6_read_group_platform_value2 =
+      bam_v1_6_read_group_platform_value1 == bam_v1_6_read_group_platform_value2
+
+instance Show BAM_V1_6_Read_Group_Platform where
+  show (BAM_V1_6_Read_Group_Platform value) =
+    "BAM_V1_6_Read_Group_Platform { "       ++
+    "bam_v1_6_read_group_platform_value = " ++
+    (show value)                            ++
+    " }"
+
+-- | PM tag for @"BAM_V1_6_Read_Group"@.
+newtype BAM_V1_6_Read_Group_Platform_Model = BAM_V1_6_Read_Group_Platform_Model { bam_v1_6_read_group_platform_model_value :: ByteString
+                                                                                }
+  deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_Read_Group_Platform_Model where
+  BAM_V1_6_Read_Group_Platform_Model bam_v1_6_read_group_platform_model_value1 ==
+    BAM_V1_6_Read_Group_Platform_Model bam_v1_6_read_group_platform_model_value2 =
+      bam_v1_6_read_group_platform_model_value1 == bam_v1_6_read_group_platform_model_value2
+
+instance Show BAM_V1_6_Read_Group_Platform_Model where
+  show (BAM_V1_6_Read_Group_Platform_Model value) =
+    "BAM_V1_6_Read_Group_Platform_Model { "       ++
+    "bam_v1_6_read_group_platform_model_value = " ++
+    (show value)                                  ++
+    " }"
+
+-- | PU tag for @"BAM_V1_6_Read_Group"@.
+newtype BAM_V1_6_Read_Group_Platform_Unit = BAM_V1_6_Read_Group_Platform_Unit { bam_v1_6_read_group_platform_unit_value :: ByteString
+                                                                              }
+  deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_Read_Group_Platform_Unit where
+  BAM_V1_6_Read_Group_Platform_Unit bam_v1_6_read_group_platform_unit_value1 ==
+    BAM_V1_6_Read_Group_Platform_Unit bam_v1_6_read_group_platform_unit_value2 =
+      bam_v1_6_read_group_platform_unit_value1 == bam_v1_6_read_group_platform_unit_value2
+
+instance Show BAM_V1_6_Read_Group_Platform_Unit where
+  show (BAM_V1_6_Read_Group_Platform_Unit value) =
+    "BAM_V1_6_Read_Group_Platform_Unit { "       ++
+    "bam_v1_6_read_group_platform_unit_value = " ++
+    (show value)                                 ++
+    " }"
+
+-- | SM tag for @"BAM_V1_6_Read_Group"@.
+newtype BAM_V1_6_Read_Group_Sample = BAM_V1_6_Read_Group_Sample { bam_v1_6_read_group_sample_value :: ByteString
+                                                                }
+  deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_Read_Group_Sample where
+  BAM_V1_6_Read_Group_Sample bam_v1_6_read_group_sample_value1 ==
+    BAM_V1_6_Read_Group_Sample bam_v1_6_read_group_sample_value2 =
+      bam_v1_6_read_group_sample_value1 == bam_v1_6_read_group_sample_value2
+
+instance Show BAM_V1_6_Read_Group_Sample where
+  show (BAM_V1_6_Read_Group_Sample value) =
+    "BAM_V1_6_Read_Group_Sample { "       ++
+    "bam_v1_6_read_group_sample_value = " ++
+    (show value)                          ++
+    " }"
diff --git a/src/Data/BAM/Version1_6/BAM/Header/SQ.hs b/src/Data/BAM/Version1_6/BAM/Header/SQ.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/BAM/Header/SQ.hs
@@ -0,0 +1,291 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE StrictData            #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.BAM.Header.SQ
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.BAM.Header.SQ ( -- * BAM version 1.6 Reference sequence dictionary data type
+                                           BAM_V1_6_Reference_Sequence_Dictionary(..),
+                                           -- * BAM version 1.6 Reference sequence dictionary data types
+                                           BAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Name(..),
+                                           BAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Length(..),
+                                           BAM_V1_6_Reference_Sequence_Dictionary_Alternative_Locus(..),
+                                           BAM_V1_6_Reference_Sequence_Dictionary_Alternative_Reference_Sequence_Names(..),
+                                           BAM_V1_6_Reference_Sequence_Dictionary_Genome_Assembly_Identifier(..),
+                                           BAM_V1_6_Reference_Sequence_Dictionary_Description(..),
+                                           BAM_V1_6_Reference_Sequence_Dictionary_MD5_Checksum(..),
+                                           BAM_V1_6_Reference_Sequence_Dictionary_Species(..),
+                                           BAM_V1_6_Reference_Sequence_Dictionary_Molecule_Topology(..),
+                                           BAM_V1_6_Reference_Sequence_Dictionary_URI(..)
+                                         ) where
+
+import Data.ByteString
+import Data.Data
+import Generics.Deriving.Base
+
+-- | Custom BAM (version 1.6) @"BAM_V1_6_Reference_Sequence_Dictionary"@ data type.
+--
+-- See section 4.2 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data BAM_V1_6_Reference_Sequence_Dictionary = BAM_V1_6_Reference_Sequence_Dictionary { bam_v1_6_reference_sequence_dictionary_reference_sequence_name                        :: BAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Name
+                                                                                     , bam_v1_6_reference_sequence_dictionary_reference_sequence_length                      :: BAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Length
+                                                                                     , bam_v1_6_reference_sequence_dictionary_alternative_locus                              :: Maybe BAM_V1_6_Reference_Sequence_Dictionary_Alternative_Locus
+                                                                                     , bam_v1_6_reference_sequence_dictionary_alternative_reference_sequence_names           :: Maybe BAM_V1_6_Reference_Sequence_Dictionary_Alternative_Reference_Sequence_Names
+                                                                                     , bam_v1_6_reference_sequence_dictionary_genome_assembly_identifier                     :: Maybe BAM_V1_6_Reference_Sequence_Dictionary_Genome_Assembly_Identifier
+                                                                                     , bam_v1_6_reference_sequence_dictionary_description                                    :: Maybe BAM_V1_6_Reference_Sequence_Dictionary_Description
+                                                                                     , bam_v1_6_reference_sequence_dictionary_md5_checksum                                   :: Maybe BAM_V1_6_Reference_Sequence_Dictionary_MD5_Checksum
+                                                                                     , bam_v1_6_reference_sequence_dictionary_species                                        :: Maybe BAM_V1_6_Reference_Sequence_Dictionary_Species
+                                                                                     , bam_v1_6_reference_sequence_dictionary_molecule_topology                              :: Maybe BAM_V1_6_Reference_Sequence_Dictionary_Molecule_Topology                                       
+                                                                                     , bam_v1_6_reference_sequence_dictionary_uri                                            :: Maybe BAM_V1_6_Reference_Sequence_Dictionary_URI 
+                                                                                     }
+  deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_Reference_Sequence_Dictionary where
+  BAM_V1_6_Reference_Sequence_Dictionary bam_v1_6_reference_sequence_dictionary_reference_sequence_name1
+                                         bam_v1_6_reference_sequence_dictionary_reference_sequence_length1
+                                         bam_v1_6_reference_sequence_dictionary_reference_alternative_locus1
+                                         bam_v1_6_reference_sequence_dictionary_reference_alternative_reference_sequence_names1
+                                         bam_v1_6_reference_sequence_dictionary_genome_assembly_identifier1
+                                         bam_v1_6_reference_sequence_dictionary_description1
+                                         bam_v1_6_reference_sequence_dictionary_md5_checksum1
+                                         bam_v1_6_reference_sequence_dictionary_species1
+                                         bam_v1_6_reference_sequence_dictionary_molecule_topology1
+                                         bam_v1_6_reference_sequence_dictionary_uri1 ==
+    BAM_V1_6_Reference_Sequence_Dictionary bam_v1_6_reference_sequence_dictionary_reference_sequence_name2
+                                           bam_v1_6_reference_sequence_dictionary_reference_sequence_length2
+                                           bam_v1_6_reference_sequence_dictionary_reference_alternative_locus2
+                                           bam_v1_6_reference_sequence_dictionary_reference_alternative_reference_sequence_names2
+                                           bam_v1_6_reference_sequence_dictionary_genome_assembly_identifier2
+                                           bam_v1_6_reference_sequence_dictionary_description2
+                                           bam_v1_6_reference_sequence_dictionary_md5_checksum2
+                                           bam_v1_6_reference_sequence_dictionary_species2
+                                           bam_v1_6_reference_sequence_dictionary_molecule_topology2
+                                           bam_v1_6_reference_sequence_dictionary_uri2 =
+      bam_v1_6_reference_sequence_dictionary_reference_sequence_name1                        == bam_v1_6_reference_sequence_dictionary_reference_sequence_name2                        &&
+      bam_v1_6_reference_sequence_dictionary_reference_sequence_length1                      == bam_v1_6_reference_sequence_dictionary_reference_sequence_length2                      &&
+      bam_v1_6_reference_sequence_dictionary_reference_alternative_locus1                    == bam_v1_6_reference_sequence_dictionary_reference_alternative_locus2                    &&
+      bam_v1_6_reference_sequence_dictionary_reference_alternative_reference_sequence_names1 == bam_v1_6_reference_sequence_dictionary_reference_alternative_reference_sequence_names2 &&
+      bam_v1_6_reference_sequence_dictionary_genome_assembly_identifier1                     == bam_v1_6_reference_sequence_dictionary_genome_assembly_identifier2                     &&
+      bam_v1_6_reference_sequence_dictionary_description1                                    == bam_v1_6_reference_sequence_dictionary_description2                                    &&
+      bam_v1_6_reference_sequence_dictionary_md5_checksum1                                   == bam_v1_6_reference_sequence_dictionary_md5_checksum2                                   &&
+      bam_v1_6_reference_sequence_dictionary_species1                                        == bam_v1_6_reference_sequence_dictionary_species2                                        &&
+      bam_v1_6_reference_sequence_dictionary_molecule_topology1                              == bam_v1_6_reference_sequence_dictionary_molecule_topology2                              &&
+      bam_v1_6_reference_sequence_dictionary_uri1                                            == bam_v1_6_reference_sequence_dictionary_uri2
+
+instance Show BAM_V1_6_Reference_Sequence_Dictionary where
+  show (BAM_V1_6_Reference_Sequence_Dictionary reference_sequence_name
+                                               reference_sequence_length
+                                               reference_alternative_locus
+                                               reference_alternative_sequence_names
+                                               genome_assembly_identifier
+                                               description
+                                               md5_checksum
+                                               species
+                                               molecule_topology
+                                               uri
+       ) =
+    "BAM_V1_6_Reference_Sequence_Dictionary { "                                         ++
+    "bam_v1_6_reference_sequence_dictionary_reference_sequence_name = "                 ++
+    (show reference_sequence_name)                                                      ++
+    " , bam_v1_6_reference_sequence_dictionary_reference_sequence_length = "            ++
+    (show reference_sequence_length)                                                    ++
+    " , bam_v1_6_reference_sequence_dictionary_alternative_locus = "                    ++
+    (show reference_alternative_locus)                                                  ++
+    " , bam_v1_6_reference_sequence_dictionary_alternative_reference_sequence_names = " ++
+    (show reference_alternative_sequence_names)                                         ++
+    " , bam_v1_6_reference_sequence_dictionary_genome_assembly_identifier = "           ++
+    (show genome_assembly_identifier)                                                   ++
+    " , bam_v1_6_reference_sequence_dictionary_description = "                          ++
+    (show description)                                                                  ++
+    " , bam_v1_6_reference_sequence_dictionary_md5_checksum = "                         ++
+    (show md5_checksum)                                                                 ++
+    " , bam_v1_6_reference_sequence_dictionary_species = "                              ++
+    (show species)                                                                      ++
+    " , bam_v1_6_reference_sequence_dictionary_molecule_topology = "                    ++
+    (show molecule_topology)                                                            ++
+    " , bam_v1_6_reference_sequence_dictionary_uri = "                                  ++
+    (show uri)                                                                          ++
+    " }"
+
+-- | SN tag for @"BAM_V1_6_Reference_Sequence_Dictionary"@.
+newtype BAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Name = BAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Name { bam_v1_6_reference_sequence_dictionary_reference_sequence_name_value :: ByteString 
+                                                                                                                                        }
+  deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Name where
+  BAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Name bam_v1_6_reference_sequence_dictionary_reference_sequence_name_value1 ==
+    BAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Name bam_v1_6_reference_sequence_dictionary_reference_sequence_name_value2 =
+      bam_v1_6_reference_sequence_dictionary_reference_sequence_name_value1 == bam_v1_6_reference_sequence_dictionary_reference_sequence_name_value2  
+
+instance Show BAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Name where
+  show (BAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Name value) =
+    "BAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Name { "       ++
+    "bam_v1_6_reference_sequence_dictionary_reference_sequence_name_value = " ++
+    (show value)                                                              ++
+    " }"
+
+-- | LN tag for @"BAM_V1_6_Reference_Sequence_Dictionary"@.
+newtype BAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Length = BAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Length { bam_v1_6_reference_sequence_dictionary_reference_sequence_length_value :: ByteString
+                                                                                                                                            }
+  deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Length where
+  BAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Length bam_v1_6_reference_sequence_dictionary_reference_sequence_length_value1 ==
+    BAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Length bam_v1_6_reference_sequence_dictionary_reference_sequence_length_value2 =
+      bam_v1_6_reference_sequence_dictionary_reference_sequence_length_value1 == bam_v1_6_reference_sequence_dictionary_reference_sequence_length_value2
+
+instance Show BAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Length where
+  show (BAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Length value) =
+    "BAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Length { "       ++
+    "bam_v1_6_reference_sequence_dictionary_reference_sequence_length_value = " ++
+    (show value)                                                                ++
+    " }"
+
+-- | AH tag for @"BAM_V1_6_Reference_Sequence_Dictionary"@.
+newtype BAM_V1_6_Reference_Sequence_Dictionary_Alternative_Locus = BAM_V1_6_Reference_Sequence_Dictionary_Alternative_Locus { bam_v1_6_reference_sequence_dictionary_alternative_locus_value :: ByteString
+                                                                                                                            }
+  deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_Reference_Sequence_Dictionary_Alternative_Locus where
+  BAM_V1_6_Reference_Sequence_Dictionary_Alternative_Locus bam_v1_6_reference_sequence_dictionary_alternative_locus_value1 ==
+    BAM_V1_6_Reference_Sequence_Dictionary_Alternative_Locus bam_v1_6_reference_sequence_dictionary_alternative_locus_value2 =
+      bam_v1_6_reference_sequence_dictionary_alternative_locus_value1 == bam_v1_6_reference_sequence_dictionary_alternative_locus_value2
+
+instance Show BAM_V1_6_Reference_Sequence_Dictionary_Alternative_Locus where
+  show (BAM_V1_6_Reference_Sequence_Dictionary_Alternative_Locus value) =
+    "BAM_V1_6_Reference_Sequence_Dictionary_Alternative_Locus { "       ++
+    "bam_v1_6_reference_sequence_dictionary_alternative_locus_value = " ++
+    (show value)                                                        ++
+    " }"
+
+-- | AN tag for @"BAM_V1_6_Reference_Sequence_Dictionary"@.
+newtype BAM_V1_6_Reference_Sequence_Dictionary_Alternative_Reference_Sequence_Names = BAM_V1_6_Reference_Sequence_Dictionary_Alternative_Reference_Sequence_Names { bam_v1_6_reference_sequence_dictionary_alternative_reference_sequence_names_value :: ByteString
+                                                                                                                                                                  }
+  deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_Reference_Sequence_Dictionary_Alternative_Reference_Sequence_Names where
+  BAM_V1_6_Reference_Sequence_Dictionary_Alternative_Reference_Sequence_Names bam_v1_6_reference_sequence_dictionary_alternative_reference_sequence_names_value1 ==
+    BAM_V1_6_Reference_Sequence_Dictionary_Alternative_Reference_Sequence_Names bam_v1_6_reference_sequence_dictionary_alternative_reference_sequence_names_value2 =
+      bam_v1_6_reference_sequence_dictionary_alternative_reference_sequence_names_value1 == bam_v1_6_reference_sequence_dictionary_alternative_reference_sequence_names_value2
+
+instance Show BAM_V1_6_Reference_Sequence_Dictionary_Alternative_Reference_Sequence_Names where
+  show (BAM_V1_6_Reference_Sequence_Dictionary_Alternative_Reference_Sequence_Names value) =
+    "BAM_V1_6_Reference_Sequence_Dictionary_Alternative_Reference_Sequence_Names { "       ++
+    "bam_v1_6_reference_sequence_dictionary_alternative_reference_sequence_names_value = " ++
+    (show value)                                                                           ++
+    " }"
+
+-- | AS tag for @"BAM_V1_6_Reference_Sequence_Dictionary"@.
+newtype BAM_V1_6_Reference_Sequence_Dictionary_Genome_Assembly_Identifier = BAM_V1_6_Reference_Sequence_Dictionary_Genome_Assembly_Identifier { bam_v1_6_reference_sequence_dictionary_genome_assembly_identifier_value :: ByteString
+                                                                                                                                              }
+  deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_Reference_Sequence_Dictionary_Genome_Assembly_Identifier where
+  BAM_V1_6_Reference_Sequence_Dictionary_Genome_Assembly_Identifier bam_v1_6_reference_sequence_dictionary_genome_assembly_identifier_value1 ==
+    BAM_V1_6_Reference_Sequence_Dictionary_Genome_Assembly_Identifier bam_v1_6_reference_sequence_dictionary_genome_assembly_identifier_value2 =
+      bam_v1_6_reference_sequence_dictionary_genome_assembly_identifier_value1 == bam_v1_6_reference_sequence_dictionary_genome_assembly_identifier_value2
+
+instance Show BAM_V1_6_Reference_Sequence_Dictionary_Genome_Assembly_Identifier where
+  show (BAM_V1_6_Reference_Sequence_Dictionary_Genome_Assembly_Identifier value) =
+    "BAM_V1_6_Reference_Sequence_Dictionary_Genome_Assembly_Identifier { "       ++
+    "bam_v1_6_reference_sequence_dictionary_genome_assembly_identifier_value = " ++
+    (show value)                                                                 ++
+    " }"
+
+-- | DS tag for @"BAM_V1_6_Reference_Sequence_Dictionary"@.
+newtype BAM_V1_6_Reference_Sequence_Dictionary_Description = BAM_V1_6_Reference_Sequence_Dictionary_Description { bam_v1_6_reference_sequence_dictionary_description_value :: ByteString
+                                                                                                                }
+  deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_Reference_Sequence_Dictionary_Description where
+  BAM_V1_6_Reference_Sequence_Dictionary_Description bam_v1_6_reference_sequence_dictionary_description_value1 ==
+    BAM_V1_6_Reference_Sequence_Dictionary_Description bam_v1_6_reference_sequence_dictionary_description_value2 =
+      bam_v1_6_reference_sequence_dictionary_description_value1 == bam_v1_6_reference_sequence_dictionary_description_value2
+
+instance Show BAM_V1_6_Reference_Sequence_Dictionary_Description where
+  show (BAM_V1_6_Reference_Sequence_Dictionary_Description value) =
+    "BAM_V1_6_Reference_Sequence_Dictionary_Description { "       ++
+    "bam_v1_6_reference_sequence_dictionary_description_value = " ++
+    (show value)                                                  ++
+    " }"
+
+-- | M5 tag for @"BAM_V1_6_Reference_Sequence_Dictionary"@.
+newtype BAM_V1_6_Reference_Sequence_Dictionary_MD5_Checksum = BAM_V1_6_Reference_Sequence_Dictionary_MD5_Checksum { bam_v1_6_reference_sequence_dictionary_md5_checksum_value :: ByteString
+                                                                                                                  }
+  deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_Reference_Sequence_Dictionary_MD5_Checksum where
+  BAM_V1_6_Reference_Sequence_Dictionary_MD5_Checksum bam_v1_6_reference_sequence_dictionary_md5_checksum_value1 ==
+    BAM_V1_6_Reference_Sequence_Dictionary_MD5_Checksum bam_v1_6_reference_sequence_dictionary_md5_checksum_value2 =
+      bam_v1_6_reference_sequence_dictionary_md5_checksum_value1 == bam_v1_6_reference_sequence_dictionary_md5_checksum_value2
+
+instance Show BAM_V1_6_Reference_Sequence_Dictionary_MD5_Checksum where
+  show (BAM_V1_6_Reference_Sequence_Dictionary_MD5_Checksum value) =
+    "BAM_V1_6_Reference_Sequence_Dictionary_MD5_Checksum { "       ++
+    "bam_v1_6_reference_sequence_dictionary_md5_checksum_value = " ++
+    (show value)                                                   ++
+    " }"
+
+-- | SP tag for @"BAM_V1_6_Reference_Sequence_Dictionary"@.
+newtype BAM_V1_6_Reference_Sequence_Dictionary_Species = BAM_V1_6_Reference_Sequence_Dictionary_Species { bam_v1_6_reference_sequence_dictionary_species_value :: ByteString
+                                                                                                        }
+  deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_Reference_Sequence_Dictionary_Species where
+  BAM_V1_6_Reference_Sequence_Dictionary_Species bam_v1_6_reference_sequence_dictionary_species_value1 ==
+    BAM_V1_6_Reference_Sequence_Dictionary_Species bam_v1_6_reference_sequence_dictionary_species_value2 =
+      bam_v1_6_reference_sequence_dictionary_species_value1 == bam_v1_6_reference_sequence_dictionary_species_value2
+
+instance Show BAM_V1_6_Reference_Sequence_Dictionary_Species where
+  show (BAM_V1_6_Reference_Sequence_Dictionary_Species value) =
+    "BAM_V1_6_Reference_Sequence_Dictionary_Species { "       ++
+    "bam_v1_6_reference_sequence_dictionary_species_value = " ++
+    (show value)                                              ++
+    " }"
+
+-- | TP tag for @"BAM_V1_6_Reference_Sequence_Dictionary"@.
+newtype BAM_V1_6_Reference_Sequence_Dictionary_Molecule_Topology = BAM_V1_6_Reference_Sequence_Dictionary_Molecule_Topology { bam_v1_6_reference_sequence_dictionary_molecule_topology_value :: ByteString
+                                                                                                                            }
+  deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_Reference_Sequence_Dictionary_Molecule_Topology where
+  BAM_V1_6_Reference_Sequence_Dictionary_Molecule_Topology bam_v1_6_reference_sequence_dictionary_molecule_topology_value1 ==
+    BAM_V1_6_Reference_Sequence_Dictionary_Molecule_Topology bam_v1_6_reference_sequence_dictionary_molecule_topology_value2 =
+      bam_v1_6_reference_sequence_dictionary_molecule_topology_value1 == bam_v1_6_reference_sequence_dictionary_molecule_topology_value2
+
+instance Show BAM_V1_6_Reference_Sequence_Dictionary_Molecule_Topology where
+  show (BAM_V1_6_Reference_Sequence_Dictionary_Molecule_Topology value) =
+    "BAM_V1_6_Reference_Sequence_Dictionary_Molecule_Topology { "       ++
+    "bam_v1_6_reference_sequence_dictionary_molecule_topology_value = " ++
+    (show value)                                                        ++
+    " }"
+
+-- | UR tag for @"BAM_V1_6_Reference_Sequence_Dictionary"@.
+newtype BAM_V1_6_Reference_Sequence_Dictionary_URI = BAM_V1_6_Reference_Sequence_Dictionary_URI { bam_v1_6_reference_sequence_dictionary_uri_value :: ByteString
+                                                                                                }
+  deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_Reference_Sequence_Dictionary_URI where
+  BAM_V1_6_Reference_Sequence_Dictionary_URI bam_v1_6_reference_sequence_dictionary_uri_value1 ==
+    BAM_V1_6_Reference_Sequence_Dictionary_URI bam_v1_6_reference_sequence_dictionary_uri_value2 =
+      bam_v1_6_reference_sequence_dictionary_uri_value1 == bam_v1_6_reference_sequence_dictionary_uri_value2
+
+instance Show BAM_V1_6_Reference_Sequence_Dictionary_URI where
+  show (BAM_V1_6_Reference_Sequence_Dictionary_URI value) =
+    "BAM_V1_6_Reference_Sequence_Dictionary_URI { "       ++
+    "bam_v1_6_reference_sequence_dictionary_uri_value = " ++
+    (show value)                                          ++
+    " }"
diff --git a/src/Data/BAM/Version1_6/BAM/ReferenceInformation.hs b/src/Data/BAM/Version1_6/BAM/ReferenceInformation.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/BAM/ReferenceInformation.hs
@@ -0,0 +1,38 @@
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.BAM.ReferenceInformation
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = WARNING
+--
+-- This module is considered __internal__.
+--
+-- The Package Versioning Policy __does not apply__.
+--
+-- The contents of this module may change __in any way whatsoever__
+-- and __without any warning__ between minor versions of this package.
+--
+-- Authors importing this library are expected to track development
+-- closely.
+--
+-- All credit goes to the author(s)/maintainer(s) of the
+-- [containers](https://hackage.haskell.org/package/containers) library
+-- for the above warning text.
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.BAM.ReferenceInformation ( -- * BAM version 1.6 reference information mandatory and optional data types (RE-EXPORT)
+                                                      module Data.BAM.Version1_6.BAM.ReferenceInformation.Base
+                                                    ) where
+
+-- | Re-exports.
+import Data.BAM.Version1_6.BAM.ReferenceInformation.Base
diff --git a/src/Data/BAM/Version1_6/BAM/ReferenceInformation/Base.hs b/src/Data/BAM/Version1_6/BAM/ReferenceInformation/Base.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/BAM/ReferenceInformation/Base.hs
@@ -0,0 +1,62 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE StrictData            #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.BAM.ReferenceInformation.Base
+-- Copyright   :  (c) Matthew Mosior 2023
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.BAM.ReferenceInformation.Base ( -- * BAM_V1_6_BAM_Reference_Information version 1.6 data type
+                                                           BAM_V1_6_BAM_Reference_Information(..)
+                                                         ) where
+
+import Data.ByteString
+import Data.Data
+import Data.Word
+import Generics.Deriving.Base
+
+-- | Custom @"BAM_V1_6_BAM_Reference_Information"@ (BAM version 1.6) data type.
+--
+-- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data BAM_V1_6_BAM_Reference_Information = BAM_V1_6_BAM_Reference_Information
+  { bam_v1_6_bam_reference_information_l_name :: Word32     -- ^ Length of the reference name plus 1 (including NUL).
+  , bam_v1_6_bam_reference_information_name   :: ByteString -- ^ Reference sequence name; NUL terminated.
+  , bam_v1_6_bam_reference_information_l_ref  :: Word32     -- ^ Length of the reference sequence.
+  } deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_BAM_Reference_Information where
+  BAM_V1_6_BAM_Reference_Information bam_v1_6_bam_reference_information_l_name1
+                                     bam_v1_6_bam_reference_information_name1
+                                     bam_v1_6_bam_reference_information_l_ref1 ==
+    BAM_V1_6_BAM_Reference_Information bam_v1_6_bam_reference_information_l_name2
+                                       bam_v1_6_bam_reference_information_name2
+                                       bam_v1_6_bam_reference_information_l_ref2 =
+      bam_v1_6_bam_reference_information_l_name1 == bam_v1_6_bam_reference_information_l_name2 &&
+      bam_v1_6_bam_reference_information_name1   == bam_v1_6_bam_reference_information_name2   &&
+      bam_v1_6_bam_reference_information_l_ref1  == bam_v1_6_bam_reference_information_l_ref2
+
+instance Show BAM_V1_6_BAM_Reference_Information where
+  show (BAM_V1_6_BAM_Reference_Information l_name
+                                           name
+                                           l_ref
+       ) =
+    "BAM_V1_6_BAM_Reference_Information { "          ++
+    "bam_v1_6_bam_reference_information_l_name = "   ++
+    (show l_name)                                    ++
+    " , bam_v1_6_bam_reference_information_name = "  ++
+    (show name)                                      ++
+    " , bam_v1_6_bam_reference_information_l_ref = " ++
+    (show l_ref)                                     ++
+    " }"
diff --git a/src/Data/BAM/Version1_6/BGZFBlock.hs b/src/Data/BAM/Version1_6/BGZFBlock.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/BGZFBlock.hs
@@ -0,0 +1,112 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE StrictData            #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.BGZFBlock
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.BGZFBlock ( -- * BAM_V1_6_BGZFBlock version 1.6 data type
+                                       BAM_V1_6_BGZFBlock(..)
+                                     ) where
+
+import Data.BAM.Version1_6.BAM
+import Data.BAM.Version1_6.GZipHeader
+
+import Data.Data
+import Data.Word
+import Generics.Deriving.Base
+
+-- | Custom @"BAM_V1_6_BGZFBlock"@ (BAM version 1.6) data type.
+--
+-- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data BAM_V1_6_BGZFBlock = BAM_V1_6_BGZFBlock
+  { bam_v1_6_bgzfblock_gzip_header                :: BAM_V1_6_GZipHeader -- ^ GZip 10 byte header.
+                                                                         -- This contains a magic number (1f 08),
+                                                                         -- the compression method (08 for DEFLATE),
+                                                                         -- 1-byte of header flags,
+                                                                         -- a 4-byte timestamp,
+                                                                         -- compression flags,
+                                                                         -- and the operating system ID.
+  , bam_v1_6_bgzfblock_subfield_identifier_one    :: Word8               -- ^ This should be 'B'.
+  , bam_v1_6_bgzfblock_subfield_identifier_two    :: Word8               -- ^ This should be 'C'.
+  , bam_v1_6_bgzfblock_subfield_length            :: Word16              -- ^ This should be '02 00'.
+  , bam_v1_6_bgzfblock_total_block_size_minus_one :: Word16              -- ^ The payload of the BGZF
+                                                                         -- extra field is a 16-bit unsigned
+                                                                         -- integer in little endian format.
+                                                                         -- This integer gives the size of the
+                                                                         -- containing BGZF block minus one.
+  , bam_v1_6_bgzfblock_cdata                      :: BAM_V1_6_BAM        -- ^ Compressed DATA by zlib::deflate().
+                                                                         -- The data in this field will be
+                                                                         -- in a decompressed and
+                                                                         -- useable state.
+  , bam_v1_6_bgzfblock_crc32                      :: Word32              -- ^ CRC-32.
+  , bam_v1_6_bgzfblock_isize                      :: Word32              -- ^ Input SIZE (length of uncompressed data).
+  } deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_BGZFBlock where
+  BAM_V1_6_BGZFBlock bam_v1_6_bgzfblock_gzip_header1
+                     bam_v1_6_bgzfblock_subfield_identifier_one1
+                     bam_v1_6_bgzfblock_subfield_identifier_two1
+                     bam_v1_6_bgzfblock_subfield_length1
+                     bam_v1_6_bgzfblock_total_block_size_minus_one1
+                     bam_v1_6_bgzfblock_cdata1
+                     bam_v1_6_bgzfblock_crc321
+                     bam_v1_6_bgzfblock_isize1 ==
+    BAM_V1_6_BGZFBlock bam_v1_6_bgzfblock_gzip_header2
+                       bam_v1_6_bgzfblock_subfield_identifier_one2
+                       bam_v1_6_bgzfblock_subfield_identifier_two2
+                       bam_v1_6_bgzfblock_subfield_length2
+                       bam_v1_6_bgzfblock_total_block_size_minus_one2
+                       bam_v1_6_bgzfblock_cdata2
+                       bam_v1_6_bgzfblock_crc322
+                       bam_v1_6_bgzfblock_isize2 =
+      bam_v1_6_bgzfblock_gzip_header1                == bam_v1_6_bgzfblock_gzip_header2                &&
+      bam_v1_6_bgzfblock_subfield_identifier_one1    == bam_v1_6_bgzfblock_subfield_identifier_one2    &&
+      bam_v1_6_bgzfblock_subfield_identifier_two1    == bam_v1_6_bgzfblock_subfield_identifier_two2    &&
+      bam_v1_6_bgzfblock_subfield_length1            == bam_v1_6_bgzfblock_subfield_length2            &&
+      bam_v1_6_bgzfblock_total_block_size_minus_one1 == bam_v1_6_bgzfblock_total_block_size_minus_one2 &&
+      bam_v1_6_bgzfblock_cdata1                      == bam_v1_6_bgzfblock_cdata2                      &&
+      bam_v1_6_bgzfblock_crc321                      == bam_v1_6_bgzfblock_crc322                      &&
+      bam_v1_6_bgzfblock_isize1                      == bam_v1_6_bgzfblock_isize2
+
+instance Show BAM_V1_6_BGZFBlock where
+  show (BAM_V1_6_BGZFBlock gzip_header
+                           subfield_identifier_one
+                           subfield_identifier_two
+                           subfield_length
+                           total_block_size_minus_one
+                           cdata
+                           crc32
+                           isize
+       ) =
+    "BAM_V1_6_BGZFBlock { "                               ++
+    "bam_v1_6_bgzfblock_gzip_header = "                   ++
+    (show gzip_header)                                    ++
+    " , bam_v1_6_bgzfblock_subfield_identifier_one = "    ++
+    (show subfield_identifier_one)                        ++
+    " , bam_v1_6_bgzfblock_subfield_identifier_two = "    ++
+    (show subfield_identifier_two)                        ++
+    " , bam_v1_6_bgzfblock_subfield_length = "            ++
+    (show subfield_length)                                ++
+    " , bam_v1_6_bgzfblock_total_block_size_minus_one = " ++
+    (show total_block_size_minus_one)                     ++
+    " , bam_v1_6_bgzfblock_cdata = "                      ++
+    (show cdata)                                          ++
+    " , bam_v1_6_bgzfblock_crc32 = "                      ++
+    (show crc32)                                          ++
+    " , bam_v1_6_bgzfblock_isize = "                      ++
+    (show isize)                                          ++
+    " }"
diff --git a/src/Data/BAM/Version1_6/Base.hs b/src/Data/BAM/Version1_6/Base.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/Base.hs
@@ -0,0 +1,51 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE StrictData            #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.Base
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.Base ( -- * BAM_V1_6 version 1.6 data type
+                                  BAM_V1_6(..)
+                                ) where
+
+import Data.BAM.Version1_6.BGZFBlock
+
+import Data.Data
+import Data.Sequence
+import Generics.Deriving.Base
+
+-- | Custom @"BAM_V1_6"@ (BAM version 1.6) newtype.
+--
+-- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+newtype BAM_V1_6 = BAM_V1_6
+  { bam_v1_6 :: Seq BAM_V1_6_BGZFBlock -- ^ Sequence holding all
+                                       -- BGZF blocks of data
+                                       -- within the BAM file.
+  } deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6 where
+  BAM_V1_6 bam_v1_61 ==
+    BAM_V1_6 bam_v1_62 =
+      bam_v1_61 == bam_v1_62
+
+instance Show BAM_V1_6 where
+  show (BAM_V1_6 bam
+       ) =
+    "BAM_V1_6 { " ++
+    "bam_v1_6 = " ++
+    (show bam)    ++
+    " }"
diff --git a/src/Data/BAM/Version1_6/GZipHeader.hs b/src/Data/BAM/Version1_6/GZipHeader.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/GZipHeader.hs
@@ -0,0 +1,98 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE StrictData            #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.GZipHeader
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.GZipHeader ( -- * BAM_V1_6_GZipHeader version 1.6 data type
+                                        BAM_V1_6_GZipHeader(..)
+                                      ) where
+
+import Data.Data
+import Data.Word
+import Generics.Deriving.Base
+
+-- | Custom @"BAM_V1_6_GZipHeader"@ (BAM version 1.6) data type.
+--
+-- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data BAM_V1_6_GZipHeader = BAM_V1_6_GZipHeader
+  { bam_v1_6_gzip_header_gzip_identifier_1   :: Word8  -- ^ Magic number 1f (0x1f).
+  , bam_v1_6_gzip_header_gzip_identifier_2   :: Word8  -- ^ Magic number 08 (0x08).
+  , bam_v1_6_gzip_header_compression_method  :: Word8  -- ^ Compression method (08 for DEFLATE).
+  , bam_v1_6_gzip_header_header_flags        :: Word8  -- ^ 1-byte for header flags.
+  , bam_v1_6_gzip_header_modification_time   :: Word32 -- ^ 4-byte timestamp.
+  , bam_v1_6_gzip_header_extra_flags         :: Word8  -- ^ 1-byte eXtra FLags.
+  , bam_v1_6_gzip_header_operating_system    :: Word8  -- ^ The operating system id.
+  , bam_v1_6_gzip_header_extra_length        :: Word16 -- ^ If FLG.FEXTRA is set,
+                                                       -- this gives the length of the optional
+                                                       -- extra field.
+  } deriving (Generic,Typeable)
+
+instance Eq BAM_V1_6_GZipHeader where
+  BAM_V1_6_GZipHeader bam_v1_6_gzip_header_gzip_identifier_11
+                      bam_v1_6_gzip_header_gzip_identifier_21
+                      bam_v1_6_gzip_header_compression_method1
+                      bam_v1_6_gzip_header_header_flags1
+                      bam_v1_6_gzip_header_modification_time1
+                      bam_v1_6_gzip_header_extra_flags1
+                      bam_v1_6_gzip_header_operating_system_id1
+                      bam_v1_6_gzip_header_extra_length1 ==
+    BAM_V1_6_GZipHeader bam_v1_6_gzip_header_gzip_identifier_12
+                        bam_v1_6_gzip_header_gzip_identifier_22
+                        bam_v1_6_gzip_header_compression_method2
+                        bam_v1_6_gzip_header_header_flags2
+                        bam_v1_6_gzip_header_modification_time2
+                        bam_v1_6_gzip_header_extra_flags2
+                        bam_v1_6_gzip_header_operating_system_id2
+                        bam_v1_6_gzip_header_extra_length2 =
+      bam_v1_6_gzip_header_gzip_identifier_11   == bam_v1_6_gzip_header_gzip_identifier_12   &&
+      bam_v1_6_gzip_header_gzip_identifier_21   == bam_v1_6_gzip_header_gzip_identifier_22   &&
+      bam_v1_6_gzip_header_compression_method1  == bam_v1_6_gzip_header_compression_method2  &&
+      bam_v1_6_gzip_header_header_flags1        == bam_v1_6_gzip_header_header_flags2        &&
+      bam_v1_6_gzip_header_modification_time1   == bam_v1_6_gzip_header_modification_time2   &&
+      bam_v1_6_gzip_header_extra_flags1         == bam_v1_6_gzip_header_extra_flags2         &&
+      bam_v1_6_gzip_header_operating_system_id1 == bam_v1_6_gzip_header_operating_system_id2 &&
+      bam_v1_6_gzip_header_extra_length1        == bam_v1_6_gzip_header_extra_length2
+
+instance Show BAM_V1_6_GZipHeader where
+  show (BAM_V1_6_GZipHeader gzip_identifier_1
+                            gzip_identifier_2
+                            compression_method
+                            header_flags
+                            modification_time
+                            extra_flags
+                            operating_system_id
+                            extra_length
+       ) =
+    "BAM_V1_6_GZipHeader { "                         ++
+    "bam_v1_6_gzip_header_gzip_identifier_1 = "      ++
+    (show gzip_identifier_1)                         ++
+    " , bam_v1_6_gzip_header_gzip_identifier_2 = "   ++
+    (show gzip_identifier_2)                         ++
+    " , bam_v1_6_gzip_header_compression_method = "  ++
+    (show compression_method)                        ++
+    " , bam_v1_6_gzip_header_header_flags = "        ++
+    (show header_flags)                              ++
+    " , bam_v1_6_gzip_header_modification_time = "   ++
+    (show modification_time)                         ++
+    " , bam_v1_6_gzip_header_extra_flags = "         ++
+    (show extra_flags)                               ++
+    " , bam_v1_6_gzip_header_operating_system_id = " ++
+    (show operating_system_id)                       ++
+    " , bam_v1_6_gzip_header_extra_length = "        ++
+    (show extra_length)                              ++
+    " }"
diff --git a/src/Data/BAM/Version1_6/Internal.hs b/src/Data/BAM/Version1_6/Internal.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/Internal.hs
@@ -0,0 +1,335 @@
+{-# LANGUAGE FlexibleContexts #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.Internal
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = WARNING
+--
+-- This module is considered __internal__.
+--
+-- The Package Versioning Policy __does not apply__.
+--
+-- The contents of this module may change __in any way whatsoever__
+-- and __without any warning__ between minor versions of this package.
+--
+-- Authors importing this library are expected to track development
+-- closely.
+--
+-- All credit goes to the author(s)/maintainer(s) of the
+-- [containers](https://hackage.haskell.org/package/containers) library
+-- for the above warning text.
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.Internal ( -- * BAM version 1.6 internal functions
+                                      bytestringToFloatLE
+                                    , byteStringToIntLE 
+                                    , byteStringToWord16LE
+                                    , floatToByteStringLE
+                                    , intToByteStringLE
+                                    , intToWord16LE
+                                    , intToWord32LE
+                                    , int8ToByteString
+                                    , int16ToByteStringLE
+                                    , int32ToByteStringLE
+                                    , maybeOption
+                                    , splitByteString
+                                    , word8sToInt8LE
+                                    , word8sToInt16LE
+                                    , word8sToInt32LE
+                                    , word8sToWord8LE
+                                    , word8sToWord16LE
+                                    , word8sToWord32LE
+                                    , word32ToByteStringLE
+                                    , word16ToByteStringLE
+                                    , word16ToByteString
+                                    , word16ToIntLE
+                                    ) where
+
+import Data.Attoparsec.ByteString.Lazy
+import Data.Binary.Get                 (runGet,getFloatle)
+import Data.Binary.Put                 (runPut,putFloatle,putInt64le)
+import Data.Bits
+import Data.ByteString as DB
+import Data.ByteString.Builder
+import Data.Int
+import Data.Word
+
+-- | Make a parser optional, return Nothing if there is no match.
+maybeOption :: Parser a
+            -> Parser (Maybe a)
+maybeOption p =
+  option Nothing
+         (Just <$> p)
+
+-- | Convert a little-endian Word16 to an Int.
+word16ToIntLE :: Word16
+              -> Int
+word16ToIntLE w = do
+  let signedValue = fromIntegral w :: Int
+      -- Check if the most significant bit (sign bit) is set
+      isNegative = testBit signedValue 15
+  case isNegative of
+    True  ->
+      signedValue - 65536  -- If negative, subtract 2^16
+    False ->
+      signedValue
+
+-- | Split a ByteString into chunks of n bytes.
+splitByteString :: Int
+                -> ByteString
+                -> [ByteString]
+splitByteString n bs =
+  case (DB.null bs) of
+    True  ->
+      []
+    False ->
+      case (DB.length bs `mod` n /= 0) of
+        True  ->
+          error $
+            "ByteString length must be a multiple of " ++
+            (show n)                                   ++
+            "."
+        False ->
+          let (chunk,rest) = DB.splitAt n
+                                        bs
+            in chunk : splitByteString n
+                                       rest
+
+-- | Convert a ByteString to a Float (IEEE 754 binary32).
+bytestringToFloatLE :: ByteString
+                    -> Float
+bytestringToFloatLE bs =
+  case (DB.length bs == 4) of
+    True  ->
+      runGet getFloatle $
+        fromStrict bs
+    False ->
+      error "ByteString must contain exactly 4 bytes"
+
+-- | Convert a ByteString (little-endian) to an Int.
+byteStringToIntLE :: ByteString
+                  -> Int
+byteStringToIntLE bs =
+  Prelude.foldr go 0 (Prelude.zip [0..]
+                                  (DB.unpack bs)
+                     )
+  where
+    go :: (Int,Word8)
+       -> Int
+       -> Int
+    go (i,b)
+       acc = acc
+             .|.
+             ( fromIntegral b
+               `shiftL`
+               (8 * i)
+             )
+
+-- | Convert a ByteString to [Word16] in little-endian format.
+byteStringToWord16LE :: ByteString
+                     -> [Word16]
+byteStringToWord16LE bs
+  | DB.length bs `mod` 2 /= 0 = error "ByteString must have an even length."
+  | otherwise = go bs
+                   []
+  where
+    go :: ByteString
+       -> [Word16]
+       -> [Word16]
+    go input acc
+      | DB.null input = Prelude.reverse acc -- Stop processing when no bytes are left
+      | otherwise     =
+          let byte1  = fromIntegral (DB.index input 0) :: Word16 -- LSB
+              byte2  = fromIntegral (DB.index input 1) :: Word16 -- MSB
+              word16 = byte1 .|. (byte2 `shiftL` 8) -- Combine bytes in little-endian order
+            in go ( DB.drop 2
+                            input
+                  )
+                  ( word16 : acc
+                  ) -- Recursively process the rest
+
+-- | Convert a [Word8] to a Int8 (little endian).
+word8sToInt8LE :: [Word8]
+               -> Int8
+word8sToInt8LE [ b0
+               ] = fromIntegral b0
+word8sToInt8LE _ = error "List must contain exactly 1 Word8 element."
+
+-- | Convert a [Word8] to a Int16 (little endian).
+word8sToInt16LE :: [Word8]
+                -> Int16
+word8sToInt16LE [ b0
+                , b1
+                ] = 
+  ( fromIntegral b0
+  ) .|.
+  ( fromIntegral b1
+    `shiftL`
+    8
+  )
+word8sToInt16LE _ = error "List must contain exactly 2 Word8 elements."
+
+-- | Convert a [Word8] to a Int32 (little endian).
+word8sToInt32LE :: [Word8]
+              -> Int32
+word8sToInt32LE [ b0
+                , b1
+                , b2
+                , b3
+                ] = 
+  (fromIntegral b0
+  ) .|.
+  ( fromIntegral b1
+    `shiftL`
+    8
+  ) .|.
+  ( fromIntegral b2
+    `shiftL`
+    16
+  ) .|.
+  ( fromIntegral b3
+    `shiftL`
+    24
+  )
+word8sToInt32LE _ = error "List must contain exactly 4 Word8 elements."
+
+-- | Convert a [Word8] to a Word8 (little endian).
+word8sToWord8LE :: [Word8]
+                -> Word8
+word8sToWord8LE [ b0
+                ] = b0
+word8sToWord8LE _ = error "List must contain exactly 1 Word8 element."
+
+-- | Convert a [Word8] to a Word16 (little endian).
+word8sToWord16LE :: [Word8]
+                 -> Word16
+word8sToWord16LE [ b0
+                 , b1
+                 ] = 
+  ( fromIntegral b0
+  ) .|.
+  ( fromIntegral b1
+    `shiftL`
+    8
+  )
+word8sToWord16LE _ = error "List must contain exactly 2 Word8 elements."
+
+-- | Convert a [Word8] to a Word32 (little endian).
+word8sToWord32LE :: [Word8]
+                 -> Word32
+word8sToWord32LE [ b0
+                 , b1
+                 , b2
+                 , b3
+                 ] =
+  ( fromIntegral b0
+  ) .|.
+  ( fromIntegral b1
+    `shiftL`
+    8
+  ) .|.
+  ( fromIntegral b2
+    `shiftL`
+    16
+  ) .|.
+  ( fromIntegral b3
+    `shiftL`
+    24
+  )
+word8sToWord32LE _ = error "List must contain exactly 4 Word8 elements."
+
+-- Convert Word16 to ByteString.
+word16ToByteString :: Word16
+                   -> ByteString
+word16ToByteString w =
+  DB.pack [ fromIntegral (w `shiftR` 8)
+          , fromIntegral (w .&. 0xFF)
+          ]
+
+-- | Convert a Word16 in little endian
+-- byte order to a ByteString.
+word16ToByteStringLE :: Word16
+                     -> ByteString
+word16ToByteStringLE w =
+  DB.toStrict        $
+    toLazyByteString $
+      word16LE w
+
+-- | Convert a Word32 in little endian
+-- byte order to a ByteString.
+word32ToByteStringLE :: Word32
+                     -> ByteString
+word32ToByteStringLE w =
+  DB.toStrict        $
+    toLazyByteString $
+      word32LE w
+
+-- | Convert a Int in little endian
+-- byte order to a ByteString.
+intToByteStringLE :: Int
+                  -> ByteString
+intToByteStringLE i =
+  DB.toStrict    $
+    runPut       $
+      putInt64le $
+        fromIntegral i
+
+-- | Convert an Int in little-endian
+-- byte order to a Word16.
+intToWord16LE :: Int
+              -> Word16
+intToWord16LE i
+  | i >= 0 && i <= 0xFFFF = fromIntegral i
+  | otherwise             = error "Int value is out of Word16 range"
+
+-- | Convert an Int little-endian
+-- byte order to a Word32.
+intToWord32LE :: Int
+              -> Word32
+intToWord32LE i
+  | i >= 0    = fromIntegral i
+  | otherwise = error "Int value must be non-negative"
+
+-- | Convert a Int8 in little endian
+-- byte order to a ByteString.
+int8ToByteString :: Int8
+                 -> ByteString
+int8ToByteString i =
+  DB.toStrict        $
+    toLazyByteString $
+      int8 i
+
+-- | Convert a Int16 in little endian
+-- byte order to a ByteString.
+int16ToByteStringLE :: Int16
+                    -> ByteString
+int16ToByteStringLE i =
+  DB.toStrict        $
+    toLazyByteString $
+      int16LE i
+
+-- | Convert a Int32 in little endian
+-- byte order to a ByteString.
+int32ToByteStringLE :: Int32
+                    -> ByteString
+int32ToByteStringLE i =
+  DB.toStrict        $
+    toLazyByteString $
+      int32LE i
+
+-- | Convert a Float in little endian
+-- byte order to a ByteString.
+-- See https://stackoverflow.com/questions/6976684/converting-ieee-754-floating-point-in-haskell-word32-64-to-and-from-haskell-floa
+floatToByteStringLE :: Float
+                    -> ByteString
+floatToByteStringLE f =
+  DB.toStrict $
+    runPut    $
+      putFloatle f
diff --git a/src/Data/BAM/Version1_6/Read/Base.hs b/src/Data/BAM/Version1_6/Read/Base.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/Read/Base.hs
@@ -0,0 +1,113 @@
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.Read.Base
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.Read.Base ( -- * Reading
+                                       readBAM_V1_6
+                                     ) where
+
+import Data.BAM.Version1_6.Base
+import Data.BAM.Version1_6.Read.Error 
+import Data.BAM.Version1_6.Read.Parser.BGZFBlock
+
+import           Data.Attoparsec.ByteString.Lazy   as DABL
+import           Data.ByteString                   as DB
+import           Data.ByteString.Lazy              as DBL
+import           Data.Sequence                     as DSeq
+import qualified Streamly.Data.Stream              as S
+import           Streamly.External.ByteString.Lazy as StreamlyLByteString  (fromChunksIO)
+import           Streamly.Internal.FileSystem.File as StreamlyInternalFile (chunkReader)
+import qualified System.IO                         as SIO
+
+-- | Define the @"BAM_V1_6"@ parser.
+parse_BAM_V1_6 :: Parser BAM_V1_6
+parse_BAM_V1_6 = do
+  bgzfblocks <-
+    DABL.many' parse_BAM_V1_6_BGZFBlock
+  return BAM_V1_6
+          { bam_v1_6 = DSeq.fromList bgzfblocks
+          }
+
+-- | Run the @"SAM_V1_6"@ parser.
+readBAM_V1_6_LBS :: DBL.ByteString
+                 -> IO BAM_V1_6
+readBAM_V1_6_LBS lbs =
+  case (DABL.parseOnly parse_BAM_V1_6 lbs) of 
+    Left  samparseerror ->
+      error samparseerror
+    Right sam           ->
+      return sam
+
+-- | Read a @"BAM_V1_6"@ from a file.
+--
+-- The file is checked for errors as it is parsed.
+--
+-- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+readBAM_V1_6 :: FilePath -- ^ Input path to BAM file.
+             -> IO BAM_V1_6
+readBAM_V1_6 fp = do
+  -- Ensure that BAM file is intact
+  -- by checking for end-of-file
+  -- marker.
+  bamfileh        <-
+    SIO.openBinaryFile fp
+                       SIO.ReadMode
+  _               <-
+    SIO.hSeek bamfileh
+              SIO.SeekFromEnd
+              (-28)
+  endoffilemarker <-
+    DB.hGetContents bamfileh
+  case ( endoffilemarker == endoffilemarkerbytes
+       ) of
+    False ->
+      error $
+        show BAM_V1_6_Read_Error_End_Of_File_Marker_Incorrect_Format
+    True  -> do
+      let lazybamfile = S.unfold StreamlyInternalFile.chunkReader fp
+      lazybamfilef    <-
+        StreamlyLByteString.fromChunksIO lazybamfile
+      readBAM_V1_6_LBS lazybamfilef
+  where
+    endoffilemarkerbytes = DB.pack 
+                             [ 0x1f
+                             , 0x8b
+                             , 0x08
+                             , 0x04
+                             , 0x00
+                             , 0x00
+                             , 0x00
+                             , 0x00
+                             , 0x00
+                             , 0xff
+                             , 0x06
+                             , 0x00
+                             , 0x42
+                             , 0x43
+                             , 0x02
+                             , 0x00
+                             , 0x1b
+                             , 0x00
+                             , 0x03
+                             , 0x00
+                             , 0x00
+                             , 0x00
+                             , 0x00
+                             , 0x00
+                             , 0x00
+                             , 0x00
+                             , 0x00
+                             , 0x00
+                             ]
diff --git a/src/Data/BAM/Version1_6/Read/Error.hs b/src/Data/BAM/Version1_6/Read/Error.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/Read/Error.hs
@@ -0,0 +1,319 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE StrictData            #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.Read.Error
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.Read.Error ( -- * BAM version 1.6 data type
+                                        BAM_V1_6_Read_Error(..)
+                                      ) where
+
+import Data.Data
+import Generics.Deriving.Base
+
+-- | Custom @"BAM_V1_6_Read_Error"@ (BAM version 1.6) error data type.
+-- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data BAM_V1_6_Read_Error = -- | Identification 1 (IDentification 1; ID1) field
+                           -- of the GZip header not in accepted format.
+                           BAM_V1_6_Read_Error_GZipHeader_ID1_Incorrect_Format
+                           -- | Identification 2 (IDentification 2; ID2) field
+                           -- of the GZip header not in accepted format.
+                         | BAM_V1_6_Read_Error_GZipHeader_ID2_Incorrect_Format
+                           -- | Compression Method (CM) field of the GZip header not
+                           -- in accepted format.
+                         | BAM_V1_6_Read_Error_GZipHeader_Compression_Method_Incorrect_Format
+                           -- | Flag (FLG) field of the GZip header not in accepted format.
+                         | BAM_V1_6_Read_Error_GZipHeader_Flag_Incorrect_Format
+                           -- | Modification TIME (MTIME) field of the GZip header not
+                           -- in accepted format.
+                         | BAM_V1_6_Read_Error_GZipHeader_Modification_TIME_Incorrect_Format
+                           -- | Extra flags (eXtra FLags; XFL) field of the GZip header
+                           -- not in accepted format.
+                         | BAM_V1_6_Read_Error_GZipHeader_Extra_Flags_Incorrect_Format
+                           -- | Operating System (OS) field of the GZip header
+                           -- not in accepted format.
+                         | BAM_V1_6_Read_Error_GZipHeader_Operating_System_Incorrect_Format
+                           -- | Extra Length (eXtra LENgth; XLEN) field of the
+                           -- GZip header is not in accepted format.
+                         | BAM_V1_6_Read_Error_GZipHeader_Extra_Length_Incorrect_Format
+                           -- | Subfield Identifier 1 (Subfield Identifier1; SI1)
+                           -- field of the GZip header is not in accepted format.
+                         | BAM_V1_6_Read_Error_GZipHeader_Subfield_Identifier_1_Incorrect_Format
+                           -- | Subfield Identifier 2 (Subfield Identifier2; SI2)
+                           -- field of the GZip header is not in accepted format.
+                         | BAM_V1_6_Read_Error_GZipHeader_Subfield_Identifier_2_Incorrect_Format
+                           -- | Subfield Length (Subfield LENgth; SLEN)
+                           -- field of the GZip header is not in accepted format.
+                         | BAM_V1_6_Read_Error_GZipHeader_Subfield_Length_Incorrect_Format
+                           -- | Total block size minus 1 (total Block SIZE minus 1; BSIZE)
+                           -- field of the GZip header is not in accepted format.
+                         | BAM_V1_6_Read_Error_GZipHeader_Total_Block_SIZE_Minus_1_Incorrect_Format
+                           -- | Compressed DATA by zlib::deflate() (CDATA) is not
+                           -- in accepted format.
+                         | BAM_V1_6_Read_Error_GZipHeader_Compressed_DATA_Incorrect_Format
+                           -- | @HD tag not in accepted format (only important
+                           -- if @HD tag is present).
+                         | BAM_V1_6_Read_Error_File_Level_Metadata_Tag_Incorrect_Format
+                           -- | VN tag missing (only important
+                           -- if @HD tag is present).
+                         | BAM_V1_6_Read_Error_File_Level_Metadata_Format_Version_Tag_Missing
+                           -- | VN tag not in accepted format (only important
+                           -- if @HD tag is present).
+                         | BAM_V1_6_Read_Error_File_Level_Metadata_Format_Version_Tag_Incorrect_Format
+                           -- | VN value not in accepted format (only important
+                           -- if @HD tag is present).
+                         | BAM_V1_6_Read_Error_File_Level_Metadata_Format_Version_Value_Incorrect_Format
+                           -- | Sorting order tag not in accepted format (only important
+                           -- if @HD tag is present).
+                         | BAM_V1_6_Read_Error_File_Level_Metadata_Sorting_Order_Tag_Incorrect_Format
+                           -- | Sorting order invalid value (only important
+                           -- if @HD tag is present).
+                         | BAM_V1_6_Read_Error_File_Level_Metadata_Sorting_Order_Invalid_Value
+                           -- | Grouping of alignments no in accepted format (only important
+                           -- if @HD tag is present).
+                         | BAM_V1_6_Read_Error_File_Level_Metadata_Grouping_Of_Alignments_Tag_Incorrect_Format
+                           -- | Grouping of Alignments invalid value (only important
+                           -- if @HD tag is present).
+                         | BAM_V1_6_Read_Error_File_Level_Metadata_Grouping_Of_Alignments_Invalid_Value
+                           -- | Subsorting order tag not in accepted format (only important
+                           -- if @HD tag is present).
+                         | BAM_V1_6_Read_Error_File_Level_Metadata_Subsorting_Order_Tag_Incorrect_Format
+                           -- | Subsorting order of alignments not in accepted format (only
+                           -- if @HD tag is present.
+                         | BAM_V1_6_Read_Error_File_Level_Metadata_Subsorting_Order_Incorrect_Format
+                           -- | The BAM magic string in the BAM header is not BAM\SOH (BAM\1).
+                         | BAM_V1_6_Read_Error_BAMHeader_BAM_Magic_String_Invalid_Value
+                           -- | SN tag missing (only important
+                           -- if @SQ tag is present).
+                         | BAM_V1_6_Read_Error_Reference_Sequence_Dictionary_Reference_Sequence_Name_Tag_Missing
+                           -- | Reference Sequence Name not in accepted format (only important
+                           -- if @SQ tag is present.
+                         | BAM_V1_6_Read_Error_Reference_Sequence_Dictionary_Reference_Sequence_Name_Incorrect_Format
+                           -- | Reference Sequence Name invalid value (only important
+                           -- if @SQ tag is present).
+                         | BAM_V1_6_Read_Error_Reference_Sequence_Dictionary_Reference_Sequence_Name_Invalid_Value
+                           -- | LN tag missing (only important
+                           -- if @SQ tag is present).
+                         |  BAM_V1_6_Error_Reference_Sequence_Dictionary_Reference_Sequence_Length_Missing
+                           -- | Reference Sequence Length not in accepted format (only important
+                           -- if @SQ tag is present.
+                         | BAM_V1_6_Read_Error_Reference_Sequence_Dictionary_Reference_Sequence_Length_Incorrect_Format
+                           -- | Reference Sequence Length invalid value (only important
+                           -- if @SQ tag is present).
+                         | BAM_V1_6_Read_Error_Reference_Sequence_Dictionary_Reference_Sequence_Length_Invalid_Value
+                           -- | Alternative locus not in accepted format (only important
+                           -- if @SQ tag is present).
+                         | BAM_V1_6_Read_Error_Reference_Sequence_Dictionary_Alternative_Locus_Incorrect_Format
+                           -- | Alternative Reference Sequence Names not in accepted format (only important
+                           -- if @SQ tag is present).
+                         | BAM_V1_6_Read_Error_Reference_Sequence_Dictionary_Alternative_Reference_Sequence_Names_Incorrect_Format
+                           -- | Alternative Reference Sequence Names invalid value (only important
+                           -- if @SQ tag is present).
+                         | BAM_V1_6_Read_Error_Reference_Sequence_Dictionary_Alternative_Reference_Sequence_Names_Invalid_Value
+                           -- | Genome Assembly Identifier not in accepted format (only important
+                           -- if @SQ tag is present).
+                         | BAM_V1_6_Read_Error_Reference_Sequence_Dictionary_Genome_Assembly_Identifier_Incorrect_Format
+                           -- | Description not in accepted format (only important
+                           -- if @SQ tag is present).
+                         | BAM_V1_6_Read_Error_Reference_Sequence_Dictionary_Description_Incorrect_Format
+                           -- | MD5 checksum not in accepted format (only important
+                           -- if @SQ tag is present).
+                         | BAM_V1_6_Read_Error_Reference_Sequence_Dictionary_MD5_Checksum_Incorrect_Format
+                           -- | Species not in accepted format (only important
+                           -- if @SQ tag is present).
+                         | BAM_V1_6_Read_Error_Reference_Sequence_Dictionary_Species_Incorrect_Format
+                           -- | Molecule topology not in accepted format (only important
+                           -- if @SQ tag is present).
+                         | BAM_V1_6_Read_Error_Reference_Sequence_Dictionary_Molecule_Topology_Incorrect_Format
+                           -- | Molecule topology invalid value (only important
+                           -- if @SQ tag is present).
+                         | BAM_V1_6_Read_Error_Reference_Sequence_Dictionary_Molecule_Topology_Invalid_Value
+                           -- | URI not in accepted format (only important
+                           -- if @SQ tag is present).
+                         | BAM_V1_6_Read_Error_Reference_Sequence_Dictionary_URI_Incorrect_Format
+                           -- | ID tag not accepted format (only important
+                           -- if @RG tag is present).
+                         | BAM_V1_6_Read_Error_Read_Group_Read_Group_Identifier_Incorrect_Format
+                           -- | ID tag is missing (only important
+                           -- if @RG tag is present).
+                         | BAM_V1_6_Read_Error_Read_Group_Read_Group_Identifier_Tag_Missing
+                           -- | BC tag not in accepted format (only important
+                           -- if @RG tag is present).
+                         | BAM_V1_6_Read_Error_Read_Group_Barcode_Sequence_Incorrect_Format
+                           -- | CN tag not in accepted format (only important
+                           -- if @RG tag is present).
+                         | BAM_V1_6_Read_Error_Read_Group_Sequencing_Center_Incorrect_Format
+                           -- | DS tag not in accepted format (only important
+                           -- if @RG tag is present).
+                         | BAM_V1_6_Read_Error_Read_Group_Description_Incorrect_Format
+                           -- | DT tag not in accepted format (only important
+                           -- if @RG tag is present).
+                         | BAM_V1_6_Read_Error_Read_Group_Date_Run_Produced_Incorrect_Format
+                           -- | FO tag not in accepted format (only important
+                           -- if @RG tag is present).
+                         | BAM_V1_6_Read_Error_Read_Group_Flow_Order_Incorrect_Format
+                           -- | KS tag not in accepted format (only important
+                           -- if @RG tag is present).
+                         | BAM_V1_6_Read_Error_Read_Group_Key_Sequence_Incorrect_Format
+                           -- | LB tag not in accepted format (only important
+                           -- if @RG tag is present).
+                         | BAM_V1_6_Read_Error_Read_Group_Library_Incorrect_Format
+                           -- | PG tag not in accepted format (only important
+                           -- if @RG tag is present).
+                         | BAM_V1_6_Read_Error_Read_Group_Programs_Incorrect_Format
+                           -- | PI tag not in accepted format (only important
+                           -- if @RG tag is present).
+                         | BAM_V1_6_Read_Error_Read_Group_Predicted_Median_Insert_Size_Incorrect_Format
+                           -- | PL tag not in accepted format (only important
+                           -- if @RG tag is present).
+                         | BAM_V1_6_Read_Error_Read_Group_Platform_Incorrect_Format
+                           -- | PM tag not in accepted format (only important
+                           -- if @RG tag is present).
+                         | BAM_V1_6_Read_Error_Read_Group_Platform_Model_Incorrect_Format
+                           -- | PU tag not in accepted format (only important
+                           -- if @RG tag is present).
+                         | BAM_V1_6_Read_Error_Read_Group_Platform_Unit_Incorrect_Format
+                           -- | SM tag not in accepted format (only important
+                           -- if @RG tag is present).
+                         | BAM_V1_6_Read_Error_Read_Group_Sample_Incorrect_Format
+                           -- | RG tag not in accepted format.
+                         | BAM_V1_6_Read_Error_Read_Group_Tag_Incorrect_Format
+                           -- | ID tag not in accepted format (only important
+                           -- if @PG tag is present).
+                         | BAM_V1_6_Read_Error_Program_Identifier_Incorrect_Format
+                           -- | PN tag not in accepted format (only important
+                           -- if @PG tag is present).
+                         | BAM_V1_6_Read_Error_Program_Name_Incorrect_Format
+                           -- | CL tag not in accepted format (only important
+                           -- if @PG tag is present).
+                         | BAM_V1_6_Read_Error_Program_Command_Line_Incorrect_Format
+                           -- | PP tag not in accepted format (only important
+                           -- if @PG tag is present).
+                         | BAM_V1_6_Read_Error_Program_Previous_PG_ID_Incorrect_Format
+                           -- | DS tag not in accepted format (only important
+                           -- if @PG tag is present).
+                         | BAM_V1_6_Read_Error_Program_Description_Incorrect_Format
+                           -- | VN tag not in accepted format (only important
+                           -- if @PG tag is present).
+                         | BAM_V1_6_Read_Error_Program_Version_Incorrect_Format
+                           -- | PG tag not in accepted format.
+                         | BAM_V1_6_Read_Error_Program_Tag_Incorrect_Format
+                           -- | CO tag not in accepted format.
+                         | BAM_V1_6_Read_Error_One_Line_Comment_Tag_Incorrect_Format
+                           -- | QNAME of alignment section not in accepted format.
+                         | BAM_V1_6_Read_Error_Alignment_QNAME_Incorrect_Format
+                           -- | FLAG of alignment section not in accepted format.
+                         | BAM_V1_6_Read_Error_Alignment_FLAG_Incorrect_Format
+                           -- | RNAME of alignment section not in accepted format.
+                         | BAM_V1_6_Read_Error_Alignment_RNAME_Incorrect_Format
+                           -- | POS of alignment section not in accepted format.
+                         | BAM_V1_6_Read_Error_Alignment_POS_Incorrect_Format
+                           -- | MAPQ of alignment section not in accepted format.
+                         | BAM_V1_6_Read_Error_Alignment_MAPQ_Incorrect_Format
+                           -- | CIGAR of alignment section not in accepted format.
+                         | BAM_V1_6_Read_Error_Alignment_CIGAR_Incorrect_Format
+                           -- | RNEXT of alignment section not in accepted format.
+                         | BAM_V1_6_Read_Error_Alignment_RNEXT_Incorrect_Format
+                           -- | PNEXT of alignment section not in accepted format.
+                         | BAM_V1_6_Read_Error_Alignment_PNEXT_Incorrect_Format
+                           -- | TLEN of alignment section not in accpepted format.
+                         | BAM_V1_6_Read_Error_Alignment_TLEN_Incorrect_Format
+                           -- | SEQ of alignment section not in accepted format.
+                         | BAM_V1_6_Read_Error_Alignment_SEQ_Incorrect_Format
+                           -- | QUAL of alignment section not in accepted format.
+                         | BAM_V1_6_Read_Error_Alignment_QUAL_Incorrect_Format
+                           -- | Optional field is missing a type.
+                         | BAM_V1_6_Read_Error_Alignment_OptionalFields_Missing_Type
+                           -- | Optional field BOPT is missing a type.
+                         | BAM_V1_6_Read_Error_Alignment_OptionalFields_BOPT_Missing_Type
+                           -- | Optional field doesn't have a type.
+                         | BAM_V1_6_Read_Error_Alignment_OptionalFields_Index_Missing
+                           -- | Optional field has left-over bytes following parsing.
+                         | BAM_V1_6_Read_Error_Alignment_OptionalFields_Remaining_Bytes
+                           -- | AOPT tag of the alignment section not in accepted format.
+                         | BAM_V1_6_Read_Error_Alignment_AOPT_Tag_Incorrect_Format
+                           -- | AOPT type of the alignment section not in accepted format.
+                         | BAM_V1_6_Read_Error_Alignment_AOPT_Type_Incorrect_Format
+                           -- | AOPT value of the alignment section not in accepted format.
+                         | BAM_V1_6_Read_Error_Alignment_AOPT_Value_Incorrect_Format
+                           -- | BigCOPT tag of the alignment section not in accepted format.
+                         | BAM_V1_6_Read_Error_Alignment_BigCOPT_Tag_Incorrect_Format
+                           -- | BigCOPT type of the alignment section not in accepted format.
+                         | BAM_V1_6_Read_Error_Alignment_BigCOPT_Type_Incorrect_Format
+                           -- | BigIOPT tag of the alignment section not in accepted format.
+                         | BAM_V1_6_Read_Error_Alignment_BigIOPT_Tag_Incorrect_Format
+                           -- | BigIOPT type of the alignment section not in accepted format.
+                         | BAM_V1_6_Read_Error_Alignment_BigIOPT_Type_Incorrect_Format
+                           -- | BigSOPT tag of the alignment section not in accepted format.
+                         | BAM_V1_6_Read_Error_Alignment_BigSOPT_Tag_Incorrect_Format
+                           -- | BigSOPT type of the alignment section not in accepted format.
+                         | BAM_V1_6_Read_Error_Alignment_BigSOPT_Type_Incorrect_Format
+                           -- | SmallCOPT tag of the alignment section not in accepted format.
+                         | BAM_V1_6_Read_Error_Alignment_SmallCOPT_Tag_Incorrect_Format
+                           -- | SmallCOPT type of the alignment section not in accepted format.
+                         | BAM_V1_6_Read_Error_Alignment_SmallCOPT_Type_Incorrect_Format
+                           -- | SmallIOPT tag of the alignment section not in accepted format.
+                         | BAM_V1_6_Read_Error_Alignment_SmallIOPT_Tag_Incorrect_Format
+                           -- | SmallIOPT type of the alignment section not in accepted format.
+                         | BAM_V1_6_Read_Error_Alignment_SmallIOPT_Type_Incorrect_Format
+                           -- | SmallSOPT tag of the alignment section not in accepted format.
+                         | BAM_V1_6_Read_Error_Alignment_SmallSOPT_Tag_Incorrect_Format
+                           -- | SmallSOPT type of the alignment section not in accepted format.
+                         | BAM_V1_6_Read_Error_Alignment_SmallSOPT_Type_Incorrect_Format
+                           -- | FOPT tag of the alignment section not in accepted format.
+                         | BAM_V1_6_Read_Error_Alignment_FOPT_Tag_Incorrect_Format
+                           -- | FOPT type of the alignment section not in accepted format.
+                         | BAM_V1_6_Read_Error_Alignment_FOPT_Type_Incorrect_Format
+                           -- | FOPT value of the alignment section not in accepted format.
+                         | BAM_V1_6_Read_Error_Alignment_FOPT_Value_Incorrect_Format
+                           -- | ZOPT tag of the alignment section not in accepted format.
+                         | BAM_V1_6_Read_Error_Alignment_ZOPT_Tag_Incorrect_Format
+                           -- | ZOPT type of the alignment section not in accepted format.
+                         | BAM_V1_6_Read_Error_Alignment_ZOPT_Type_Incorrect_Format
+                           -- | ZOPT value of the alignment section not in accepted format.
+                         | BAM_V1_6_Read_Error_Alignment_ZOPT_Value_Incorrect_Format
+                           -- | HOPT tag of the alignment section not in accepted format.
+                         | BAM_V1_6_Read_Error_Alignment_HOPT_Tag_Incorrect_Format
+                           -- | HOPT type of the alignment section not in accepted format.
+                         | BAM_V1_6_Read_Error_Alignment_HOPT_Type_Incorrect_Format
+                           -- | HOPT value of the alignment section not in accepted format.
+                         | BAM_V1_6_Read_Error_Alignment_HOPT_Value_Incorrect_Format
+                           -- | BOPT tag of the alignment section not in accepted format.
+                         | BAM_V1_6_Read_Error_Alignment_BOPT_Tag_Incorrect_Format
+                           -- | BOPT type of the alignment section not in accepted format.
+                         | BAM_V1_6_Read_Error_Alignment_BOPT_Type_Incorrect_Format
+                           -- | BOPT value type of the alignment section not in accepted format.
+                         | BAM_V1_6_Read_Error_Alignment_BOPT_Value_Type_Incorrect_Format
+                           -- | BOPT value data of the alignment section not in accepted format.
+                         | BAM_V1_6_Read_Error_Alignment_BOPT_Value_Data_Incorrect_Format
+                           -- | The CDATA field of a BGZF block not in accepted format.
+                         | BAM_V1_6_Read_Error_CDATA_Incorrect_Format
+                           -- | A CDATA BAM block alignment optional fields
+                           -- are not in accepted format.
+                         | BAM_V1_6_Read_Error_CDATA_BAM_Alignment_Optional_Fields_Incorrect_Format
+                           -- | CRC-32 (CRC32) field of the GZip header
+                           -- not in accepted format.
+                         | BAM_V1_6_Read_Error_GZipHeader_CRC32_Incorrect_Format
+                           -- | Input Size (Input SIZE, i.e. length of uncompressed data)
+                           -- not in accepted format.
+                         | BAM_V1_6_Read_Error_GZipHeader_Input_Size_Incorrect_Format
+                           -- | The calculated crc32 of the uncompressed CDATA
+                           -- is not equivalent to the CRC32 field of the BGZF block.
+                         | BAM_V1_6_Read_Error_Calculated_CRC32_Not_Equivalent_To_CRC32
+                           -- | The last 28 bytes of the BAM file are not equivalent
+                           -- to the standardized 28 byte end-of-file marker.
+                         | BAM_V1_6_Read_Error_End_Of_File_Marker_Incorrect_Format 
+  deriving (Eq,Generic,Show,Typeable)
diff --git a/src/Data/BAM/Version1_6/Read/Parser/BAM/Alignment/Base.hs b/src/Data/BAM/Version1_6/Read/Parser/BAM/Alignment/Base.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/Read/Parser/BAM/Alignment/Base.hs
@@ -0,0 +1,1117 @@
+{-# LANGUAGE DeriveDataTypeable          #-}
+{-# LANGUAGE DeriveGeneric               #-}
+{-# LANGUAGE FlexibleContexts            #-}
+{-# LANGUAGE FlexibleInstances           #-}
+{-# LANGUAGE MultiParamTypeClasses       #-}
+{-# LANGUAGE OverloadedLists             #-}
+{-# LANGUAGE OverloadedStrings           #-}
+{-# LANGUAGE MultiWayIf                  #-}
+{-# LANGUAGE RecordWildCards             #-}
+{-# LANGUAGE TypeFamilies                #-}
+{-# LANGUAGE ViewPatterns                #-}
+{-# Language QuasiQuotes                 #-}
+{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.Read.Parser.BAM.Alignment.Base
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = WARNING
+--
+-- This module is considered __internal__.
+--
+-- The Package Versioning Policy __does not apply__.
+--
+-- The contents of this module may change __in any way whatsoever__
+-- and __without any warning__ between minor versions of this package.
+--
+-- Authors importing this library are expected to track development
+-- closely.
+--
+-- All credit goes to the author(s)/maintainer(s) of the
+-- [containers](https://hackage.haskell.org/package/containers) library
+-- for the above warning text.
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.Read.Parser.BAM.Alignment.Base ( -- * BAM_V1_6_BAM parser - alignment section
+                                                            parse_BAM_V1_6_BAM_Alignment
+                                                          ) where
+
+import Data.BAM.Version1_6.BAM.Alignment
+import Data.BAM.Version1_6.BAM.Alignment.OptionalFields.Base
+import Data.BAM.Version1_6.Read.Error 
+import Data.BAM.Version1_6.Internal
+import Data.BAM.Version1_6.Read.Parser.BAM.Alignment.Internal
+import Data.BAM.Version1_6.Read.Parser.BAM.Alignment.OptionalFields.AOPT
+import Data.BAM.Version1_6.Read.Parser.BAM.Alignment.OptionalFields.BigCOPT
+import Data.BAM.Version1_6.Read.Parser.BAM.Alignment.OptionalFields.BigIOPT
+import Data.BAM.Version1_6.Read.Parser.BAM.Alignment.OptionalFields.BigSOPT
+import Data.BAM.Version1_6.Read.Parser.BAM.Alignment.OptionalFields.SmallCOPT
+import Data.BAM.Version1_6.Read.Parser.BAM.Alignment.OptionalFields.SmallIOPT
+import Data.BAM.Version1_6.Read.Parser.BAM.Alignment.OptionalFields.SmallSOPT
+import Data.BAM.Version1_6.Read.Parser.BAM.Alignment.OptionalFields.FOPT
+import Data.BAM.Version1_6.Read.Parser.BAM.Alignment.OptionalFields.ZOPT
+import Data.BAM.Version1_6.Read.Parser.BAM.Alignment.OptionalFields.HOPT
+import Data.BAM.Version1_6.Read.Parser.BAM.Alignment.OptionalFields.BOPT
+
+import Data.Attoparsec.ByteString.Lazy  as DABL
+import Data.ByteString                  as DB hiding (intercalate,map)
+import Data.List                                     (intercalate)
+import Data.Sequence                    as DSeq      (empty,fromList,singleton,Seq(..))
+
+-- | @"BAM_V1_6_BAM_Alignment"@ parser.
+--
+-- Defines a parser for the alignment section of the BAM v1.6 file format.
+--
+-- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+parse_BAM_V1_6_BAM_Alignment :: Parser BAM_V1_6_BAM_Alignment
+parse_BAM_V1_6_BAM_Alignment = do
+  block_size  <-
+    DABL.take 4
+  refID       <-
+    DABL.take 4
+  pos         <-
+    DABL.take 4
+  l_read_name <-
+    DABL.take 1
+  mapq        <-
+    DABL.take 1
+  bin         <-
+    DABL.take 2
+  n_cigar_op  <-
+    DABL.take 2
+  flag        <-
+    DABL.take 2
+  l_seq       <-
+    DABL.take 4
+  next_refID  <-
+    DABL.take 4 
+  next_pos    <-
+    DABL.take 4
+  tlen        <-
+    DABL.take 4
+  read_name   <-
+    DABL.take
+      ( fromIntegral      $
+          word8sToWord8LE $
+            DB.unpack l_read_name :: Int
+      )
+  cigar       <-
+    DABL.take
+      ( ( ( fromIntegral       $
+              word8sToWord16LE $
+                DB.unpack n_cigar_op
+          ) * 4
+        ) :: Int
+      )
+  seq         <-
+    DABL.take
+      ( ( ( ( fromIntegral       $
+                word8sToWord32LE $
+                  DB.unpack l_seq
+            ) + 1
+          ) `div` 2
+        ) :: Int
+      )
+  qual        <-
+    DABL.take
+      ( fromIntegral       $
+          word8sToWord32LE $
+            DB.unpack l_seq :: Int
+      )
+  let bytesuptooptionalfields = 4                                             + 
+                                4                                             +
+                                1                                             +
+                                1                                             + 
+                                2                                             +
+                                2                                             +
+                                2                                             +
+                                4                                             +
+                                4                                             +
+                                4                                             +
+                                4                                             +
+                                ( fromIntegral      $
+                                    word8sToWord8LE $
+                                      DB.unpack l_read_name :: Int
+                                )                                             +
+                                ( ( ( fromIntegral       $
+                                        word8sToWord16LE $
+                                          DB.unpack n_cigar_op
+                                    ) * 4
+                                  ) :: Int
+                                )                                             +
+                                ( ( ( ( fromIntegral       $
+                                          word8sToWord32LE $
+                                            DB.unpack l_seq
+                                      ) + 1
+                                    ) `div` 2
+                                  ) :: Int
+                                )                                             +
+                                ( fromIntegral       $
+                                    word8sToWord32LE $
+                                      DB.unpack l_seq
+                                ) :: Int
+  let block_size_int = fromIntegral       $
+                         word8sToWord32LE $
+                           DB.unpack block_size :: Int
+  case (bytesuptooptionalfields == block_size_int) of
+    True ->
+      return BAM_V1_6_BAM_Alignment
+               { bam_v1_6_bam_alignment_block_size     = word8sToWord32LE $
+                                                           DB.unpack block_size
+               , bam_v1_6_bam_alignment_refID          = word8sToInt32LE $
+                                                           DB.unpack refID
+               , bam_v1_6_bam_alignment_pos            = word8sToInt32LE $
+                                                           DB.unpack pos
+               , bam_v1_6_bam_alignment_l_read_name    = word8sToWord8LE $
+                                                           DB.unpack l_read_name
+               , bam_v1_6_bam_alignment_mapq           = word8sToWord8LE $
+                                                           DB.unpack mapq
+               , bam_v1_6_bam_alignment_bin            = word8sToWord16LE $
+                                                           DB.unpack bin
+               , bam_v1_6_bam_alignment_n_cigar_op     = word8sToWord16LE $
+                                                           DB.unpack n_cigar_op
+               , bam_v1_6_bam_alignment_flag           = word8sToWord16LE $
+                                                           DB.unpack flag
+               , bam_v1_6_bam_alignment_l_seq          = word8sToWord32LE $
+                                                           DB.unpack l_seq
+               , bam_v1_6_bam_alignment_next_refID     = word8sToInt32LE $
+                                                           DB.unpack next_refID
+               , bam_v1_6_bam_alignment_next_pos       = word8sToInt32LE $
+                                                           DB.unpack next_pos
+               , bam_v1_6_bam_alignment_tlen           = word8sToInt32LE $
+                                                           DB.unpack tlen
+               , bam_v1_6_bam_alignment_read_name      = read_name
+               , bam_v1_6_bam_alignment_cigar          = DSeq.fromList                        $
+                                                           map (word8sToWord32LE . DB.unpack) $
+                                                             splitByteString 4
+                                                                             cigar
+               , bam_v1_6_bam_alignment_seq            = DSeq.fromList $
+                                                           decodeSeqField seq
+               , bam_v1_6_bam_alignment_qual           = qual
+               , bam_v1_6_bam_alignment_optionalfields = DSeq.singleton
+                                                           BAM_V1_6_BAM_Alignment_OptionalFields
+                                                             { bam_v1_6_bam_alignment_optionalfields_aopt        = Nothing
+                                                             , bam_v1_6_bam_alignment_optionalfields_smallcopt   = Nothing
+                                                             , bam_v1_6_bam_alignment_optionalfields_bigcopt     = Nothing
+                                                             , bam_v1_6_bam_alignment_optionalfields_smalliopt   = Nothing
+                                                             , bam_v1_6_bam_alignment_optionalfields_bigiopt     = Nothing
+                                                             , bam_v1_6_bam_alignment_optionalfields_smallsopt   = Nothing
+                                                             , bam_v1_6_bam_alignment_optionalfields_bigsopt     = Nothing
+                                                             , bam_v1_6_bam_alignment_optionalfields_fopt        = Nothing
+                                                             , bam_v1_6_bam_alignment_optionalfields_zopt        = Nothing
+                                                             , bam_v1_6_bam_alignment_optionalfields_hopt        = Nothing
+                                                             , bam_v1_6_bam_alignment_optionalfields_bopt        = Nothing
+                                                             }
+               }
+    False -> do
+      -- This parser assumes that
+      -- the optional alignment
+      -- tags can appear in any order.
+      optionalfieldbytes <-
+        parse_BAM_V1_6_BAM_Alignment_OptionalFields block_size_int
+                                                    bytesuptooptionalfields
+      return BAM_V1_6_BAM_Alignment
+               { bam_v1_6_bam_alignment_block_size     = word8sToWord32LE $
+                                                           DB.unpack block_size
+               , bam_v1_6_bam_alignment_refID          = word8sToInt32LE $
+                                                           DB.unpack refID
+               , bam_v1_6_bam_alignment_pos            = word8sToInt32LE $
+                                                           DB.unpack pos
+               , bam_v1_6_bam_alignment_l_read_name    = word8sToWord8LE $
+                                                           DB.unpack l_read_name
+               , bam_v1_6_bam_alignment_mapq           = word8sToWord8LE $
+                                                           DB.unpack mapq
+               , bam_v1_6_bam_alignment_bin            = word8sToWord16LE $
+                                                           DB.unpack bin
+               , bam_v1_6_bam_alignment_n_cigar_op     = word8sToWord16LE $
+                                                           DB.unpack n_cigar_op
+               , bam_v1_6_bam_alignment_flag           = word8sToWord16LE $
+                                                           DB.unpack flag
+               , bam_v1_6_bam_alignment_l_seq          = word8sToWord32LE $
+                                                           DB.unpack l_seq
+               , bam_v1_6_bam_alignment_next_refID     = word8sToInt32LE $
+                                                           DB.unpack next_refID
+               , bam_v1_6_bam_alignment_next_pos       = word8sToInt32LE $
+                                                           DB.unpack next_pos
+               , bam_v1_6_bam_alignment_tlen           = word8sToInt32LE $
+                                                           DB.unpack tlen
+               , bam_v1_6_bam_alignment_read_name      = read_name
+               , bam_v1_6_bam_alignment_cigar          = DSeq.fromList                        $
+                                                           map (word8sToWord32LE . DB.unpack) $
+                                                             splitByteString 4
+                                                                             cigar
+               , bam_v1_6_bam_alignment_seq            = DSeq.fromList $
+                                                           decodeSeqField seq
+               , bam_v1_6_bam_alignment_qual           = qual
+               , bam_v1_6_bam_alignment_optionalfields = optionalfieldbytes
+               }
+  where
+    parse_BAM_V1_6_BAM_Alignment_OptionalFields :: Int
+                                                -> Int
+                                                -> Parser (Seq BAM_V1_6_BAM_Alignment_OptionalFields)
+    parse_BAM_V1_6_BAM_Alignment_OptionalFields block_size_int
+                                                bytesuptooptionalfields = do
+      optionalfieldbytes' <-
+        DABL.take $
+          block_size_int -
+          bytesuptooptionalfields
+      return $
+        parse_OptionalFields optionalfieldbytes'
+      where
+        parse_OptionalFields :: DB.ByteString
+                             -> Seq BAM_V1_6_BAM_Alignment_OptionalFields 
+        parse_OptionalFields bs =
+          case DB.null bs of
+            True  ->
+              DSeq.empty
+            False ->
+              case DB.indexMaybe bs 2 of
+                Nothing                      ->
+                  error $
+                    show BAM_V1_6_Read_Error_Alignment_OptionalFields_Index_Missing
+                -- AOPT <-> 'A'
+                Just 0x41 ->
+                  case ( DABL.parse parse_BAM_V1_6_BAM_Alignment_OptionalFields_AOPT
+                                    ( DB.fromStrict $
+                                        DB.take 4
+                                                bs
+                                    )
+                       ) of
+                    Fail _
+                         ctxs
+                         err ->
+                      error  $
+                        show $ "Error while parsing AOPT field." ++
+                               "\n"                              ++
+                               "Parsing contexts: "              ++
+                               (intercalate ", " ctxs)           ++
+                               "\n"                              ++
+                               "Error message: "                 ++
+                               err
+                    Done remainingbytes
+                         parsedbs -> do
+                      let strictremainingbytes = DB.toStrict remainingbytes
+                      case DB.null strictremainingbytes of
+                        True  ->
+                          BAM_V1_6_BAM_Alignment_OptionalFields
+                            { bam_v1_6_bam_alignment_optionalfields_aopt        = Just parsedbs
+                            , bam_v1_6_bam_alignment_optionalfields_smallcopt   = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_bigcopt     = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_smalliopt   = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_bigiopt     = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_smallsopt   = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_bigsopt     = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_fopt        = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_zopt        = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_hopt        = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_bopt        = Nothing
+                            }
+                          DSeq.:<|
+                          parse_OptionalFields ( DB.drop 4
+                                                         bs
+                                               )
+                        False ->
+                          error $
+                            show BAM_V1_6_Read_Error_Alignment_OptionalFields_Remaining_Bytes
+                -- SmallCOPT <-> 'c'
+                Just 0x63 ->
+                  case ( DABL.parse parse_BAM_V1_6_BAM_Alignment_OptionalFields_SmallCOPT
+                                    ( DB.fromStrict $
+                                        DB.take 4
+                                                bs
+                                    )
+                       ) of
+                    Fail _
+                         ctxs
+                         err ->
+                      error  $
+                        show $ "Error while parsing SmallCOPT field." ++
+                               "\n"                                   ++
+                               "Parsing contexts: "                   ++
+                               (intercalate ", " ctxs)                ++
+                               "\n"                                   ++
+                               "Error message: "                      ++
+                               err
+                    Done remainingbytes
+                         parsedbs -> do
+                      let strictremainingbytes = DB.toStrict remainingbytes
+                      case DB.null strictremainingbytes of
+                        True  ->
+                          BAM_V1_6_BAM_Alignment_OptionalFields
+                            { bam_v1_6_bam_alignment_optionalfields_aopt        = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_smallcopt   = Just parsedbs
+                            , bam_v1_6_bam_alignment_optionalfields_bigcopt     = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_smalliopt   = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_bigiopt     = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_smallsopt   = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_bigsopt     = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_fopt        = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_zopt        = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_hopt        = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_bopt        = Nothing
+                            }
+                          DSeq.:<|
+                          parse_OptionalFields ( DB.drop 4
+                                                         bs
+                                               )
+                        False ->
+                          error $
+                            show BAM_V1_6_Read_Error_Alignment_OptionalFields_Remaining_Bytes
+                -- BigCOPT <-> 'C'
+                Just 0x43 ->
+                  case ( DABL.parse parse_BAM_V1_6_BAM_Alignment_OptionalFields_BigCOPT
+                                    ( DB.fromStrict $
+                                        DB.take 4
+                                                bs
+                                    )
+                       ) of
+                    Fail _
+                         ctxs
+                         err ->
+                      error  $
+                        show $ "Error while parsing BigCOPT field." ++
+                               "\n"                                 ++
+                               "Parsing contexts: "                 ++
+                               (intercalate ", " ctxs)              ++
+                               "\n"                                 ++
+                               "Error message: "                    ++
+                               err
+                    Done remainingbytes
+                         parsedbs -> do
+                      let strictremainingbytes = DB.toStrict remainingbytes
+                      case DB.null strictremainingbytes of
+                        True  ->
+                          BAM_V1_6_BAM_Alignment_OptionalFields
+                            { bam_v1_6_bam_alignment_optionalfields_aopt        = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_smallcopt   = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_bigcopt     = Just parsedbs
+                            , bam_v1_6_bam_alignment_optionalfields_smalliopt   = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_bigiopt     = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_smallsopt   = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_bigsopt     = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_fopt        = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_zopt        = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_hopt        = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_bopt        = Nothing
+                            }
+                          DSeq.:<|
+                          parse_OptionalFields ( DB.drop 4
+                                                         bs
+                                               )
+                        False ->
+                          error $
+                            show BAM_V1_6_Read_Error_Alignment_OptionalFields_Remaining_Bytes
+                -- SmallIOPT <-> 'i'
+                Just 0x69 ->
+                  case ( DABL.parse parse_BAM_V1_6_BAM_Alignment_OptionalFields_SmallIOPT
+                                    ( DB.fromStrict $
+                                        DB.take 7
+                                                bs
+                                    )
+                       ) of
+                    Fail _
+                         ctxs
+                         err ->
+                      error  $
+                        show $ "Error while parsing SmallIOPT field." ++
+                               "\n"                                   ++
+                               "Parsing contexts: "                   ++
+                               (intercalate ", " ctxs)                ++
+                               "\n"                                   ++
+                               "Error message: "                      ++
+                               err
+                    Done remainingbytes
+                         parsedbs -> do
+                      let strictremainingbytes = DB.toStrict remainingbytes
+                      case DB.null strictremainingbytes of
+                        True  ->
+                          BAM_V1_6_BAM_Alignment_OptionalFields
+                            { bam_v1_6_bam_alignment_optionalfields_aopt        = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_smallcopt   = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_bigcopt     = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_smalliopt   = Just parsedbs
+                            , bam_v1_6_bam_alignment_optionalfields_bigiopt     = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_smallsopt   = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_bigsopt     = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_fopt        = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_zopt        = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_hopt        = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_bopt        = Nothing
+                            }
+                          DSeq.:<|
+                          parse_OptionalFields ( DB.drop 7
+                                                         bs
+                                               ) 
+                        False ->
+                          error $
+                            show BAM_V1_6_Read_Error_Alignment_OptionalFields_Remaining_Bytes
+                -- BigIOPT <-> 'I'
+                Just 0x49 ->
+                  case ( DABL.parse parse_BAM_V1_6_BAM_Alignment_OptionalFields_BigIOPT
+                                    ( DB.fromStrict $
+                                        DB.take 7
+                                                bs
+                                    )
+                       ) of
+                    Fail _
+                         ctxs
+                         err ->
+                      error  $
+                        show $ "Error while parsing BigIOPT field." ++
+                               "\n"                                 ++
+                               "Parsing contexts: "                 ++
+                               (intercalate ", " ctxs)              ++
+                               "\n"                                 ++
+                               "Error message: "                    ++
+                               err
+                    Done remainingbytes
+                         parsedbs -> do
+                      let strictremainingbytes = DB.toStrict remainingbytes
+                      case DB.null strictremainingbytes of
+                        True  ->
+                          BAM_V1_6_BAM_Alignment_OptionalFields
+                            { bam_v1_6_bam_alignment_optionalfields_aopt        = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_smallcopt   = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_bigcopt     = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_smalliopt   = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_bigiopt     = Just parsedbs
+                            , bam_v1_6_bam_alignment_optionalfields_smallsopt   = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_bigsopt     = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_fopt        = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_zopt        = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_hopt        = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_bopt        = Nothing
+                            }
+                          DSeq.:<|
+                          parse_OptionalFields ( DB.drop 7
+                                                         bs
+                                               )
+                        False ->
+                          error $
+                            show BAM_V1_6_Read_Error_Alignment_OptionalFields_Remaining_Bytes
+                -- SmallSOPT <-> 's'
+                Just 0x73 ->
+                  case ( DABL.parse parse_BAM_V1_6_BAM_Alignment_OptionalFields_SmallSOPT
+                                    ( DB.fromStrict $
+                                        DB.take 5
+                                                bs
+                                    )
+                       ) of
+                    Fail _
+                         ctxs
+                         err ->
+                      error  $
+                        show $ "Error while parsing SmallSOPT field." ++
+                               "\n"                                   ++
+                               "Parsing contexts: "                   ++
+                               (intercalate ", " ctxs)                ++
+                               "\n"                                   ++
+                               "Error message: "                      ++
+                               err
+                    Done remainingbytes
+                         parsedbs -> do
+                      let strictremainingbytes = DB.toStrict remainingbytes
+                      case DB.null strictremainingbytes of
+                        True  ->
+                          BAM_V1_6_BAM_Alignment_OptionalFields
+                            { bam_v1_6_bam_alignment_optionalfields_aopt        = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_smallcopt   = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_bigcopt     = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_smalliopt   = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_bigiopt     = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_smallsopt   = Just parsedbs
+                            , bam_v1_6_bam_alignment_optionalfields_bigsopt     = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_fopt        = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_zopt        = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_hopt        = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_bopt        = Nothing
+                            }
+                          DSeq.:<|
+                          parse_OptionalFields ( DB.drop 5
+                                                         bs
+                                               )
+                        False ->
+                          error $
+                            show BAM_V1_6_Read_Error_Alignment_OptionalFields_Remaining_Bytes
+                -- BigSOPT <-> 'S'
+                Just 0x53 ->
+                  case ( DABL.parse parse_BAM_V1_6_BAM_Alignment_OptionalFields_BigSOPT
+                                    ( DB.fromStrict $
+                                        DB.take 5
+                                                bs
+                                    )
+                       ) of
+                    Fail _
+                         ctxs
+                         err ->
+                      error  $
+                        show $ "Error while parsing BigSOPT field." ++
+                               "\n"                                 ++
+                               "Parsing contexts: "                 ++
+                               (intercalate ", " ctxs)              ++
+                               "\n"                                 ++
+                               "Error message: "                    ++
+                               err
+                    Done remainingbytes
+                         parsedbs -> do
+                      let strictremainingbytes = DB.toStrict remainingbytes
+                      case DB.null strictremainingbytes of
+                        True  ->
+                          BAM_V1_6_BAM_Alignment_OptionalFields
+                            { bam_v1_6_bam_alignment_optionalfields_aopt        = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_smallcopt   = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_bigcopt     = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_smalliopt   = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_bigiopt     = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_smallsopt   = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_bigsopt     = Just parsedbs
+                            , bam_v1_6_bam_alignment_optionalfields_fopt        = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_zopt        = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_hopt        = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_bopt        = Nothing
+                            }
+                          DSeq.:<|
+                          parse_OptionalFields ( DB.drop 5
+                                                         bs
+                                               )
+                        False ->
+                          error $
+                            show BAM_V1_6_Read_Error_Alignment_OptionalFields_Remaining_Bytes
+                -- FOPT <-> 'f'
+                Just 0x66 ->
+                  case ( DABL.parse parse_BAM_V1_6_BAM_Alignment_OptionalFields_FOPT
+                                    ( DB.fromStrict $
+                                        DB.take 7
+                                                bs
+                                    )
+                       ) of
+                    Fail _
+                         ctxs
+                         err ->
+                      error  $
+                        show $ "Error while parsing FOPT field." ++
+                               "\n"                              ++
+                               "Parsing contexts: "              ++
+                               (intercalate ", " ctxs)           ++
+                               "\n"                              ++
+                               "Error message: "                 ++
+                               err
+                    Done remainingbytes
+                         parsedbs -> do
+                      let strictremainingbytes = DB.toStrict remainingbytes
+                      case DB.null strictremainingbytes of
+                        True  ->
+                          BAM_V1_6_BAM_Alignment_OptionalFields
+                            { bam_v1_6_bam_alignment_optionalfields_aopt        = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_smallcopt   = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_bigcopt     = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_smalliopt   = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_bigiopt     = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_smallsopt   = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_bigsopt     = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_fopt        = Just parsedbs
+                            , bam_v1_6_bam_alignment_optionalfields_zopt        = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_hopt        = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_bopt        = Nothing
+                            }
+                          DSeq.:<|
+                          parse_OptionalFields ( DB.drop 7
+                                                         bs
+                                               )
+                        False ->
+                          error $
+                            show BAM_V1_6_Read_Error_Alignment_OptionalFields_Remaining_Bytes
+                -- ZOPT <-> 'Z'
+                Just 0x5A ->
+                  case ( DABL.parse parse_BAM_V1_6_BAM_Alignment_OptionalFields_ZOPT
+                                    ( DB.fromStrict $
+                                        takeUpTo 0x00
+                                                 bs
+                                    )
+                       ) of
+                    Fail _
+                         ctxs
+                         err ->
+                      error  $
+                        show $ "Error while parsing ZOPT field." ++
+                               "\n"                              ++
+                               "Parsing contexts: "              ++
+                               (intercalate ", " ctxs)           ++
+                               "\n"                              ++
+                               "Error message: "                 ++
+                               err
+                    Done remainingbytes
+                         parsedbs -> do
+                      let strictremainingbytes = DB.toStrict remainingbytes
+                      case DB.null strictremainingbytes of
+                        True  ->
+                          BAM_V1_6_BAM_Alignment_OptionalFields
+                            { bam_v1_6_bam_alignment_optionalfields_aopt        = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_smallcopt   = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_bigcopt     = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_smalliopt   = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_bigiopt     = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_smallsopt   = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_bigsopt     = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_fopt        = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_zopt        = Just parsedbs
+                            , bam_v1_6_bam_alignment_optionalfields_hopt        = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_bopt        = Nothing
+                            }
+                          DSeq.:<|
+                          parse_OptionalFields ( dropUpTo 0x00
+                                                          bs
+                                               )
+                        False ->
+                          error $
+                            show BAM_V1_6_Read_Error_Alignment_OptionalFields_Remaining_Bytes
+                -- HOPT <-> 'H'
+                Just 0x48 ->
+                  case ( DABL.parse parse_BAM_V1_6_BAM_Alignment_OptionalFields_HOPT
+                                    ( DB.fromStrict $
+                                        takeUpTo 0x00
+                                                 bs
+                                    )
+                       ) of
+                    Fail _
+                         ctxs
+                         err ->
+                      error  $
+                        show $ "Error while parsing HOPT field." ++
+                               "\n"                              ++
+                               "Parsing contexts: "              ++
+                               (intercalate ", " ctxs)           ++
+                               "\n"                              ++
+                               "Error message: "                 ++
+                               err
+                    Done remainingbytes
+                         parsedbs -> do
+                      let strictremainingbytes = DB.toStrict remainingbytes
+                      case DB.null strictremainingbytes of
+                        True  ->
+                          BAM_V1_6_BAM_Alignment_OptionalFields
+                            { bam_v1_6_bam_alignment_optionalfields_aopt        = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_smallcopt   = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_bigcopt     = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_smalliopt   = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_bigiopt     = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_smallsopt   = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_bigsopt     = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_fopt        = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_zopt        = Nothing
+                            , bam_v1_6_bam_alignment_optionalfields_hopt        = Just parsedbs
+                            , bam_v1_6_bam_alignment_optionalfields_bopt        = Nothing
+                            }
+                          DSeq.:<|
+                          parse_OptionalFields ( dropUpTo 0x00
+                                                          bs
+                                               )
+                        False ->
+                          error $
+                            show BAM_V1_6_Read_Error_Alignment_OptionalFields_Remaining_Bytes
+                -- BOPT <-> 'B'
+                Just 0x42 ->
+                  case DB.indexMaybe bs 3 of
+                    Nothing            ->
+                      error $
+                        show BAM_V1_6_Read_Error_Alignment_OptionalFields_Missing_Type
+                    Just boptcharacter ->
+                      case boptcharacter of
+                        -- 'c'
+                        0x63 -> do
+                          let boptcount = fromIntegral       $
+                                            word8sToWord32LE $
+                                              DB.unpack      $
+                                                DB.take 4    $
+                                                  DB.drop 4
+                                                          bs
+                          case ( DABL.parse parse_BAM_V1_6_BAM_Alignment_OptionalFields_BOPT
+                                            ( DB.fromStrict $
+                                                DB.take
+                                                  ( ( boptcount * 1
+                                                    ) + 8
+                                                  )
+                                                  bs
+                                            )
+                               ) of
+                            Fail _
+                                 ctxs
+                                 err ->
+                              error  $
+                                show $ "Error while parsing BOPT field." ++
+                                       "\n"                              ++
+                                       "Parsing contexts: "              ++
+                                       (intercalate ", " ctxs)           ++
+                                       "\n"                              ++
+                                       "Error message: "                 ++
+                                       err
+                            Done remainingbytes
+                                 parsedbs -> do
+                              let strictremainingbytes = DB.toStrict remainingbytes
+                              case DB.null strictremainingbytes of
+                                True  ->
+                                  BAM_V1_6_BAM_Alignment_OptionalFields
+                                    { bam_v1_6_bam_alignment_optionalfields_aopt        = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_smallcopt   = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_bigcopt     = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_smalliopt   = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_bigiopt     = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_smallsopt   = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_bigsopt     = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_fopt        = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_zopt        = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_hopt        = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_bopt        = Just parsedbs
+                                    }
+                                  DSeq.:<|
+                                  parse_OptionalFields ( DB.drop ( ( boptcount * 1
+                                                                   ) + 8
+                                                                 )
+                                                                 bs
+                                                       )
+                                False ->
+                                  error $
+                                    show BAM_V1_6_Read_Error_Alignment_OptionalFields_Remaining_Bytes
+                        -- 'C'
+                        0x43 -> do
+                          let boptcount = fromIntegral       $
+                                            word8sToWord32LE $
+                                              DB.unpack      $
+                                                DB.take 4    $
+                                                  DB.drop 4
+                                                          bs
+                          case ( DABL.parse parse_BAM_V1_6_BAM_Alignment_OptionalFields_BOPT
+                                            ( DB.fromStrict $
+                                                DB.take
+                                                  ( ( boptcount * 1
+                                                    ) + 8
+                                                  )
+                                                  bs
+                                            )
+                               ) of
+                            Fail _
+                                 ctxs
+                                 err ->
+                              error  $
+                                show $ "Error while parsing BOPT field." ++
+                                       "\n"                              ++
+                                       "Parsing contexts: "              ++
+                                       (intercalate ", " ctxs)           ++
+                                       "\n"                              ++
+                                       "Error message: "                 ++
+                                       err
+                            Done remainingbytes
+                                 parsedbs -> do
+                              let strictremainingbytes = DB.toStrict remainingbytes
+                              case DB.null strictremainingbytes of
+                                True  ->
+                                  BAM_V1_6_BAM_Alignment_OptionalFields
+                                    { bam_v1_6_bam_alignment_optionalfields_aopt        = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_smallcopt   = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_bigcopt     = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_smalliopt   = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_bigiopt     = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_smallsopt   = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_bigsopt     = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_fopt        = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_zopt        = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_hopt        = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_bopt        = Just parsedbs
+                                    }
+                                  DSeq.:<|
+                                  parse_OptionalFields ( DB.drop ( ( boptcount * 1
+                                                                   ) + 8
+                                                                 )
+                                                                 bs
+                                                       )
+                                False ->
+                                  error $
+                                    show BAM_V1_6_Read_Error_Alignment_OptionalFields_Remaining_Bytes
+                        -- 'i'
+                        0x69 -> do
+                          let boptcount = fromIntegral       $
+                                            word8sToWord32LE $
+                                              DB.unpack      $
+                                                DB.take 4    $
+                                                  DB.drop 4
+                                                          bs
+                          case ( DABL.parse parse_BAM_V1_6_BAM_Alignment_OptionalFields_BOPT
+                                            ( DB.fromStrict $
+                                                DB.take
+                                                  ( ( boptcount * 4
+                                                    ) + 8
+                                                  )
+                                                  bs
+                                            )
+                               ) of
+                            Fail _
+                                 ctxs
+                                 err ->
+                              error  $
+                                show $ "Error while parsing BOPT field." ++
+                                       "\n"                              ++
+                                       "Parsing contexts: "              ++
+                                       (intercalate ", " ctxs)           ++
+                                       "\n"                              ++
+                                       "Error message: "                 ++
+                                       err
+                            Done remainingbytes
+                                 parsedbs -> do
+                              let strictremainingbytes = DB.toStrict remainingbytes
+                              case DB.null strictremainingbytes of
+                                True  ->
+                                  BAM_V1_6_BAM_Alignment_OptionalFields
+                                    { bam_v1_6_bam_alignment_optionalfields_aopt        = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_smallcopt   = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_bigcopt     = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_smalliopt   = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_bigiopt     = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_smallsopt   = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_bigsopt     = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_fopt        = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_zopt        = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_hopt        = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_bopt        = Just parsedbs
+                                    }
+                                  DSeq.:<|
+                                  parse_OptionalFields ( DB.drop ( ( boptcount * 4
+                                                                   ) + 8
+                                                                 )
+                                                                 bs
+                                                       )
+                                False ->
+                                  error $
+                                    show BAM_V1_6_Read_Error_Alignment_OptionalFields_Remaining_Bytes
+                        -- 'I'
+                        0x49 -> do
+                          let boptcount = fromIntegral       $
+                                            word8sToWord32LE $
+                                              DB.unpack      $
+                                                DB.take 4    $
+                                                  DB.drop 4
+                                                          bs
+                          case ( DABL.parse parse_BAM_V1_6_BAM_Alignment_OptionalFields_BOPT
+                                            ( DB.fromStrict $
+                                                DB.take
+                                                  ( ( boptcount * 4
+                                                    ) + 8
+                                                  )
+                                                  bs
+                                            )
+                               ) of
+                            Fail _
+                                 ctxs
+                                 err ->
+                              error  $
+                                show $ "Error while parsing BOPT field." ++
+                                       "\n"                              ++
+                                       "Parsing contexts: "              ++
+                                       (intercalate ", " ctxs)           ++
+                                       "\n"                              ++
+                                       "Error message: "                 ++
+                                       err
+                            Done remainingbytes
+                                 parsedbs -> do
+                              let strictremainingbytes = DB.toStrict remainingbytes
+                              case DB.null strictremainingbytes of
+                                True  ->
+                                  BAM_V1_6_BAM_Alignment_OptionalFields
+                                    { bam_v1_6_bam_alignment_optionalfields_aopt        = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_smallcopt   = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_bigcopt     = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_smalliopt   = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_bigiopt     = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_smallsopt   = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_bigsopt     = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_fopt        = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_zopt        = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_hopt        = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_bopt        = Just parsedbs
+                                    }
+                                  DSeq.:<|
+                                  parse_OptionalFields ( DB.drop ( ( boptcount * 4
+                                                                   ) + 8
+                                                                 )
+                                                                 bs
+                                                       )
+                                False ->
+                                  error $
+                                    show BAM_V1_6_Read_Error_Alignment_OptionalFields_Remaining_Bytes
+                        -- 's'
+                        0x73 -> do
+                          let boptcount = fromIntegral       $
+                                            word8sToWord32LE $
+                                              DB.unpack      $
+                                                DB.take 4    $
+                                                  DB.drop 4
+                                                          bs
+                          case ( DABL.parse parse_BAM_V1_6_BAM_Alignment_OptionalFields_BOPT
+                                            ( DB.fromStrict $
+                                                DB.take
+                                                  ( ( boptcount * 2
+                                                    ) + 8
+                                                  )
+                                                  bs
+                                            )
+                               ) of
+                            Fail _
+                                 ctxs
+                                 err ->
+                              error  $
+                                show $ "Error while parsing BOPT field." ++
+                                       "\n"                              ++
+                                       "Parsing contexts: "              ++
+                                       (intercalate ", " ctxs)           ++
+                                       "\n"                              ++
+                                       "Error message: "                 ++
+                                       err
+                            Done remainingbytes
+                                 parsedbs -> do
+                              let strictremainingbytes = DB.toStrict remainingbytes
+                              case DB.null strictremainingbytes of
+                                True  ->
+                                  BAM_V1_6_BAM_Alignment_OptionalFields
+                                    { bam_v1_6_bam_alignment_optionalfields_aopt        = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_smallcopt   = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_bigcopt     = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_smalliopt   = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_bigiopt     = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_smallsopt   = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_bigsopt     = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_fopt        = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_zopt        = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_hopt        = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_bopt        = Just parsedbs
+                                    }
+                                  DSeq.:<|
+                                  parse_OptionalFields ( DB.drop ( ( boptcount * 2
+                                                                   ) + 8
+                                                                 )
+                                                                 bs
+                                                       )
+                                False ->
+                                  error $
+                                    show BAM_V1_6_Read_Error_Alignment_OptionalFields_Remaining_Bytes
+                        -- 'S'
+                        0x53 -> do
+                          let boptcount = fromIntegral       $
+                                            word8sToWord32LE $
+                                              DB.unpack      $
+                                                DB.take 4    $
+                                                  DB.drop 4
+                                                          bs
+                          case ( DABL.parse parse_BAM_V1_6_BAM_Alignment_OptionalFields_BOPT
+                                            ( DB.fromStrict $
+                                                DB.take
+                                                  ( ( boptcount * 2
+                                                    ) + 8
+                                                  )
+                                                  bs
+                                            )
+                               ) of
+                            Fail _
+                                 ctxs
+                                 err ->
+                              error  $
+                                show $ "Error while parsing BOPT field." ++
+                                       "\n"                              ++
+                                       "Parsing contexts: "              ++
+                                       (intercalate ", " ctxs)           ++
+                                       "\n"                              ++
+                                       "Error message: "                 ++
+                                       err
+                            Done remainingbytes
+                                 parsedbs -> do
+                              let strictremainingbytes = DB.toStrict remainingbytes
+                              case DB.null strictremainingbytes of
+                                True  ->
+                                  BAM_V1_6_BAM_Alignment_OptionalFields
+                                    { bam_v1_6_bam_alignment_optionalfields_aopt        = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_smallcopt   = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_bigcopt     = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_smalliopt   = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_bigiopt     = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_smallsopt   = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_bigsopt     = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_fopt        = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_zopt        = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_hopt        = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_bopt        = Just parsedbs
+                                    }
+                                  DSeq.:<|
+                                  parse_OptionalFields ( DB.drop ( ( boptcount * 2
+                                                                   ) + 8
+                                                                 )
+                                                                 bs
+                                                       )
+                                False ->
+                                  error $
+                                    show BAM_V1_6_Read_Error_Alignment_OptionalFields_Remaining_Bytes
+                        -- 'f'
+                        0x66 -> do
+                          let boptcount = fromIntegral       $
+                                            word8sToWord32LE $
+                                              DB.unpack      $
+                                                DB.take 4    $
+                                                  DB.drop 4
+                                                          bs
+                          case ( DABL.parse parse_BAM_V1_6_BAM_Alignment_OptionalFields_BOPT
+                                            ( DB.fromStrict $
+                                                DB.take
+                                                  ( ( boptcount * 4
+                                                    ) + 8
+                                                  )
+                                                  bs
+                                            )
+                               ) of
+                            Fail _
+                                 ctxs
+                                 err ->
+                              error  $
+                                show $ "Error while parsing BOPT field." ++
+                                       "\n"                              ++
+                                       "Parsing contexts: "              ++
+                                       (intercalate ", " ctxs)           ++
+                                       "\n"                              ++
+                                       "Error message: "                 ++
+                                       err
+                            Done remainingbytes
+                                 parsedbs -> do
+                              let strictremainingbytes = DB.toStrict remainingbytes
+                              case DB.null strictremainingbytes of
+                                True  ->
+                                  BAM_V1_6_BAM_Alignment_OptionalFields
+                                    { bam_v1_6_bam_alignment_optionalfields_aopt        = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_smallcopt   = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_bigcopt     = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_smalliopt   = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_bigiopt     = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_smallsopt   = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_bigsopt     = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_fopt        = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_zopt        = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_hopt        = Nothing
+                                    , bam_v1_6_bam_alignment_optionalfields_bopt        = Just parsedbs
+                                    }
+                                  DSeq.:<|
+                                  parse_OptionalFields ( DB.drop ( ( boptcount * 4
+                                                                   ) + 8
+                                                                 )
+                                                                 bs
+                                                       )
+                                False ->
+                                  error $
+                                    show BAM_V1_6_Read_Error_Alignment_OptionalFields_Remaining_Bytes
+                        _    ->
+                          error $
+                            show BAM_V1_6_Read_Error_Alignment_OptionalFields_BOPT_Missing_Type
+                _         ->
+                  error $
+                    show BAM_V1_6_Read_Error_Alignment_OptionalFields_Missing_Type
diff --git a/src/Data/BAM/Version1_6/Read/Parser/BAM/Alignment/Internal.hs b/src/Data/BAM/Version1_6/Read/Parser/BAM/Alignment/Internal.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/Read/Parser/BAM/Alignment/Internal.hs
@@ -0,0 +1,79 @@
+-- |
+-- Module      :  Data.BAM.Version1_6.Read.Parser.BAM.Alignment.Internal
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = WARNING
+--
+-- This module is considered __internal__.
+--
+-- The Package Versioning Policy __does not apply__.
+--
+-- The contents of this module may change __in any way whatsoever__
+-- and __without any warning__ between minor versions of this package.
+--
+-- Authors importing this library are expected to track development
+-- closely.
+--
+-- All credit goes to the author(s)/maintainer(s) of the
+-- [containers](https://hackage.haskell.org/package/containers) library
+-- for the above warning text.
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.Read.Parser.BAM.Alignment.Internal ( -- * BAM_V1_6_BAM_BAMAlignments parser - internal functions
+                                                                decodeSeqField  
+                                                              , dropUpTo
+                                                              , takeUpTo
+                                                              ) where
+
+import Data.Bits
+import Data.ByteString as DB hiding (concatMap)
+import Data.Word
+
+-- | Decode SEQ field to a [Word8]
+-- (each byte represents two bases).
+decodeSeqField :: DB.ByteString
+               -> [Word8]
+decodeSeqField bytes =
+  concatMap decodeByte (DB.unpack bytes)
+  where
+    decodeByte :: Word8
+               -> [Word8]
+    decodeByte byte =
+      [ byte `shiftR` 4
+      , byte .&. 0x0F
+      ]
+
+-- | Extract a sub ByteString starting from
+-- and including the first occurrence of the given byte.
+dropUpTo :: Word8
+         -> ByteString
+         -> ByteString
+dropUpTo byte bs = 
+  let (_,suffix) = DB.break (== byte) bs
+    in case DB.uncons suffix of
+         Nothing ->
+           DB.empty -- Specified byte not found, return an empty ByteString.
+         Just _  ->
+           suffix
+
+-- | Extract a sub ByteString up to
+-- and including the first occurrence of a given byte.
+takeUpTo :: Word8
+         -> ByteString
+         -> ByteString
+takeUpTo byte
+         bs = 
+  let (prefix,suffix) = DB.break (== byte) bs
+    in case DB.uncons suffix of
+         Nothing    ->
+           prefix -- No 0x00 found, return the entire ByteString.
+         Just (_,_) ->
+           DB.concat [ prefix
+                     , DB.singleton byte
+                     ]
diff --git a/src/Data/BAM/Version1_6/Read/Parser/BAM/Alignment/OptionalFields/AOPT.hs b/src/Data/BAM/Version1_6/Read/Parser/BAM/Alignment/OptionalFields/AOPT.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/Read/Parser/BAM/Alignment/OptionalFields/AOPT.hs
@@ -0,0 +1,92 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedLists       #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE MultiWayIf            #-}
+{-# LANGUAGE RecordWildCards       #-}
+{-# LANGUAGE ScopedTypeVariables   #-}
+{-# LANGUAGE TypeFamilies          #-}
+{-# Language QuasiQuotes           #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.Read.Parser.BAM.Alignment.OptionalFields.AOPT
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = WARNING
+--
+-- This module is considered __internal__.
+--
+-- The Package Versioning Policy __does not apply__.
+--
+-- The contents of this module may change __in any way whatsoever__
+-- and __without any warning__ between minor versions of this package.
+--
+-- Authors importing this library are expected to track development
+-- closely.
+--
+-- All credit goes to the author(s)/maintainer(s) of the
+-- [containers](https://hackage.haskell.org/package/containers) library
+-- for the above warning text.
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.Read.Parser.BAM.Alignment.OptionalFields.AOPT ( -- * BAM_V1_6_BAM parser - alignment section - aopt field 
+                                                                           parse_BAM_V1_6_BAM_Alignment_OptionalFields_AOPT
+                                                                         ) where
+
+import           Data.BAM.Version1_6.BAM.Alignment.OptionalFields.AOPT
+import           Data.BAM.Version1_6.Internal
+import           Data.BAM.Version1_6.Read.Error
+
+import           Data.ByteString                 as DB
+import           Data.Attoparsec.ByteString.Lazy as DABL
+import           Text.Regex.PCRE.Heavy
+
+-- | Defines a parser for the optional aopt field of alignment section of the BAM v1.6 file format.
+--
+-- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+parse_BAM_V1_6_BAM_Alignment_OptionalFields_AOPT :: Parser BAM_V1_6_BAM_Alignment_OptionalFields_AOPT
+parse_BAM_V1_6_BAM_Alignment_OptionalFields_AOPT = do
+  alignmentaoptfieldtag <- do
+    alignmentaoptfieldtagp <-
+      DABL.take 2
+    -- Parse AOPT tag of the alignment section.
+    case (alignmentaoptfieldtagp =~ [re|[A-Za-z][A-Za-z0-9]|]) of
+      False ->
+        fail $ show BAM_V1_6_Read_Error_Alignment_AOPT_Tag_Incorrect_Format
+      True  ->
+        -- AOPT tag is in the accepted format. 
+        return alignmentaoptfieldtagp
+  _ <- do
+    alignmentaoptfieldtypep <-
+      DABL.take 1
+    -- Parse AOPT type of the alignment section.
+    case (alignmentaoptfieldtypep =~ [re|[A]|]) of
+      False ->
+        fail $ show BAM_V1_6_Read_Error_Alignment_AOPT_Type_Incorrect_Format
+      True  ->
+        -- AOPT type is in the accepted format.
+        return ()
+  alignmentaoptfieldvalue <- do
+    alignmentaoptfieldvaluep <-
+      DABL.take 1 
+    -- Parse AOPT value of the alignment section.
+    case (alignmentaoptfieldvaluep =~ [re|[!-~]|]) of
+      False ->
+        fail $ show BAM_V1_6_Read_Error_Alignment_AOPT_Value_Incorrect_Format
+      True  ->
+        -- AOPT value is in the accepted format.
+        return alignmentaoptfieldvaluep
+  return BAM_V1_6_BAM_Alignment_OptionalFields_AOPT
+           { bam_v1_6_bam_alignment_optionalfields_aopt_tag   = alignmentaoptfieldtag
+           , bam_v1_6_bam_alignment_optionalfields_aopt_value = word8sToWord8LE $
+                                                                  DB.unpack alignmentaoptfieldvalue
+           }
diff --git a/src/Data/BAM/Version1_6/Read/Parser/BAM/Alignment/OptionalFields/BOPT.hs b/src/Data/BAM/Version1_6/Read/Parser/BAM/Alignment/OptionalFields/BOPT.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/Read/Parser/BAM/Alignment/OptionalFields/BOPT.hs
@@ -0,0 +1,343 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedLists       #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE MultiWayIf            #-}
+{-# LANGUAGE RecordWildCards       #-}
+{-# LANGUAGE ScopedTypeVariables   #-}
+{-# LANGUAGE TypeFamilies          #-}
+{-# Language QuasiQuotes           #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.Read.Parser.BAM.Alignment.OptionalFields.BOPT
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = WARNING
+--
+-- This module is considered __internal__.
+--
+-- The Package Versioning Policy __does not apply__.
+--
+-- The contents of this module may change __in any way whatsoever__
+-- and __without any warning__ between minor versions of this package.
+--
+-- Authors importing this library are expected to track development
+-- closely.
+--
+-- All credit goes to the author(s)/maintainer(s) of the
+-- [containers](https://hackage.haskell.org/package/containers) library
+-- for the above warning text.
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.Read.Parser.BAM.Alignment.OptionalFields.BOPT ( -- * BAM_V1_6_BAM parser - alignment section - bopt field 
+                                                                           parse_BAM_V1_6_BAM_Alignment_OptionalFields_BOPT
+                                                                         ) where
+
+import Data.BAM.Version1_6.BAM.Alignment.OptionalFields.BOPT
+import Data.BAM.Version1_6.Internal
+import Data.BAM.Version1_6.Read.Error
+
+import           Data.Attoparsec.ByteString.Lazy as DABL
+import qualified Data.ByteString                 as DB (unpack)
+import qualified Data.ByteString.Char8           as DBC8
+import           Data.Sequence                   as DSeq
+import           Text.Regex.PCRE.Heavy
+
+-- | Defines a parser for the optional bopt field of alignment section of the BAM v1.6 file format.
+--
+-- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+parse_BAM_V1_6_BAM_Alignment_OptionalFields_BOPT :: Parser BAM_V1_6_BAM_Alignment_OptionalFields_BOPT
+parse_BAM_V1_6_BAM_Alignment_OptionalFields_BOPT = do
+  alignmentboptfieldtag <- do
+    alignmentboptfieldtagp <-
+      DABL.take 2
+    -- Parse BOPT tag of the alignment section.
+    case (alignmentboptfieldtagp =~ [re|[A-Za-z][A-Za-z0-9]|]) of
+      False ->
+        fail $
+          show BAM_V1_6_Read_Error_Alignment_BOPT_Tag_Incorrect_Format
+      True  ->
+        -- BOPT tag is in the accepted format. 
+        return alignmentboptfieldtagp
+  _ <- do
+    alignmentboptfieldtypep <-
+      DABL.take 1
+    -- Parse BOPT type of the alignment section.
+    case (alignmentboptfieldtypep =~ [re|[B]|]) of
+      False ->
+        fail $
+          show BAM_V1_6_Read_Error_Alignment_BOPT_Type_Incorrect_Format
+      True  ->
+        -- BOPT type is in the accepted format.
+        return ()
+  alignmentboptfieldvaluetype <- do
+    alignmentboptfieldvaluetypep <-
+      DABL.take 1
+    -- Parse BOPT value type of the alignment section.
+    case (alignmentboptfieldvaluetypep =~ [re|[cCsSiIf]|]) of
+      False ->
+        fail $
+          show BAM_V1_6_Read_Error_Alignment_BOPT_Value_Type_Incorrect_Format
+      True  ->
+        -- BOPT value type is in the accepted format.
+        return alignmentboptfieldvaluetypep
+  alignmentboptfieldcount <-
+    DABL.take 4
+  case (DBC8.unpack alignmentboptfieldvaluetype) of
+    "c" -> do
+      alignmentboptfieldvaluedata <- do
+        alignmentboptfieldvaluedatap <-
+          DABL.take $
+            ( fromIntegral       $
+                word8sToWord32LE $
+                  DB.unpack alignmentboptfieldcount
+            ) * 1
+        -- Parse BOPT value data of the alignment section.
+        case (alignmentboptfieldvaluedatap =~ [re|([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)*|]) of
+          False ->
+            fail $
+              show BAM_V1_6_Read_Error_Alignment_BOPT_Value_Data_Incorrect_Format
+          True  ->
+            -- BOPT value data is in the accepted format.
+            return alignmentboptfieldvaluedatap 
+      return BAM_V1_6_BAM_Alignment_OptionalFields_BOPT
+               { bam_v1_6_bam_alignment_optionalfields_bopt_int8   = Just BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Int8
+                                                                            { bam_v1_6_bam_alignment_optionalfields_bopt_int8_tag   = alignmentboptfieldtag
+                                                                            , bam_v1_6_bam_alignment_optionalfields_bopt_int8_type  = alignmentboptfieldvaluetype
+                                                                            , bam_v1_6_bam_alignment_optionalfields_bopt_int8_count = word8sToWord32LE $
+                                                                                                                                        DB.unpack alignmentboptfieldcount
+                                                                            , bam_v1_6_bam_alignment_optionalfields_bopt_int8_value = DSeq.fromList                      $
+                                                                                                                                        map (word8sToInt8LE . DB.unpack) $
+                                                                                                                                          splitByteString 1
+                                                                                                                                                          alignmentboptfieldvaluedata
+                                                                            }
+               , bam_v1_6_bam_alignment_optionalfields_bopt_word8  = Nothing
+               , bam_v1_6_bam_alignment_optionalfields_bopt_int16  = Nothing
+               , bam_v1_6_bam_alignment_optionalfields_bopt_word16 = Nothing
+               , bam_v1_6_bam_alignment_optionalfields_bopt_int32  = Nothing
+               , bam_v1_6_bam_alignment_optionalfields_bopt_word32 = Nothing
+               , bam_v1_6_bam_alignment_optionalfields_bopt_float  = Nothing
+               }
+    "C" -> do
+      alignmentboptfieldvaluedata <- do
+        alignmentboptfieldvaluedatap <-
+          DABL.take $
+            ( fromIntegral       $
+                word8sToWord32LE $
+                  DB.unpack alignmentboptfieldcount
+            ) * 1
+        -- Parse BOPT value data of the alignment section.
+        case (alignmentboptfieldvaluedatap =~ [re|([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)*|]) of
+          False ->
+            fail $
+              show BAM_V1_6_Read_Error_Alignment_BOPT_Value_Data_Incorrect_Format
+          True  ->
+            -- BOPT value data is in the accepted format.
+            return alignmentboptfieldvaluedatap
+      return BAM_V1_6_BAM_Alignment_OptionalFields_BOPT
+               { bam_v1_6_bam_alignment_optionalfields_bopt_int8   = Nothing
+               , bam_v1_6_bam_alignment_optionalfields_bopt_word8  = Just BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Word8
+                                                                            { bam_v1_6_bam_alignment_optionalfields_bopt_word8_tag   = alignmentboptfieldtag
+                                                                            , bam_v1_6_bam_alignment_optionalfields_bopt_word8_type  = alignmentboptfieldvaluetype
+                                                                            , bam_v1_6_bam_alignment_optionalfields_bopt_word8_count = word8sToWord32LE $
+                                                                                                                                         DB.unpack alignmentboptfieldcount
+                                                                            , bam_v1_6_bam_alignment_optionalfields_bopt_word8_value = DSeq.fromList                       $
+                                                                                                                                         map (word8sToWord8LE . DB.unpack) $
+                                                                                                                                           splitByteString 1
+                                                                                                                                                           alignmentboptfieldvaluedata
+                                                                            }
+               , bam_v1_6_bam_alignment_optionalfields_bopt_int16  = Nothing
+               , bam_v1_6_bam_alignment_optionalfields_bopt_word16 = Nothing
+               , bam_v1_6_bam_alignment_optionalfields_bopt_int32  = Nothing
+               , bam_v1_6_bam_alignment_optionalfields_bopt_word32 = Nothing
+               , bam_v1_6_bam_alignment_optionalfields_bopt_float  = Nothing
+               }
+    "s" -> do
+      alignmentboptfieldvaluedata <- do
+        alignmentboptfieldvaluedatap <-
+          DABL.take $
+            ( fromIntegral       $
+                word8sToWord32LE $
+                  DB.unpack alignmentboptfieldcount
+            ) * 2
+        -- Parse BOPT value data of the alignment section.
+        case (alignmentboptfieldvaluedatap =~ [re|([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)*|]) of
+          False ->
+            fail $
+              show BAM_V1_6_Read_Error_Alignment_BOPT_Value_Data_Incorrect_Format
+          True  ->
+            -- BOPT value data is in the accepted format.
+            return alignmentboptfieldvaluedatap
+      return BAM_V1_6_BAM_Alignment_OptionalFields_BOPT
+               { bam_v1_6_bam_alignment_optionalfields_bopt_int8   = Nothing
+               , bam_v1_6_bam_alignment_optionalfields_bopt_word8  = Nothing
+               , bam_v1_6_bam_alignment_optionalfields_bopt_int16  = Just BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Int16
+                                                                            { bam_v1_6_bam_alignment_optionalfields_bopt_int16_tag   = alignmentboptfieldtag
+                                                                            , bam_v1_6_bam_alignment_optionalfields_bopt_int16_type  = alignmentboptfieldvaluetype
+                                                                            , bam_v1_6_bam_alignment_optionalfields_bopt_int16_count = word8sToWord32LE $
+                                                                                                                                         DB.unpack alignmentboptfieldcount
+                                                                            , bam_v1_6_bam_alignment_optionalfields_bopt_int16_value = DSeq.fromList                       $
+                                                                                                                                         map (word8sToInt16LE . DB.unpack) $ 
+                                                                                                                                           splitByteString 2
+                                                                                                                                                           alignmentboptfieldvaluedata
+                                                                            }
+               , bam_v1_6_bam_alignment_optionalfields_bopt_word16 = Nothing
+               , bam_v1_6_bam_alignment_optionalfields_bopt_int32  = Nothing
+               , bam_v1_6_bam_alignment_optionalfields_bopt_word32 = Nothing
+               , bam_v1_6_bam_alignment_optionalfields_bopt_float  = Nothing
+               }
+    "S" -> do
+      alignmentboptfieldvaluedata <- do
+        alignmentboptfieldvaluedatap <-
+          DABL.take $
+            ( fromIntegral       $
+                word8sToWord32LE $
+                  DB.unpack alignmentboptfieldcount
+            ) * 2
+        -- Parse BOPT value data of the alignment section.
+        case (alignmentboptfieldvaluedatap =~ [re|([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)*|]) of
+          False ->
+            fail $
+              show BAM_V1_6_Read_Error_Alignment_BOPT_Value_Data_Incorrect_Format
+          True  ->
+            -- BOPT value data is in the accepted format.
+            return alignmentboptfieldvaluedatap
+      return BAM_V1_6_BAM_Alignment_OptionalFields_BOPT
+               { bam_v1_6_bam_alignment_optionalfields_bopt_int8   = Nothing
+               , bam_v1_6_bam_alignment_optionalfields_bopt_word8  = Nothing
+               , bam_v1_6_bam_alignment_optionalfields_bopt_int16  = Nothing
+               , bam_v1_6_bam_alignment_optionalfields_bopt_word16 = Just BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Word16
+                                                                            { bam_v1_6_bam_alignment_optionalfields_bopt_word16_tag   = alignmentboptfieldtag
+                                                                            , bam_v1_6_bam_alignment_optionalfields_bopt_word16_type  = alignmentboptfieldvaluetype
+                                                                            , bam_v1_6_bam_alignment_optionalfields_bopt_word16_count = word8sToWord32LE $
+                                                                                                                                          DB.unpack alignmentboptfieldcount
+                                                                            , bam_v1_6_bam_alignment_optionalfields_bopt_word16_value = DSeq.fromList                        $
+                                                                                                                                          map (word8sToWord16LE . DB.unpack) $
+                                                                                                                                            splitByteString 2
+                                                                                                                                                            alignmentboptfieldvaluedata
+                                                                            }
+               , bam_v1_6_bam_alignment_optionalfields_bopt_int32  = Nothing
+               , bam_v1_6_bam_alignment_optionalfields_bopt_word32 = Nothing
+               , bam_v1_6_bam_alignment_optionalfields_bopt_float  = Nothing
+               }
+    "i" -> do
+      alignmentboptfieldvaluedata <- do
+        alignmentboptfieldvaluedatap <-
+          DABL.take $
+            ( fromIntegral       $
+                word8sToWord32LE $
+                  DB.unpack alignmentboptfieldcount
+            ) * 4
+        -- Parse BOPT value data of the alignment section.
+        case (alignmentboptfieldvaluedatap =~ [re|([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)*|]) of
+          False ->
+            fail $
+              show BAM_V1_6_Read_Error_Alignment_BOPT_Value_Data_Incorrect_Format
+          True  ->
+            -- BOPT value data is in the accepted format.
+            return alignmentboptfieldvaluedatap
+      return BAM_V1_6_BAM_Alignment_OptionalFields_BOPT
+               { bam_v1_6_bam_alignment_optionalfields_bopt_int8   = Nothing
+               , bam_v1_6_bam_alignment_optionalfields_bopt_word8  = Nothing
+               , bam_v1_6_bam_alignment_optionalfields_bopt_int16  = Nothing
+               , bam_v1_6_bam_alignment_optionalfields_bopt_word16 = Nothing
+               , bam_v1_6_bam_alignment_optionalfields_bopt_int32  = Just BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Int32
+                                                                            { bam_v1_6_bam_alignment_optionalfields_bopt_int32_tag   = alignmentboptfieldtag
+                                                                            , bam_v1_6_bam_alignment_optionalfields_bopt_int32_type  = alignmentboptfieldvaluetype
+                                                                            , bam_v1_6_bam_alignment_optionalfields_bopt_int32_count = word8sToWord32LE $
+                                                                                                                                         DB.unpack alignmentboptfieldcount
+                                                                            , bam_v1_6_bam_alignment_optionalfields_bopt_int32_value = DSeq.fromList                       $
+                                                                                                                                         map (word8sToInt32LE . DB.unpack) $
+                                                                                                                                           splitByteString 4
+                                                                                                                                                           alignmentboptfieldvaluedata
+                                                                            }
+               , bam_v1_6_bam_alignment_optionalfields_bopt_word32 = Nothing
+               , bam_v1_6_bam_alignment_optionalfields_bopt_float  = Nothing
+               }
+    "I" -> do
+      alignmentboptfieldvaluedata <- do
+        alignmentboptfieldvaluedatap <-
+          DABL.take $
+            ( fromIntegral       $
+                word8sToWord32LE $
+                  DB.unpack alignmentboptfieldcount
+            ) * 4
+        -- Parse BOPT value data of the alignment section.
+        case (alignmentboptfieldvaluedatap =~ [re|([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)*|]) of
+          False ->
+            fail $
+              show BAM_V1_6_Read_Error_Alignment_BOPT_Value_Data_Incorrect_Format
+          True  ->
+            -- BOPT value data is in the accepted format.
+            return alignmentboptfieldvaluedatap
+      return BAM_V1_6_BAM_Alignment_OptionalFields_BOPT
+               { bam_v1_6_bam_alignment_optionalfields_bopt_int8   = Nothing
+               , bam_v1_6_bam_alignment_optionalfields_bopt_word8  = Nothing
+               , bam_v1_6_bam_alignment_optionalfields_bopt_int16  = Nothing
+               , bam_v1_6_bam_alignment_optionalfields_bopt_word16 = Nothing
+               , bam_v1_6_bam_alignment_optionalfields_bopt_int32  = Nothing
+               , bam_v1_6_bam_alignment_optionalfields_bopt_word32 = Just BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Word32
+                                                                            { bam_v1_6_bam_alignment_optionalfields_bopt_word32_tag   = alignmentboptfieldtag
+                                                                            , bam_v1_6_bam_alignment_optionalfields_bopt_word32_type  = alignmentboptfieldvaluetype
+                                                                            , bam_v1_6_bam_alignment_optionalfields_bopt_word32_count = word8sToWord32LE $
+                                                                                                                                          DB.unpack alignmentboptfieldcount
+                                                                            , bam_v1_6_bam_alignment_optionalfields_bopt_word32_value = DSeq.fromList                        $
+                                                                                                                                          map (word8sToWord32LE . DB.unpack) $
+                                                                                                                                            splitByteString 4
+                                                                                                                                                            alignmentboptfieldvaluedata
+                                                                            }
+               , bam_v1_6_bam_alignment_optionalfields_bopt_float  = Nothing
+               }
+    "f" -> do
+      alignmentboptfieldvaluedata <- do
+        alignmentboptfieldvaluedatap <-
+          DABL.take $
+            ( fromIntegral       $
+                word8sToWord32LE $
+                  DB.unpack alignmentboptfieldcount
+            ) * 4
+        -- Parse BOPT value data of the alignment section.
+        case (alignmentboptfieldvaluedatap =~ [re|([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)*|]) of
+          False ->
+            fail $
+              show BAM_V1_6_Read_Error_Alignment_BOPT_Value_Data_Incorrect_Format
+          True  ->
+            -- BOPT value data is in the accepted format.
+            return alignmentboptfieldvaluedatap
+      return BAM_V1_6_BAM_Alignment_OptionalFields_BOPT
+               { bam_v1_6_bam_alignment_optionalfields_bopt_int8   = Nothing
+               , bam_v1_6_bam_alignment_optionalfields_bopt_word8  = Nothing
+               , bam_v1_6_bam_alignment_optionalfields_bopt_int16  = Nothing
+               , bam_v1_6_bam_alignment_optionalfields_bopt_word16 = Nothing
+               , bam_v1_6_bam_alignment_optionalfields_bopt_int32  = Nothing
+               , bam_v1_6_bam_alignment_optionalfields_bopt_word32 = Nothing
+               , bam_v1_6_bam_alignment_optionalfields_bopt_float  = Just BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_Float
+                                                                            { bam_v1_6_bam_alignment_optionalfields_bopt_float_tag   = alignmentboptfieldtag
+                                                                            , bam_v1_6_bam_alignment_optionalfields_bopt_float_type  = alignmentboptfieldvaluetype
+                                                                            , bam_v1_6_bam_alignment_optionalfields_bopt_float_count = word8sToWord32LE $
+                                                                                                                                         DB.unpack alignmentboptfieldcount
+                                                                            , bam_v1_6_bam_alignment_optionalfields_bopt_float_value = DSeq.fromList             $
+                                                                                                                                         map bytestringToFloatLE $
+                                                                                                                                           splitByteString 4
+                                                                                                                                                           alignmentboptfieldvaluedata
+                                                                            }
+               }
+    _   ->
+      return BAM_V1_6_BAM_Alignment_OptionalFields_BOPT
+               { bam_v1_6_bam_alignment_optionalfields_bopt_int8   = Nothing
+               , bam_v1_6_bam_alignment_optionalfields_bopt_word8  = Nothing
+               , bam_v1_6_bam_alignment_optionalfields_bopt_int16  = Nothing
+               , bam_v1_6_bam_alignment_optionalfields_bopt_word16 = Nothing
+               , bam_v1_6_bam_alignment_optionalfields_bopt_int32  = Nothing
+               , bam_v1_6_bam_alignment_optionalfields_bopt_word32 = Nothing
+               , bam_v1_6_bam_alignment_optionalfields_bopt_float  = Nothing
+               }
diff --git a/src/Data/BAM/Version1_6/Read/Parser/BAM/Alignment/OptionalFields/BigCOPT.hs b/src/Data/BAM/Version1_6/Read/Parser/BAM/Alignment/OptionalFields/BigCOPT.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/Read/Parser/BAM/Alignment/OptionalFields/BigCOPT.hs
@@ -0,0 +1,84 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedLists       #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE MultiWayIf            #-}
+{-# LANGUAGE RecordWildCards       #-}
+{-# LANGUAGE ScopedTypeVariables   #-}
+{-# LANGUAGE TypeFamilies          #-}
+{-# Language QuasiQuotes           #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.Read.Parser.BAM.Alignment.OptionalFields.BigCOPT
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = WARNING
+--
+-- This module is considered __internal__.
+--
+-- The Package Versioning Policy __does not apply__.
+--
+-- The contents of this module may change __in any way whatsoever__
+-- and __without any warning__ between minor versions of this package.
+--
+-- Authors importing this library are expected to track development
+-- closely.
+--
+-- All credit goes to the author(s)/maintainer(s) of the
+-- [containers](https://hackage.haskell.org/package/containers) library
+-- for the above warning text.
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.Read.Parser.BAM.Alignment.OptionalFields.BigCOPT ( -- * BAM_V1_6_BAM parser - alignment section - bigcopt field 
+                                                                              parse_BAM_V1_6_BAM_Alignment_OptionalFields_BigCOPT
+                                                                            ) where
+
+import           Data.BAM.Version1_6.BAM.Alignment.OptionalFields.BigCOPT
+import           Data.BAM.Version1_6.Internal
+import           Data.BAM.Version1_6.Read.Error
+
+import           Data.ByteString                 as DB
+import           Data.Attoparsec.ByteString.Lazy as DABL
+import           Text.Regex.PCRE.Heavy
+
+-- | Defines a parser for the optional bigcopt field of alignment section of the BAM v1.6 file format.
+--
+-- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+parse_BAM_V1_6_BAM_Alignment_OptionalFields_BigCOPT :: Parser BAM_V1_6_BAM_Alignment_OptionalFields_BigCOPT
+parse_BAM_V1_6_BAM_Alignment_OptionalFields_BigCOPT = do
+  alignmentbigcoptfieldtag <- do
+    alignmentbigcoptfieldtagp <-
+      DABL.take 2
+    -- Parse BigCOPT tag of the alignment section.
+    case (alignmentbigcoptfieldtagp =~ [re|[A-Za-z][A-Za-z0-9]|]) of
+      False ->
+        fail $ show BAM_V1_6_Read_Error_Alignment_BigCOPT_Tag_Incorrect_Format
+      True  ->
+        -- BigCOPT tag is in the accepted format. 
+        return alignmentbigcoptfieldtagp
+  _ <- do
+    alignmentbigcoptfieldtypep <-
+      DABL.take 1
+    -- Parse BigCOPT type of the alignment section.
+    case (alignmentbigcoptfieldtypep =~ [re|[C]|]) of
+      False ->
+        fail $ show BAM_V1_6_Read_Error_Alignment_BigCOPT_Type_Incorrect_Format
+      True  ->
+        -- BigCOPT type is in the accepted format.
+        return ()
+  alignmentbigcoptfieldvalue <-
+    DABL.take 1 
+  return BAM_V1_6_BAM_Alignment_OptionalFields_BigCOPT
+           { bam_v1_6_bam_alignment_optionalfields_bigcopt_tag   = alignmentbigcoptfieldtag
+           , bam_v1_6_bam_alignment_optionalfields_bigcopt_value = word8sToWord8LE $
+                                                                     DB.unpack alignmentbigcoptfieldvalue
+           }
diff --git a/src/Data/BAM/Version1_6/Read/Parser/BAM/Alignment/OptionalFields/BigIOPT.hs b/src/Data/BAM/Version1_6/Read/Parser/BAM/Alignment/OptionalFields/BigIOPT.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/Read/Parser/BAM/Alignment/OptionalFields/BigIOPT.hs
@@ -0,0 +1,84 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedLists       #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE MultiWayIf            #-}
+{-# LANGUAGE RecordWildCards       #-}
+{-# LANGUAGE ScopedTypeVariables   #-}
+{-# LANGUAGE TypeFamilies          #-}
+{-# Language QuasiQuotes           #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.Read.Parser.BAM.Alignment.OptionalFields.BigIOPT
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = WARNING
+--
+-- This module is considered __internal__.
+--
+-- The Package Versioning Policy __does not apply__.
+--
+-- The contents of this module may change __in any way whatsoever__
+-- and __without any warning__ between minor versions of this package.
+--
+-- Authors importing this library are expected to track development
+-- closely.
+--
+-- All credit goes to the author(s)/maintainer(s) of the
+-- [containers](https://hackage.haskell.org/package/containers) library
+-- for the above warning text.
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.Read.Parser.BAM.Alignment.OptionalFields.BigIOPT ( -- * BAM_V1_6_BAM parser - alignment section - bigiopt field 
+                                                                              parse_BAM_V1_6_BAM_Alignment_OptionalFields_BigIOPT
+                                                                            ) where
+
+import Data.BAM.Version1_6.BAM.Alignment.OptionalFields.BigIOPT
+import Data.BAM.Version1_6.Internal
+import Data.BAM.Version1_6.Read.Error
+
+import Data.ByteString                 as DB
+import Data.Attoparsec.ByteString.Lazy as DABL
+import Text.Regex.PCRE.Heavy
+
+-- | Defines a parser for the optional bigiopt field of alignment section of the BAM v1.6 file format.
+--
+-- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+parse_BAM_V1_6_BAM_Alignment_OptionalFields_BigIOPT :: Parser BAM_V1_6_BAM_Alignment_OptionalFields_BigIOPT
+parse_BAM_V1_6_BAM_Alignment_OptionalFields_BigIOPT = do
+  alignmentbigioptfieldtag <- do
+    alignmentbigioptfieldtagp <-
+      DABL.take 2
+    -- Parse BigIOPT tag of the alignment section.
+    case (alignmentbigioptfieldtagp =~ [re|[A-Za-z][A-Za-z0-9]|]) of
+      False ->
+        fail $ show BAM_V1_6_Read_Error_Alignment_BigIOPT_Tag_Incorrect_Format
+      True  ->
+        -- BigIOPT tag is in the accepted format. 
+        return alignmentbigioptfieldtagp
+  _ <- do
+    alignmentbigioptfieldtypep <-
+      DABL.take 1
+    -- Parse BigIOPT type of the alignment section.
+    case (alignmentbigioptfieldtypep =~ [re|[I]|]) of
+      False ->
+        fail $ show BAM_V1_6_Read_Error_Alignment_BigIOPT_Type_Incorrect_Format
+      True  ->
+        -- BigIOPT type is in the accepted format.
+        return ()
+  alignmentbigioptfieldvalue <-
+    DABL.take 4
+  return BAM_V1_6_BAM_Alignment_OptionalFields_BigIOPT
+           { bam_v1_6_bam_alignment_optionalfields_bigiopt_tag   = alignmentbigioptfieldtag
+           , bam_v1_6_bam_alignment_optionalfields_bigiopt_value = word8sToWord32LE $
+                                                                     DB.unpack alignmentbigioptfieldvalue
+           }
diff --git a/src/Data/BAM/Version1_6/Read/Parser/BAM/Alignment/OptionalFields/BigSOPT.hs b/src/Data/BAM/Version1_6/Read/Parser/BAM/Alignment/OptionalFields/BigSOPT.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/Read/Parser/BAM/Alignment/OptionalFields/BigSOPT.hs
@@ -0,0 +1,84 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedLists       #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE MultiWayIf            #-}
+{-# LANGUAGE RecordWildCards       #-}
+{-# LANGUAGE ScopedTypeVariables   #-}
+{-# LANGUAGE TypeFamilies          #-}
+{-# Language QuasiQuotes           #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.Read.Parser.BAM.Alignment.OptionalFields.BigSOPT
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = WARNING
+--
+-- This module is considered __internal__.
+--
+-- The Package Versioning Policy __does not apply__.
+--
+-- The contents of this module may change __in any way whatsoever__
+-- and __without any warning__ between minor versions of this package.
+--
+-- Authors importing this library are expected to track development
+-- closely.
+--
+-- All credit goes to the author(s)/maintainer(s) of the
+-- [containers](https://hackage.haskell.org/package/containers) library
+-- for the above warning text.
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.Read.Parser.BAM.Alignment.OptionalFields.BigSOPT ( -- * BAM_V1_6_BAM parser - alignment section - bigsopt field 
+                                                                              parse_BAM_V1_6_BAM_Alignment_OptionalFields_BigSOPT
+                                                                            ) where
+
+import Data.BAM.Version1_6.BAM.Alignment.OptionalFields.BigSOPT
+import Data.BAM.Version1_6.Internal
+import Data.BAM.Version1_6.Read.Error
+
+import Data.ByteString                  as DB
+import Data.Attoparsec.ByteString.Lazy  as DABL
+import Text.Regex.PCRE.Heavy
+
+-- | Defines a parser for the optional bigsopt field of alignment section of the BAM v1.6 file format.
+--
+-- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+parse_BAM_V1_6_BAM_Alignment_OptionalFields_BigSOPT :: Parser BAM_V1_6_BAM_Alignment_OptionalFields_BigSOPT
+parse_BAM_V1_6_BAM_Alignment_OptionalFields_BigSOPT = do
+  alignmentbigsoptfieldtag <- do
+    alignmentbigsoptfieldtagp <-
+      DABL.take 2
+    -- Parse BigSOPT tag of the alignment section.
+    case (alignmentbigsoptfieldtagp =~ [re|[A-Za-z][A-Za-z0-9]|]) of
+      False ->
+        fail $ show BAM_V1_6_Read_Error_Alignment_BigSOPT_Tag_Incorrect_Format
+      True  ->
+        -- BigSOPT tag is in the accepted format. 
+        return alignmentbigsoptfieldtagp
+  _ <- do
+    alignmentbigsoptfieldtypep <-
+      DABL.take 1
+    -- Parse BigSOPT type of the alignment section.
+    case (alignmentbigsoptfieldtypep =~ [re|[S]|]) of
+      False ->
+        fail $ show BAM_V1_6_Read_Error_Alignment_BigSOPT_Type_Incorrect_Format
+      True  ->
+        -- BigSOPT type is in the accepted format.
+        return ()
+  alignmentbigsoptfieldvalue <-
+    DABL.take 2
+  return BAM_V1_6_BAM_Alignment_OptionalFields_BigSOPT
+           { bam_v1_6_bam_alignment_optionalfields_bigsopt_tag   = alignmentbigsoptfieldtag
+           , bam_v1_6_bam_alignment_optionalfields_bigsopt_value = word8sToWord16LE $
+                                                                     DB.unpack alignmentbigsoptfieldvalue
+           }
diff --git a/src/Data/BAM/Version1_6/Read/Parser/BAM/Alignment/OptionalFields/FOPT.hs b/src/Data/BAM/Version1_6/Read/Parser/BAM/Alignment/OptionalFields/FOPT.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/Read/Parser/BAM/Alignment/OptionalFields/FOPT.hs
@@ -0,0 +1,95 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedLists       #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE MultiWayIf            #-}
+{-# LANGUAGE RecordWildCards       #-}
+{-# LANGUAGE ScopedTypeVariables   #-}
+{-# LANGUAGE TypeFamilies          #-}
+{-# Language QuasiQuotes           #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.Read.Parser.BAM.Alignment.OptionalFields.FOPT
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = WARNING
+--
+-- This module is considered __internal__.
+--
+-- The Package Versioning Policy __does not apply__.
+--
+-- The contents of this module may change __in any way whatsoever__
+-- and __without any warning__ between minor versions of this package.
+--
+-- Authors importing this library are expected to track development
+-- closely.
+--
+-- All credit goes to the author(s)/maintainer(s) of the
+-- [containers](https://hackage.haskell.org/package/containers) library
+-- for the above warning text.
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.Read.Parser.BAM.Alignment.OptionalFields.FOPT ( -- * BAM_V1_6 parser - alignment section - fopt field 
+                                                                           parse_BAM_V1_6_BAM_Alignment_OptionalFields_FOPT
+                                                                         ) where
+
+import           Data.BAM.Version1_6.BAM.Alignment.OptionalFields.FOPT
+import           Data.BAM.Version1_6.Internal
+import           Data.BAM.Version1_6.Read.Error
+
+import           Data.ByteString                 as DB
+import           Data.Attoparsec.ByteString.Lazy as DABL
+import           Text.Regex.PCRE.Heavy
+
+-- | Defines a parser for the optional fopt field of alignment section of the BAM v1.6 file format.
+--
+-- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+parse_BAM_V1_6_BAM_Alignment_OptionalFields_FOPT :: Parser BAM_V1_6_BAM_Alignment_OptionalFields_FOPT
+parse_BAM_V1_6_BAM_Alignment_OptionalFields_FOPT = do
+  alignmentfoptfieldtag <- do
+    alignmentfoptfieldtagp <-
+      DABL.take 2
+    -- Parse FOPT tag of the alignment section.
+    case (alignmentfoptfieldtagp =~ [re|[A-Za-z][A-Za-z0-9]|]) of
+      False ->
+        fail $
+          show BAM_V1_6_Read_Error_Alignment_FOPT_Tag_Incorrect_Format
+      True  ->
+        -- FOPT tag is in the accepted format. 
+        return alignmentfoptfieldtagp
+  _ <- do
+    alignmentfoptfieldtypep <-
+      DABL.take 1
+    -- Parse FOPT type of the alignment section.
+    case (alignmentfoptfieldtypep =~ [re|[f]|]) of
+      False ->
+        fail $
+          show BAM_V1_6_Read_Error_Alignment_FOPT_Type_Incorrect_Format
+      True  ->
+        -- FOPT type is in the accepted format.
+        return ()
+  alignmentfoptfieldvalue <- do
+    alignmentfoptfieldvaluep <-
+      DABL.take 4
+    -- Parse FOPT value of the alignment section.
+    case (alignmentfoptfieldvaluep =~ [re|[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?|]) of
+      False ->
+        fail $
+          show BAM_V1_6_Read_Error_Alignment_FOPT_Value_Incorrect_Format
+      True  ->
+        -- FOPT value is in the accepted format.
+        return alignmentfoptfieldvaluep
+  return BAM_V1_6_BAM_Alignment_OptionalFields_FOPT
+           { bam_v1_6_bam_alignment_optionalfields_fopt_tag   = alignmentfoptfieldtag
+           , bam_v1_6_bam_alignment_optionalfields_fopt_value = word8sToWord32LE $
+                                                                  DB.unpack alignmentfoptfieldvalue
+           }
diff --git a/src/Data/BAM/Version1_6/Read/Parser/BAM/Alignment/OptionalFields/HOPT.hs b/src/Data/BAM/Version1_6/Read/Parser/BAM/Alignment/OptionalFields/HOPT.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/Read/Parser/BAM/Alignment/OptionalFields/HOPT.hs
@@ -0,0 +1,110 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedLists       #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE MultiWayIf            #-}
+{-# LANGUAGE RecordWildCards       #-}
+{-# LANGUAGE ScopedTypeVariables   #-}
+{-# LANGUAGE TypeFamilies          #-}
+{-# Language QuasiQuotes           #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.Read.Parser.BAM.Alignment.OptionalFields.HOPT
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = WARNING
+--
+-- This module is considered __internal__.
+--
+-- The Package Versioning Policy __does not apply__.
+--
+-- The contents of this module may change __in any way whatsoever__
+-- and __without any warning__ between minor versions of this package.
+--
+-- Authors importing this library are expected to track development
+-- closely.
+--
+-- All credit goes to the author(s)/maintainer(s) of the
+-- [containers](https://hackage.haskell.org/package/containers) library
+-- for the above warning text.
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.Read.Parser.BAM.Alignment.OptionalFields.HOPT ( -- * BAM_V1_6 parser - alignment section - hopt field 
+                                                                           parse_BAM_V1_6_BAM_Alignment_OptionalFields_HOPT
+                                                                         ) where
+
+import Data.BAM.Version1_6.BAM.Alignment.OptionalFields.HOPT
+import Data.BAM.Version1_6.Internal
+import Data.BAM.Version1_6.Read.Error
+
+import Data.ByteString.Base16            as DBB16
+import Data.Base16.Types                 as DBB16T
+import Data.Attoparsec.ByteString.Lazy   as DABL
+import Data.Sequence                     as DSeq
+import Text.Regex.PCRE.Heavy
+
+-- | Defines a parser for the optional hopt field of alignment section of the BAM v1.6 file format.
+--
+-- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+parse_BAM_V1_6_BAM_Alignment_OptionalFields_HOPT :: Parser BAM_V1_6_BAM_Alignment_OptionalFields_HOPT
+parse_BAM_V1_6_BAM_Alignment_OptionalFields_HOPT = do
+  alignmenthoptfieldtag <- do
+    alignmenthoptfieldtagp <-
+      DABL.take 2
+    -- Parse HOPT tag of the alignment section.
+    case (alignmenthoptfieldtagp =~ [re|[A-Za-z][A-Za-z0-9]|]) of
+      False ->
+        fail $
+          show BAM_V1_6_Read_Error_Alignment_HOPT_Tag_Incorrect_Format
+      True  ->
+        -- HOPT tag is in the accepted format. 
+        return alignmenthoptfieldtagp
+  _ <- do
+    alignmenthoptfieldtypep <-
+      DABL.take 1
+    -- Parse HOPT type of the alignment section.
+    case (alignmenthoptfieldtypep =~ [re|[H]|]) of
+      False ->
+        fail $
+          show BAM_V1_6_Read_Error_Alignment_HOPT_Type_Incorrect_Format
+      True  ->
+        -- HOPT type is in the accepted format.
+        return ()
+  alignmenthoptfieldvalue <- do
+    alignmenthoptfieldvaluep <-
+      DABL.takeTill (\x -> x == 0x00)
+    -- Parse HOPT value of the alignment section.
+    case (alignmenthoptfieldvaluep =~ [re|([0-9A-F][0-9A-F])*|]) of
+      False ->
+        fail $
+          show BAM_V1_6_Read_Error_Alignment_HOPT_Value_Incorrect_Format
+      True  ->
+        -- HOPT value is in the accepted format.
+        return $
+          Prelude.map (\currenthexvalue -> do
+                         case (DBB16.isBase16 alignmenthoptfieldvaluep) of
+                           False ->
+                             error $
+                               show BAM_V1_6_Read_Error_Alignment_HOPT_Value_Incorrect_Format
+                           True  ->
+                             DBB16.decodeBase16    $
+                               DBB16T.assertBase16 currenthexvalue
+                      ) $
+          ( splitByteString 2
+                            alignmenthoptfieldvaluep
+          )
+  _ <-
+    DABL.take 1
+  return BAM_V1_6_BAM_Alignment_OptionalFields_HOPT
+           { bam_v1_6_bam_alignment_optionalfields_hopt_tag   = alignmenthoptfieldtag
+           , bam_v1_6_bam_alignment_optionalfields_hopt_value = DSeq.fromList alignmenthoptfieldvalue
+           }
diff --git a/src/Data/BAM/Version1_6/Read/Parser/BAM/Alignment/OptionalFields/SmallCOPT.hs b/src/Data/BAM/Version1_6/Read/Parser/BAM/Alignment/OptionalFields/SmallCOPT.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/Read/Parser/BAM/Alignment/OptionalFields/SmallCOPT.hs
@@ -0,0 +1,84 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedLists       #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE MultiWayIf            #-}
+{-# LANGUAGE RecordWildCards       #-}
+{-# LANGUAGE ScopedTypeVariables   #-}
+{-# LANGUAGE TypeFamilies          #-}
+{-# Language QuasiQuotes           #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.Read.Parser.BAM.Alignment.OptionalFields.SmallCOPT
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = WARNING
+--
+-- This module is considered __internal__.
+--
+-- The Package Versioning Policy __does not apply__.
+--
+-- The contents of this module may change __in any way whatsoever__
+-- and __without any warning__ between minor versions of this package.
+--
+-- Authors importing this library are expected to track development
+-- closely.
+--
+-- All credit goes to the author(s)/maintainer(s) of the
+-- [containers](https://hackage.haskell.org/package/containers) library
+-- for the above warning text.
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.Read.Parser.BAM.Alignment.OptionalFields.SmallCOPT ( -- * BAM_V1_6_BAM parser - alignment section - smallcopt field 
+                                                                                parse_BAM_V1_6_BAM_Alignment_OptionalFields_SmallCOPT
+                                                                              ) where
+
+import Data.BAM.Version1_6.BAM.Alignment.OptionalFields.SmallCOPT
+import Data.BAM.Version1_6.Internal
+import Data.BAM.Version1_6.Read.Error
+
+import Data.Attoparsec.ByteString.Lazy as DABL
+import Data.ByteString                 as DB
+import Text.Regex.PCRE.Heavy
+
+-- | Defines a parser for the optional smallcopt field of alignment section of the BAM v1.6 file format.
+--
+-- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+parse_BAM_V1_6_BAM_Alignment_OptionalFields_SmallCOPT :: Parser BAM_V1_6_BAM_Alignment_OptionalFields_SmallCOPT
+parse_BAM_V1_6_BAM_Alignment_OptionalFields_SmallCOPT = do
+  alignmentsmallcoptfieldtag <- do
+    alignmentsmallcoptfieldtagp <-
+      DABL.take 2
+    -- Parse SmallCOPT tag of the alignment section.
+    case (alignmentsmallcoptfieldtagp =~ [re|[A-Za-z][A-Za-z0-9]|]) of
+      False ->
+        fail $ show BAM_V1_6_Read_Error_Alignment_SmallCOPT_Tag_Incorrect_Format
+      True  ->
+        -- SmallCOPT tag is in the accepted format. 
+        return alignmentsmallcoptfieldtagp
+  _ <- do
+    alignmentsmallcoptfieldtypep <-
+      DABL.take 1
+    -- Parse SmallCOPT type of the alignment section.
+    case (alignmentsmallcoptfieldtypep =~ [re|[c]|]) of
+      False ->
+        fail $ show BAM_V1_6_Read_Error_Alignment_SmallCOPT_Type_Incorrect_Format
+      True  ->
+        -- SmallCOPT type is in the accepted format.
+        return ()
+  alignmentsmallcoptfieldvalue <-
+    DABL.take 1 
+  return BAM_V1_6_BAM_Alignment_OptionalFields_SmallCOPT
+           { bam_v1_6_bam_alignment_optionalfields_smallcopt_tag   = alignmentsmallcoptfieldtag
+           , bam_v1_6_bam_alignment_optionalfields_smallcopt_value = word8sToInt8LE $
+                                                                       DB.unpack alignmentsmallcoptfieldvalue
+           }
diff --git a/src/Data/BAM/Version1_6/Read/Parser/BAM/Alignment/OptionalFields/SmallIOPT.hs b/src/Data/BAM/Version1_6/Read/Parser/BAM/Alignment/OptionalFields/SmallIOPT.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/Read/Parser/BAM/Alignment/OptionalFields/SmallIOPT.hs
@@ -0,0 +1,84 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedLists       #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE MultiWayIf            #-}
+{-# LANGUAGE RecordWildCards       #-}
+{-# LANGUAGE ScopedTypeVariables   #-}
+{-# LANGUAGE TypeFamilies          #-}
+{-# Language QuasiQuotes           #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.Read.Parser.BAM.Alignment.OptionalFields.SmallIOPT
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = WARNING
+--
+-- This module is considered __internal__.
+--
+-- The Package Versioning Policy __does not apply__.
+--
+-- The contents of this module may change __in any way whatsoever__
+-- and __without any warning__ between minor versions of this package.
+--
+-- Authors importing this library are expected to track development
+-- closely.
+--
+-- All credit goes to the author(s)/maintainer(s) of the
+-- [containers](https://hackage.haskell.org/package/containers) library
+-- for the above warning text.
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.Read.Parser.BAM.Alignment.OptionalFields.SmallIOPT ( -- * BAM_V1_6_BAM parser - alignment section - smalliopt field 
+                                                                                parse_BAM_V1_6_BAM_Alignment_OptionalFields_SmallIOPT
+                                                                              ) where
+
+import Data.BAM.Version1_6.BAM.Alignment.OptionalFields.SmallIOPT
+import Data.BAM.Version1_6.Internal
+import Data.BAM.Version1_6.Read.Error
+
+import Data.ByteString                 as DB
+import Data.Attoparsec.ByteString.Lazy as DABL
+import Text.Regex.PCRE.Heavy
+
+-- | Defines a parser for the optional smalliopt field of alignment section of the BAM v1.6 file format.
+--
+-- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+parse_BAM_V1_6_BAM_Alignment_OptionalFields_SmallIOPT :: Parser BAM_V1_6_BAM_Alignment_OptionalFields_SmallIOPT
+parse_BAM_V1_6_BAM_Alignment_OptionalFields_SmallIOPT = do
+  alignmentsmallioptfieldtag <- do
+    alignmentsmallioptfieldtagp <-
+      DABL.take 2
+    -- Parse SmallIOPT tag of the alignment section.
+    case (alignmentsmallioptfieldtagp =~ [re|[A-Za-z][A-Za-z0-9]|]) of
+      False ->
+        fail $ show BAM_V1_6_Read_Error_Alignment_SmallIOPT_Tag_Incorrect_Format
+      True  ->
+        -- SmallIOPT tag is in the accepted format. 
+        return alignmentsmallioptfieldtagp
+  _ <- do
+    alignmentsmallioptfieldtypep <-
+      DABL.take 1
+    -- Parse SmallIOPT type of the alignment section.
+    case (alignmentsmallioptfieldtypep =~ [re|[i]|]) of
+      False ->
+        fail $ show BAM_V1_6_Read_Error_Alignment_SmallIOPT_Type_Incorrect_Format
+      True  ->
+        -- SmallIOPT type is in the accepted format.
+        return ()
+  alignmentsmallioptfieldvalue <-
+    DABL.take 4
+  return BAM_V1_6_BAM_Alignment_OptionalFields_SmallIOPT
+           { bam_v1_6_bam_alignment_optionalfields_smalliopt_tag   = alignmentsmallioptfieldtag
+           , bam_v1_6_bam_alignment_optionalfields_smalliopt_value = word8sToInt32LE $
+                                                                       DB.unpack alignmentsmallioptfieldvalue
+           }
diff --git a/src/Data/BAM/Version1_6/Read/Parser/BAM/Alignment/OptionalFields/SmallSOPT.hs b/src/Data/BAM/Version1_6/Read/Parser/BAM/Alignment/OptionalFields/SmallSOPT.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/Read/Parser/BAM/Alignment/OptionalFields/SmallSOPT.hs
@@ -0,0 +1,84 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedLists       #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE MultiWayIf            #-}
+{-# LANGUAGE RecordWildCards       #-}
+{-# LANGUAGE ScopedTypeVariables   #-}
+{-# LANGUAGE TypeFamilies          #-}
+{-# Language QuasiQuotes           #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.Read.Parser.BAM.Alignment.OptionalFields.SmallSOPT
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = WARNING
+--
+-- This module is considered __internal__.
+--
+-- The Package Versioning Policy __does not apply__.
+--
+-- The contents of this module may change __in any way whatsoever__
+-- and __without any warning__ between minor versions of this package.
+--
+-- Authors importing this library are expected to track development
+-- closely.
+--
+-- All credit goes to the author(s)/maintainer(s) of the
+-- [containers](https://hackage.haskell.org/package/containers) library
+-- for the above warning text.
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.Read.Parser.BAM.Alignment.OptionalFields.SmallSOPT ( -- * BAM_V1_6_BAM parser - alignment section - smallsopt field 
+                                                                                parse_BAM_V1_6_BAM_Alignment_OptionalFields_SmallSOPT
+                                                                              ) where
+
+import Data.BAM.Version1_6.BAM.Alignment.OptionalFields.SmallSOPT
+import Data.BAM.Version1_6.Internal
+import Data.BAM.Version1_6.Read.Error
+
+import Data.ByteString                 as DB
+import Data.Attoparsec.ByteString.Lazy as DABL
+import Text.Regex.PCRE.Heavy
+
+-- | Defines a parser for the optional smallsopt field of alignment section of the BAM v1.6 file format.
+--
+-- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+parse_BAM_V1_6_BAM_Alignment_OptionalFields_SmallSOPT :: Parser BAM_V1_6_BAM_Alignment_OptionalFields_SmallSOPT
+parse_BAM_V1_6_BAM_Alignment_OptionalFields_SmallSOPT = do
+  alignmentsmallsoptfieldtag <- do
+    alignmentsmallsoptfieldtagp <-
+      DABL.take 2
+    -- Parse SmallSOPT tag of the alignment section.
+    case (alignmentsmallsoptfieldtagp =~ [re|[A-Za-z][A-Za-z0-9]|]) of
+      False ->
+        fail $ show BAM_V1_6_Read_Error_Alignment_SmallSOPT_Tag_Incorrect_Format
+      True  ->
+        -- SmallSOPT tag is in the accepted format. 
+        return alignmentsmallsoptfieldtagp
+  _ <- do
+    alignmentsmallsoptfieldtypep <-
+      DABL.take 1
+    -- Parse SmallSOPT type of the alignment section.
+    case (alignmentsmallsoptfieldtypep =~ [re|[s]|]) of
+      False ->
+        fail $ show BAM_V1_6_Read_Error_Alignment_SmallSOPT_Type_Incorrect_Format
+      True  ->
+        -- SmallSOPT type is in the accepted format.
+        return ()
+  alignmentsmallsoptfieldvalue <-
+    DABL.take 2
+  return BAM_V1_6_BAM_Alignment_OptionalFields_SmallSOPT
+           { bam_v1_6_bam_alignment_optionalfields_smallsopt_tag   = alignmentsmallsoptfieldtag
+           , bam_v1_6_bam_alignment_optionalfields_smallsopt_value = word8sToInt16LE $
+                                                                       DB.unpack alignmentsmallsoptfieldvalue
+           }
diff --git a/src/Data/BAM/Version1_6/Read/Parser/BAM/Alignment/OptionalFields/ZOPT.hs b/src/Data/BAM/Version1_6/Read/Parser/BAM/Alignment/OptionalFields/ZOPT.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/Read/Parser/BAM/Alignment/OptionalFields/ZOPT.hs
@@ -0,0 +1,97 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedLists       #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE MultiWayIf            #-}
+{-# LANGUAGE RecordWildCards       #-}
+{-# LANGUAGE ScopedTypeVariables   #-}
+{-# LANGUAGE TypeFamilies          #-}
+{-# Language QuasiQuotes           #-}
+
+-- |
+-- Module      :  Data.SAM.Version1_6.Read.Parser.BAM.Alignment.OptionalFields.ZOPT
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = WARNING
+--
+-- This module is considered __internal__.
+--
+-- The Package Versioning Policy __does not apply__.
+--
+-- The contents of this module may change __in any way whatsoever__
+-- and __without any warning__ between minor versions of this package.
+--
+-- Authors importing this library are expected to track development
+-- closely.
+--
+-- All credit goes to the author(s)/maintainer(s) of the
+-- [containers](https://hackage.haskell.org/package/containers) library
+-- for the above warning text.
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.Read.Parser.BAM.Alignment.OptionalFields.ZOPT ( -- * BAM_V1_6 parser - alignment section - zopt field 
+                                                                           parse_BAM_V1_6_BAM_Alignment_OptionalFields_ZOPT
+                                                                         ) where
+
+import Data.BAM.Version1_6.BAM.Alignment.OptionalFields.ZOPT
+import Data.BAM.Version1_6.Read.Error
+
+import Data.ByteString                 as DB
+import Data.Attoparsec.ByteString.Lazy as DABL
+import Data.Sequence                   as DSeq
+import Text.Regex.PCRE.Heavy
+
+-- | Defines a parser for the optional zopt field of alignment section of the BAM v1.6 file format.
+--
+-- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+parse_BAM_V1_6_BAM_Alignment_OptionalFields_ZOPT :: Parser BAM_V1_6_BAM_Alignment_OptionalFields_ZOPT
+parse_BAM_V1_6_BAM_Alignment_OptionalFields_ZOPT = do
+  alignmentzoptfieldtag <- do
+    alignmentzoptfieldtagp <-
+      DABL.take 2
+    -- Parse ZOPT tag of the alignment section.
+    case (alignmentzoptfieldtagp =~ [re|[A-Za-z][A-Za-z0-9]|]) of
+      False ->
+        fail $
+          show BAM_V1_6_Read_Error_Alignment_ZOPT_Tag_Incorrect_Format
+      True  ->
+        -- ZOPT tag is in the accepted format. 
+        return alignmentzoptfieldtagp
+  _ <- do
+    alignmentzoptfieldtypep <-
+      DABL.take 1
+    -- Parse ZOPT type of the alignment section.
+    case (alignmentzoptfieldtypep =~ [re|[Z]|]) of
+      False ->
+        fail $
+          show BAM_V1_6_Read_Error_Alignment_ZOPT_Type_Incorrect_Format
+      True  ->
+        -- ZOPT type is in the accepted format.
+        return ()
+  alignmentzoptfieldvalue <- do
+    alignmentzoptfieldvaluep <-
+      DABL.takeTill (\x -> x == 0x00)
+    -- Parse ZOPT value of the alignment section.
+    case (alignmentzoptfieldvaluep =~ [re|[ !-~]*|]) of
+      False ->
+        fail $
+          show BAM_V1_6_Read_Error_Alignment_ZOPT_Value_Incorrect_Format
+      True  ->
+        -- ZOPT value is in the accepted format.
+        return alignmentzoptfieldvaluep
+  _ <-
+    DABL.take 1
+  return BAM_V1_6_BAM_Alignment_OptionalFields_ZOPT
+           { bam_v1_6_bam_alignment_optionalfields_zopt_tag   = alignmentzoptfieldtag
+           , bam_v1_6_bam_alignment_optionalfields_zopt_value = DSeq.fromList $
+                                                                  DB.unpack alignmentzoptfieldvalue
+           }
diff --git a/src/Data/BAM/Version1_6/Read/Parser/BAM/BAMAlignments.hs b/src/Data/BAM/Version1_6/Read/Parser/BAM/BAMAlignments.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/Read/Parser/BAM/BAMAlignments.hs
@@ -0,0 +1,34 @@
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.Read.Parser.BAM.BAMAlignments
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.Read.Parser.BAM.BAMAlignments ( -- * BAM_V1_6_BAM parser
+                                                           parse_BAM_V1_6_BAM_BAMAlignments
+                                                         ) where
+
+import Data.BAM.Version1_6.BAM.BAMAlignments
+import Data.BAM.Version1_6.Read.Parser.BAM.Alignment.Base
+
+import Data.Attoparsec.ByteString.Lazy as DABL
+import Data.Sequence                   as DSeq
+
+-- | Define the @"BAM_V1_6_BAM_BAMAlignments"@ parser.
+parse_BAM_V1_6_BAM_BAMAlignments :: Parser BAM_V1_6_BAM_BAMAlignments
+parse_BAM_V1_6_BAM_BAMAlignments = do
+  alignments <-
+    DABL.many' parse_BAM_V1_6_BAM_Alignment
+  return BAM_V1_6_BAM_BAMAlignments
+           { bam_v1_6_bam_bamalignments_alignments = DSeq.fromList alignments
+           }
diff --git a/src/Data/BAM/Version1_6/Read/Parser/BAM/BAMHeader.hs b/src/Data/BAM/Version1_6/Read/Parser/BAM/BAMHeader.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/Read/Parser/BAM/BAMHeader.hs
@@ -0,0 +1,72 @@
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.Read.Parser.BAM.BAMHeader
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.Read.Parser.BAM.BAMHeader ( -- * BAM_V1_6_BAM_BAMHeader parser
+                                                       parse_BAM_V1_6_BAM_BAMHeader
+                                                     ) where
+
+import Data.BAM.Version1_6.Internal
+import Data.BAM.Version1_6.BAM.BAMHeader
+import Data.BAM.Version1_6.Read.Error
+import Data.BAM.Version1_6.Read.Parser.BAM.ReferenceInformation.Base
+
+import Data.Attoparsec.ByteString.Lazy as DABL
+import Data.ByteString                 as DB
+import Data.Sequence                   as DSeq
+
+-- | Define the @"BAM_V1_6_BAM_BAMHeader"@ parser.
+parse_BAM_V1_6_BAM_BAMHeader :: Parser BAM_V1_6_BAM_BAMHeader
+parse_BAM_V1_6_BAM_BAMHeader = do
+  magic                 <- do
+    magicp <-
+      DABL.take 4
+    case (magicp == bammagicstring) of
+      False ->
+        fail $
+          show BAM_V1_6_Read_Error_BAMHeader_BAM_Magic_String_Invalid_Value
+      True ->
+        return magicp
+  l_text                <-
+    DABL.take 4
+  text                  <-
+    DABL.take
+      ( fromIntegral       $
+          word8sToWord32LE $
+            DB.unpack l_text -- :: Int
+      )
+  n_ref                 <-
+    DABL.take 4
+  reference_information <-
+    DABL.count ( fromIntegral       $
+                   word8sToWord32LE $
+                     DB.unpack n_ref :: Int
+               )
+               parse_BAM_V1_6_BAM_Reference_Information
+  return BAM_V1_6_BAM_BAMHeader
+           { bam_v1_6_bam_bamheader_magic                 = magic
+           , bam_v1_6_bam_bamheader_l_text                = word8sToWord32LE $
+                                                              DB.unpack l_text
+           , bam_v1_6_bam_bamheader_text                  = text
+           , bam_v1_6_bam_bamheader_n_ref                 = word8sToWord32LE $
+                                                              DB.unpack n_ref
+           , bam_v1_6_bam_bamheader_reference_information = DSeq.fromList reference_information
+           }
+  where
+    bammagicstring = DB.pack [ 0x42
+                             , 0x41
+                             , 0x4D
+                             , 0x01
+                             ]
diff --git a/src/Data/BAM/Version1_6/Read/Parser/BAM/Base.hs b/src/Data/BAM/Version1_6/Read/Parser/BAM/Base.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/Read/Parser/BAM/Base.hs
@@ -0,0 +1,57 @@
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.Read.Parser.BAM.Base
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.Read.Parser.BAM.Base ( -- * BAM_V1_6_BAM parser
+                                                  parse_BAM_V1_6_BAM
+                                                ) where
+
+import Data.BAM.Version1_6.Internal
+import Data.BAM.Version1_6.BAM
+import Data.BAM.Version1_6.Read.Parser.BAM.BAMAlignments
+import Data.BAM.Version1_6.Read.Parser.BAM.BAMHeader
+
+import Data.Attoparsec.ByteString.Lazy as DABL
+
+-- | Define the @"BAM_V1_6_BAM"@ parser.
+parse_BAM_V1_6_BAM :: Parser BAM_V1_6_BAM
+parse_BAM_V1_6_BAM = do
+  emptycdatablock <-
+    peekWord8
+  case emptycdatablock of
+    Nothing ->
+      return BAM_V1_6_BAM
+               { bam_v1_6_bam_bamheader       = Nothing
+               , bam_v1_6_bam_bamalignments   = Nothing
+               , bam_v1_6_bam_endoffilemarker = True 
+               }      
+    Just _ -> do
+      header <-
+        maybeOption parse_BAM_V1_6_BAM_BAMHeader
+      case header of
+        Nothing      -> do
+          alignments <-
+            parse_BAM_V1_6_BAM_BAMAlignments
+          return BAM_V1_6_BAM
+               { bam_v1_6_bam_bamheader       = Nothing
+               , bam_v1_6_bam_bamalignments   = Just alignments
+               , bam_v1_6_bam_endoffilemarker = False
+               }
+        Just header' ->
+          return BAM_V1_6_BAM
+                   { bam_v1_6_bam_bamheader       = Just header'
+                   , bam_v1_6_bam_bamalignments   = Nothing
+                   , bam_v1_6_bam_endoffilemarker = False
+                   }          
diff --git a/src/Data/BAM/Version1_6/Read/Parser/BAM/ReferenceInformation/Base.hs b/src/Data/BAM/Version1_6/Read/Parser/BAM/ReferenceInformation/Base.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/Read/Parser/BAM/ReferenceInformation/Base.hs
@@ -0,0 +1,66 @@
+{-# LANGUAGE FlexibleContexts            #-}
+{-# LANGUAGE FlexibleInstances           #-}
+{-# LANGUAGE MultiParamTypeClasses       #-}
+{-# LANGUAGE TypeFamilies                #-}
+{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.Read.Parser.BAM.ReferenceInformation.Base
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = WARNING
+--
+-- This module is considered __internal__.
+--
+-- The Package Versioning Policy __does not apply__.
+--
+-- The contents of this module may change __in any way whatsoever__
+-- and __without any warning__ between minor versions of this package.
+--
+-- Authors importing this library are expected to track development
+-- closely.
+--
+-- All credit goes to the author(s)/maintainer(s) of the
+-- [containers](https://hackage.haskell.org/package/containers) library
+-- for the above warning text.
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.Read.Parser.BAM.ReferenceInformation.Base ( -- * BAM_V1_6_BAM parser - reference information section
+                                                                       parse_BAM_V1_6_BAM_Reference_Information
+                                                                     ) where
+
+import Data.BAM.Version1_6.BAM.ReferenceInformation
+import Data.BAM.Version1_6.Internal
+
+import Data.Attoparsec.ByteString.Lazy as DABL
+import Data.ByteString                 as DB
+
+-- | @"BAM_V1_6_BAM_Reference_Information"@ parser.
+--
+-- Defines a parser for the alignment section of the BAM v1.6 file format.
+--
+-- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+parse_BAM_V1_6_BAM_Reference_Information :: Parser BAM_V1_6_BAM_Reference_Information
+parse_BAM_V1_6_BAM_Reference_Information = do
+  l_name <-
+    DABL.take 4
+  name   <-
+    DABL.take            $
+      fromIntegral       $
+        word8sToWord32LE $
+          DB.unpack l_name
+  l_ref  <-
+    DABL.take 4
+  return BAM_V1_6_BAM_Reference_Information
+           { bam_v1_6_bam_reference_information_l_name = word8sToWord32LE $
+                                                           DB.unpack l_name
+           , bam_v1_6_bam_reference_information_name   = name
+           , bam_v1_6_bam_reference_information_l_ref  = word8sToWord32LE $
+                                                           DB.unpack l_ref
+           }
diff --git a/src/Data/BAM/Version1_6/Read/Parser/BGZFBlock.hs b/src/Data/BAM/Version1_6/Read/Parser/BGZFBlock.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/Read/Parser/BGZFBlock.hs
@@ -0,0 +1,268 @@
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedLists       #-}
+{-# LANGUAGE ScopedTypeVariables   #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.Read.Parser.BGZFBlock
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = WARNING
+--
+-- This module is considered __internal__.
+--
+-- The Package Versioning Policy __does not apply__.
+--
+-- The contents of this module may change __in any way whatsoever__
+-- and __without any warning__ between minor versions of this package.
+--
+-- Authors importing this library are expected to track development
+-- closely.
+--
+-- All credit goes to the author(s)/maintainer(s) of the
+-- [containers](https://hackage.haskell.org/package/containers) library
+-- for the above warning text.
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.Read.Parser.BGZFBlock ( -- * BAM_V1_6 parser - BGZF block section.
+                                                   parse_BAM_V1_6_BGZFBlock
+                                                 ) where
+
+import           Data.BAM.Version1_6.Internal
+import           Data.BAM.Version1_6.Read.Parser.BAM.Base
+import           Data.BAM.Version1_6.BGZFBlock
+import           Data.BAM.Version1_6.GZipHeader
+import           Data.BAM.Version1_6.Read.Error
+
+import           Codec.Compression.Zlib.Raw        as CCZlibR (decompress)
+import           Data.Attoparsec.ByteString.Lazy   as DABL
+import qualified Data.ByteString                   as DB      (fromStrict,unpack)
+import           Data.Digest.CRC32                            (crc32)
+import           Data.Word
+
+-- | Defines a parser for a single BGZF block.
+--
+-- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+parse_BAM_V1_6_BGZFBlock :: Parser BAM_V1_6_BGZFBlock
+parse_BAM_V1_6_BGZFBlock = do
+  gzipheaderidentification1field <- do
+    gzipheaderidentification1fieldp <-
+      DABL.take 1
+    -- Parse GZip header Identification 1 field.
+    case ( ( word8sToWord8LE $
+               DB.unpack gzipheaderidentification1fieldp
+           ) == 0x1f
+         ) of
+      False ->
+        fail $
+          show BAM_V1_6_Read_Error_GZipHeader_ID1_Incorrect_Format
+      True  -> do
+        -- Identification field 1 is in the accepted format.
+        return gzipheaderidentification1fieldp
+  gzipheaderidentification2field <- do
+    gzipheaderidentification2fieldp <-
+      DABL.take 1
+    -- Parse GZip header Identification 2 field.
+    case ( ( word8sToWord8LE $
+               DB.unpack gzipheaderidentification2fieldp
+           ) == 0x8b
+         ) of
+      False ->
+        fail $
+          show BAM_V1_6_Read_Error_GZipHeader_ID2_Incorrect_Format
+      True  ->
+        -- Identification field 2 is in the accepted format.
+        return gzipheaderidentification2fieldp 
+  gzipheadercompressionmethodfield <- do
+    gzipheadercompressionmethodfieldp <-
+      DABL.take 1
+    -- Parse GZip header Compression Method field.
+    case ( elem
+           ( word8sToWord8LE $
+               DB.unpack gzipheadercompressionmethodfieldp
+           )
+           compressionmethodpossiblebytes
+         ) of
+      False ->
+        fail $
+          show BAM_V1_6_Read_Error_GZipHeader_Compression_Method_Incorrect_Format
+      True  ->
+        -- Compression Method is in the accepted format.
+        return gzipheadercompressionmethodfieldp
+  gzipheaderflagsfield <- do
+    gzipheaderflagsfieldp <-
+      DABL.take 1
+    -- Parse GZip Flags (FLaGs) field.
+    case ( elem
+           ( word8sToWord8LE $
+               DB.unpack gzipheaderflagsfieldp
+           )
+           flagpossiblebytes
+         ) of
+      False ->
+        fail $
+          show BAM_V1_6_Read_Error_GZipHeader_Flag_Incorrect_Format
+      True  ->
+        -- Flags (FLaGs) is in the accepted format.
+        return gzipheaderflagsfieldp
+  gzipheadermodificationtimefield <-
+    DABL.take 4
+  gzipheaderextraflagsfield <-
+    DABL.take 1
+  gzipheaderoperatingsystemfield <- do
+    gzipheaderoperatingsystemfieldp <-
+      DABL.take 1
+    -- Parse GZip header Operating System field.
+    case ( elem
+             ( word8sToWord8LE $
+                 DB.unpack gzipheaderoperatingsystemfieldp
+             )
+           operatingsystempossiblebytes
+         ) of
+      False ->
+        fail $
+          show BAM_V1_6_Read_Error_GZipHeader_Operating_System_Incorrect_Format
+      True  ->
+        -- Operating System is in the accepted format.
+        return gzipheaderoperatingsystemfieldp
+  gzipheaderextralengthfield <-
+    DABL.take 2
+  let gzipheader = BAM_V1_6_GZipHeader
+                     { bam_v1_6_gzip_header_gzip_identifier_1  = word8sToWord8LE $
+                                                                   DB.unpack gzipheaderidentification1field
+                     , bam_v1_6_gzip_header_gzip_identifier_2  = word8sToWord8LE $
+                                                                   DB.unpack gzipheaderidentification2field
+                     , bam_v1_6_gzip_header_compression_method = word8sToWord8LE $
+                                                                   DB.unpack gzipheadercompressionmethodfield
+                     , bam_v1_6_gzip_header_header_flags       = word8sToWord8LE $
+                                                                   DB.unpack gzipheaderflagsfield
+                     , bam_v1_6_gzip_header_modification_time  = word8sToWord32LE $
+                                                                   DB.unpack gzipheadermodificationtimefield
+                     , bam_v1_6_gzip_header_extra_flags        = word8sToWord8LE $
+                                                                   DB.unpack gzipheaderextraflagsfield
+                     , bam_v1_6_gzip_header_operating_system   = word8sToWord8LE $
+                                                                   DB.unpack gzipheaderoperatingsystemfield
+                     , bam_v1_6_gzip_header_extra_length       = word8sToWord16LE $
+                                                                   DB.unpack gzipheaderextralengthfield
+                     }
+  bgzfblocksubfieldidentifier1field <- do
+    bgzfblocksubfieldidentifier1fieldp <-
+      DABL.take 1
+    -- Parse GZip header Subfield Identifier 1 field.
+    case ( ( word8sToWord8LE $
+               DB.unpack bgzfblocksubfieldidentifier1fieldp
+           ) == 0x42
+         ) of
+      False ->
+        fail $
+          show BAM_V1_6_Read_Error_GZipHeader_Subfield_Identifier_1_Incorrect_Format
+      True  ->
+        -- Subfield Identifier 1 is in the accepted format.
+        return bgzfblocksubfieldidentifier1fieldp
+  bgzfblocksubfieldidentifier2field <- do
+    bgzfblocksubfieldidentifier2fieldp <-
+      DABL.take 1
+    -- Parse GZip header Subfield Identifier 2 field.
+    case ( ( word8sToWord8LE $
+               DB.unpack bgzfblocksubfieldidentifier2fieldp
+           ) == 0x43
+         ) of
+      False ->
+        fail $
+          show BAM_V1_6_Read_Error_GZipHeader_Subfield_Identifier_2_Incorrect_Format
+      True  ->
+        -- Subfield Identifier 2 is in the accepted format.
+        return bgzfblocksubfieldidentifier2fieldp
+  bgzfblocksubfieldlengthfield <-
+    DABL.take 2
+  bgzfblocktotalblocksizeminus1field <-
+    DABL.take 2
+  bgzfblockcdata <-
+    DABL.take $
+      ( fromIntegral       $
+          word8sToWord16LE $
+            DB.unpack bgzfblocktotalblocksizeminus1field
+      ) -
+      ( fromIntegral       $
+          bam_v1_6_gzip_header_extra_length gzipheader
+      ) -
+      19
+  let bgzfblockcdataf = CCZlibR.decompress $
+                          DB.fromStrict bgzfblockcdata
+  case (parseOnly parse_BAM_V1_6_BAM bgzfblockcdataf) of
+    Left _                 ->
+      fail $
+        show BAM_V1_6_Read_Error_CDATA_Incorrect_Format
+    Right bgzfblockcdataf' -> do
+      bgzfblockcrc32field <-
+        DABL.take 4
+      case (crc32 bgzfblockcdataf == ( word8sToWord32LE $
+                                         DB.unpack bgzfblockcrc32field
+                                     )
+           ) of
+        False ->
+          fail $
+            show BAM_V1_6_Read_Error_Calculated_CRC32_Not_Equivalent_To_CRC32
+        True  -> do
+          bgzfblockisizefield <-
+            DABL.take 4
+          return BAM_V1_6_BGZFBlock
+                   { bam_v1_6_bgzfblock_gzip_header                = gzipheader
+                   , bam_v1_6_bgzfblock_subfield_identifier_one    = word8sToWord8LE $
+                                                                       DB.unpack bgzfblocksubfieldidentifier1field
+                   , bam_v1_6_bgzfblock_subfield_identifier_two    = word8sToWord8LE $
+                                                                       DB.unpack bgzfblocksubfieldidentifier2field
+                   , bam_v1_6_bgzfblock_subfield_length            = word8sToWord16LE $
+                                                                       DB.unpack bgzfblocksubfieldlengthfield
+                   , bam_v1_6_bgzfblock_total_block_size_minus_one = word8sToWord16LE $
+                                                                       DB.unpack bgzfblocktotalblocksizeminus1field
+                   , bam_v1_6_bgzfblock_cdata                      = bgzfblockcdataf'
+                   , bam_v1_6_bgzfblock_crc32                      = word8sToWord32LE $
+                                                                       DB.unpack bgzfblockcrc32field
+                   , bam_v1_6_bgzfblock_isize                      = word8sToWord32LE $
+                                                                       DB.unpack bgzfblockisizefield
+                   }
+  where
+    compressionmethodpossiblebytes = [ 0x00
+                                     , 0x01
+                                     , 0x02
+                                     , 0x03
+                                     , 0x04
+                                     , 0x05
+                                     , 0x06
+                                     , 0x07
+                                     , 0x08
+                                     ] :: [Word8]
+    flagpossiblebytes = [ 0x00
+                        , 0x01
+                        , 0x02
+                        , 0x03
+                        , 0x04
+                        , 0x05
+                        , 0x06
+                        , 0x07
+                        ] :: [Word8]
+    operatingsystempossiblebytes = [ 0x00
+                                   , 0x01
+                                   , 0x02
+                                   , 0x03
+                                   , 0x04
+                                   , 0x05
+                                   , 0x06
+                                   , 0x07
+                                   , 0x08
+                                   , 0x09
+                                   , 0x0A
+                                   , 0x0B
+                                   , 0x0C
+                                   , 0x0D
+                                   , 0xFF
+                                   ] :: [Word8]
diff --git a/src/Data/BAM/Version1_6/Write/Base.hs b/src/Data/BAM/Version1_6/Write/Base.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/Write/Base.hs
@@ -0,0 +1,1082 @@
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE MultiWayIf            #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.Write.Base
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.Write.Base ( -- * Writing
+                                        writeBAM_V1_6
+                                      ) where
+
+import Data.BAM.Version1_6.Base
+import Data.BAM.Version1_6.BAM
+import Data.BAM.Version1_6.BAM.BAMAlignments
+import Data.BAM.Version1_6.BAM.BAMHeader
+import Data.BAM.Version1_6.BAM.Alignment.Base
+import Data.BAM.Version1_6.BAM.Alignment.OptionalFields.Base
+import Data.BAM.Version1_6.BAM.Alignment.OptionalFields.AOPT
+import Data.BAM.Version1_6.BAM.Alignment.OptionalFields.BigCOPT
+import Data.BAM.Version1_6.BAM.Alignment.OptionalFields.BigIOPT
+import Data.BAM.Version1_6.BAM.Alignment.OptionalFields.BigSOPT
+import Data.BAM.Version1_6.BAM.Alignment.OptionalFields.SmallCOPT
+import Data.BAM.Version1_6.BAM.Alignment.OptionalFields.SmallIOPT
+import Data.BAM.Version1_6.BAM.Alignment.OptionalFields.SmallSOPT
+import Data.BAM.Version1_6.BAM.Alignment.OptionalFields.FOPT
+import Data.BAM.Version1_6.BAM.Alignment.OptionalFields.ZOPT
+import Data.BAM.Version1_6.BAM.Alignment.OptionalFields.HOPT
+import Data.BAM.Version1_6.BAM.Alignment.OptionalFields.BOPT
+import Data.BAM.Version1_6.BAM.ReferenceInformation
+import Data.BAM.Version1_6.BGZFBlock
+import Data.BAM.Version1_6.GZipHeader
+import Data.BAM.Version1_6.Internal
+import Data.BAM.Version1_6.Write.Error
+import Data.BAM.Version1_6.Write.Internal
+
+import Codec.Compression.Zlib.Raw as CCZlibR (compress)
+import Data.ByteString            as DB      (append,concat,empty,fromStrict,hPutStr,length,pack,singleton,toStrict)
+import Data.ByteString.Base16     as DBB16
+import Data.Base16.Types          as DBB16T
+import Data.Digest.CRC32          as DDCRC32 (crc32)
+import Data.Foldable                         (forM_,toList)
+import Data.List                  as DL      (elem)
+import Data.Maybe                            (fromJust)
+import System.IO                             (hFlush,hClose,IOMode(..),openBinaryFile,Handle)
+
+-- | Deconstruct a @"BAM_V1_6"@ and
+-- write to a file.
+deconstructBAM_V1_6 :: Handle
+                    -> BAM_V1_6
+                    -> IO ()
+deconstructBAM_V1_6 h
+                    bamv16 =
+  forM_ (bam_v1_6 bamv16) $ \currentbgzfblock ->
+    case ( bam_v1_6_bam_endoffilemarker $
+             bam_v1_6_bgzfblock_cdata currentbgzfblock
+         ) of
+      True  -> do
+        -- Write to file.
+        -- GZip header.
+        _ <-
+          DB.hPutStr h                                        $
+                     DB.singleton                             $
+                       bam_v1_6_gzip_header_gzip_identifier_1 $
+                         bam_v1_6_bgzfblock_gzip_header currentbgzfblock
+        _ <-
+          DB.hPutStr h                                        $
+                     DB.singleton                             $
+                       bam_v1_6_gzip_header_gzip_identifier_2 $
+                         bam_v1_6_bgzfblock_gzip_header currentbgzfblock
+        _ <-
+          DB.hPutStr h                                         $
+                     DB.singleton                              $
+                       bam_v1_6_gzip_header_compression_method $
+                         bam_v1_6_bgzfblock_gzip_header currentbgzfblock
+        _ <-
+          DB.hPutStr h                                   $
+                     DB.singleton                        $
+                       bam_v1_6_gzip_header_header_flags $
+                         bam_v1_6_bgzfblock_gzip_header currentbgzfblock
+        _ <-
+          DB.hPutStr h                                        $
+                     word32ToByteStringLE                     $
+                       bam_v1_6_gzip_header_modification_time $
+                         bam_v1_6_bgzfblock_gzip_header currentbgzfblock
+        _ <-
+          DB.hPutStr h                                  $
+                     DB.singleton                       $
+                       bam_v1_6_gzip_header_extra_flags $
+                         bam_v1_6_bgzfblock_gzip_header currentbgzfblock
+        _ <-
+          DB.hPutStr h                                       $
+                     DB.singleton                            $
+                       bam_v1_6_gzip_header_operating_system $
+                         bam_v1_6_bgzfblock_gzip_header currentbgzfblock   
+        _ <-
+          DB.hPutStr h                                   $
+                     word16ToByteStringLE                $
+                       bam_v1_6_gzip_header_extra_length $
+                         bam_v1_6_bgzfblock_gzip_header currentbgzfblock
+        -- Subfield Identifier 1.
+        _ <-
+          DB.hPutStr h            $
+                     DB.singleton $
+                       bam_v1_6_bgzfblock_subfield_identifier_one currentbgzfblock
+        -- Subfield Identifier 2.
+        _ <-
+          DB.hPutStr h            $
+                     DB.singleton $
+                       bam_v1_6_bgzfblock_subfield_identifier_two currentbgzfblock
+        -- Subfield LENgth.
+        _ <-
+          DB.hPutStr h                    $
+                     word16ToByteStringLE $
+                       bam_v1_6_bgzfblock_subfield_length currentbgzfblock
+        -- total Block SIZE minus 1.
+        _ <-
+          DB.hPutStr h                    $
+                     word16ToByteStringLE $
+                       bam_v1_6_bgzfblock_total_block_size_minus_one currentbgzfblock
+        -- Write the empty CDATA block.
+        _ <-
+          DB.hPutStr h $
+                     DB.pack
+                       [ 0x03
+                       , 0x00
+                       ]
+        -- CRC-32.
+        _ <-
+          DB.hPutStr h                    $
+                     word32ToByteStringLE $
+                         bam_v1_6_bgzfblock_crc32 currentbgzfblock
+        -- Input SIZE (length of uncompressed data).
+        DB.hPutStr h                    $
+                   word32ToByteStringLE $
+                     bam_v1_6_bgzfblock_isize currentbgzfblock
+      False ->
+        case ( bam_v1_6_bam_bamheader $
+                 bam_v1_6_bgzfblock_cdata currentbgzfblock
+             ) of
+          Nothing                      ->
+            case ( bam_v1_6_bam_bamalignments $
+                     bam_v1_6_bgzfblock_cdata currentbgzfblock
+                 ) of
+              Nothing ->
+                error $
+                  show BAM_V1_6_Write_Error_No_Data
+              Just bam_v1_6_bam_bamalignments' -> do
+                -- Write to file.
+                -- GZip header.
+                _ <-
+                  DB.hPutStr h                                        $
+                             DB.singleton                             $
+                               bam_v1_6_gzip_header_gzip_identifier_1 $
+                                 bam_v1_6_bgzfblock_gzip_header currentbgzfblock
+                _ <-
+                  DB.hPutStr h                                        $
+                             DB.singleton                             $
+                               bam_v1_6_gzip_header_gzip_identifier_2 $
+                                 bam_v1_6_bgzfblock_gzip_header currentbgzfblock
+                _ <-
+                  DB.hPutStr h                                         $
+                             DB.singleton                              $
+                               bam_v1_6_gzip_header_compression_method $
+                                 bam_v1_6_bgzfblock_gzip_header currentbgzfblock
+                _ <-
+                  DB.hPutStr h                                   $
+                             DB.singleton                        $
+                               bam_v1_6_gzip_header_header_flags $
+                                 bam_v1_6_bgzfblock_gzip_header currentbgzfblock
+                _ <-
+                  DB.hPutStr h                                        $
+                             word32ToByteStringLE                     $
+                               bam_v1_6_gzip_header_modification_time $
+                                 bam_v1_6_bgzfblock_gzip_header currentbgzfblock
+                _ <-
+                  DB.hPutStr h                                  $
+                             DB.singleton                       $
+                               bam_v1_6_gzip_header_extra_flags $
+                                 bam_v1_6_bgzfblock_gzip_header currentbgzfblock
+                _ <-
+                  DB.hPutStr h                                       $
+                             DB.singleton                            $
+                               bam_v1_6_gzip_header_operating_system $
+                                bam_v1_6_bgzfblock_gzip_header currentbgzfblock   
+                _ <-
+                  DB.hPutStr h                                   $
+                             word16ToByteStringLE                $
+                               bam_v1_6_gzip_header_extra_length $
+                                 bam_v1_6_bgzfblock_gzip_header currentbgzfblock
+                -- Subfield Identifier 1.
+                _ <-
+                  DB.hPutStr h            $
+                             DB.singleton $
+                               bam_v1_6_bgzfblock_subfield_identifier_one currentbgzfblock
+                -- Subfield Identifier 2.
+                _ <-
+                  DB.hPutStr h            $
+                             DB.singleton $
+                               bam_v1_6_bgzfblock_subfield_identifier_two currentbgzfblock
+                -- Subfield LENgth.
+                _ <-
+                  DB.hPutStr h                    $
+                             word16ToByteStringLE $
+                               bam_v1_6_bgzfblock_subfield_length currentbgzfblock
+                let bam_v1_6_bam_bamalignments'' = fmap (\currentbamalignmentrecord -> do
+                                                               let preoptionalfields = ( word32ToByteStringLE $
+                                                                                           bam_v1_6_bam_alignment_block_size currentbamalignmentrecord
+                                                                                       )
+                                                                                       `DB.append`
+                                                                                       ( int32ToByteStringLE $
+                                                                                           bam_v1_6_bam_alignment_refID currentbamalignmentrecord
+                                                                                       )
+                                                                                       `DB.append`
+                                                                                       ( int32ToByteStringLE $
+                                                                                           bam_v1_6_bam_alignment_pos currentbamalignmentrecord
+                                                                                       )
+                                                                                       `DB.append`
+                                                                                       ( DB.singleton $
+                                                                                           bam_v1_6_bam_alignment_l_read_name currentbamalignmentrecord
+                                                                                       )
+                                                                                       `DB.append`
+                                                                                       ( DB.singleton $
+                                                                                           bam_v1_6_bam_alignment_mapq currentbamalignmentrecord
+                                                                                       )
+                                                                                       `DB.append`
+                                                                                       ( word16ToByteStringLE $
+                                                                                           bam_v1_6_bam_alignment_bin currentbamalignmentrecord
+                                                                                       )
+                                                                                       `DB.append`
+                                                                                       ( word16ToByteStringLE $
+                                                                                           bam_v1_6_bam_alignment_n_cigar_op currentbamalignmentrecord
+                                                                                       )
+                                                                                       `DB.append`
+                                                                                       ( word16ToByteStringLE $
+                                                                                           bam_v1_6_bam_alignment_flag currentbamalignmentrecord
+                                                                                       )
+                                                                                       `DB.append`
+                                                                                       ( word32ToByteStringLE $
+                                                                                           bam_v1_6_bam_alignment_l_seq currentbamalignmentrecord
+                                                                                       )
+                                                                                       `DB.append`
+                                                                                       ( int32ToByteStringLE $
+                                                                                           bam_v1_6_bam_alignment_next_refID currentbamalignmentrecord
+                                                                                       )
+                                                                                       `DB.append`
+                                                                                       ( int32ToByteStringLE $
+                                                                                           bam_v1_6_bam_alignment_next_pos currentbamalignmentrecord
+                                                                                       )
+                                                                                       `DB.append`
+                                                                                       ( int32ToByteStringLE $
+                                                                                           bam_v1_6_bam_alignment_tlen currentbamalignmentrecord
+                                                                                       )
+                                                                                       `DB.append`
+                                                                                       bam_v1_6_bam_alignment_read_name currentbamalignmentrecord
+                                                                                       `DB.append`
+                                                                                       ( DB.concat $
+                                                                                           toList  $
+                                                                                             fmap (\currentcigar ->
+                                                                                                     word32ToByteStringLE currentcigar
+                                                                                                  )
+                                                                                             (bam_v1_6_bam_alignment_cigar currentbamalignmentrecord)
+                                                                                       )
+                                                                                       `DB.append`
+                                                                                       ( encodeSeqField $
+                                                                                           toList       $
+                                                                                             bam_v1_6_bam_alignment_seq currentbamalignmentrecord
+                                                                                       )
+                                                                                       `DB.append`
+                                                                                       ( bam_v1_6_bam_alignment_qual currentbamalignmentrecord
+                                                                                       )
+                                                               let optionalfields = DB.concat $
+                                                                                      toList  $
+                                                                                        fmap (\currentbamalignmentoptionalfield -> do
+                                                                                                -- Walk through optional fields.
+                                                                                                let optionalfieldsl = [ case ( bam_v1_6_bam_alignment_optionalfields_aopt
+                                                                                                                                 currentbamalignmentoptionalfield 
+                                                                                                                             ) of
+                                                                                                                          Nothing ->
+                                                                                                                            Empty
+                                                                                                                          Just _  ->
+                                                                                                                            AOPT
+                                                                                                                      , case ( bam_v1_6_bam_alignment_optionalfields_smallcopt
+                                                                                                                                 currentbamalignmentoptionalfield
+                                                                                                                             ) of
+                                                                                                                          Nothing ->
+                                                                                                                            Empty
+                                                                                                                          Just _  ->
+                                                                                                                            SmallCOPT
+                                                                                                                      , case ( bam_v1_6_bam_alignment_optionalfields_bigcopt
+                                                                                                                                 currentbamalignmentoptionalfield
+                                                                                                                             ) of
+                                                                                                                          Nothing ->
+                                                                                                                            Empty
+                                                                                                                          Just _  ->
+                                                                                                                            BigCOPT
+                                                                                                                      , case ( bam_v1_6_bam_alignment_optionalfields_smalliopt
+                                                                                                                                 currentbamalignmentoptionalfield
+                                                                                                                             ) of
+                                                                                                                          Nothing ->
+                                                                                                                            Empty
+                                                                                                                          Just _  ->
+                                                                                                                            SmallIOPT
+                                                                                                                      , case ( bam_v1_6_bam_alignment_optionalfields_bigiopt
+                                                                                                                                 currentbamalignmentoptionalfield
+                                                                                                                             ) of
+                                                                                                                          Nothing ->
+                                                                                                                            Empty
+                                                                                                                          Just _  ->
+                                                                                                                            BigIOPT
+                                                                                                                      , case ( bam_v1_6_bam_alignment_optionalfields_smallsopt
+                                                                                                                                 currentbamalignmentoptionalfield
+                                                                                                                             ) of
+                                                                                                                          Nothing ->
+                                                                                                                            Empty
+                                                                                                                          Just _  ->
+                                                                                                                            SmallSOPT
+                                                                                                                      , case ( bam_v1_6_bam_alignment_optionalfields_bigsopt
+                                                                                                                                 currentbamalignmentoptionalfield
+                                                                                                                             ) of
+                                                                                                                          Nothing ->
+                                                                                                                            Empty
+                                                                                                                          Just _  ->
+                                                                                                                            BigSOPT
+                                                                                                                      , case ( bam_v1_6_bam_alignment_optionalfields_fopt
+                                                                                                                                 currentbamalignmentoptionalfield
+                                                                                                                             ) of
+                                                                                                                          Nothing ->
+                                                                                                                            Empty
+                                                                                                                          Just _  ->
+                                                                                                                            FOPT
+                                                                                                                      , case ( bam_v1_6_bam_alignment_optionalfields_zopt
+                                                                                                                                 currentbamalignmentoptionalfield
+                                                                                                                             ) of
+                                                                                                                          Nothing ->
+                                                                                                                            Empty
+                                                                                                                          Just _  ->
+                                                                                                                            ZOPT
+                                                                                                                      , case ( bam_v1_6_bam_alignment_optionalfields_hopt
+                                                                                                                                 currentbamalignmentoptionalfield
+                                                                                                                             ) of
+                                                                                                                          Nothing ->
+                                                                                                                            Empty
+                                                                                                                          Just _  ->
+                                                                                                                            HOPT
+                                                                                                                      , case ( bam_v1_6_bam_alignment_optionalfields_bopt
+                                                                                                                                 currentbamalignmentoptionalfield
+                                                                                                                             ) of
+                                                                                                                          Nothing ->
+                                                                                                                            Empty
+                                                                                                                          Just _  ->
+                                                                                                                            BOPT
+                                                                                                                      ] :: [BAM_V1_6_BAM_Alignment_OptionalFields_SumType]
+                                                                                                if | AOPT `DL.elem` optionalfieldsl
+                                                                                                   -> ( bam_v1_6_bam_alignment_optionalfields_aopt_tag $
+                                                                                                          fromJust                                     $
+                                                                                                            bam_v1_6_bam_alignment_optionalfields_aopt
+                                                                                                              currentbamalignmentoptionalfield
+                                                                                                      )
+                                                                                                      `DB.append`
+                                                                                                      ( DB.singleton 0x41 --'A'
+                                                                                                      )
+                                                                                                      `DB.append`
+                                                                                                      ( DB.singleton                                       $
+                                                                                                          bam_v1_6_bam_alignment_optionalfields_aopt_value $
+                                                                                                            fromJust                                       $
+                                                                                                              bam_v1_6_bam_alignment_optionalfields_aopt
+                                                                                                                currentbamalignmentoptionalfield
+                                                                                                      )
+                                                                                                   | SmallCOPT `DL.elem` optionalfieldsl
+                                                                                                   -> ( bam_v1_6_bam_alignment_optionalfields_smallcopt_tag $
+                                                                                                          fromJust                                          $
+                                                                                                            bam_v1_6_bam_alignment_optionalfields_smallcopt
+                                                                                                              currentbamalignmentoptionalfield
+                                                                                                      )
+                                                                                                      `DB.append`
+                                                                                                      ( DB.singleton 0x63 --'c'
+                                                                                                      )
+                                                                                                      `DB.append`
+                                                                                                      ( int8ToByteString                                        $
+                                                                                                          bam_v1_6_bam_alignment_optionalfields_smallcopt_value $
+                                                                                                            fromJust                                            $
+                                                                                                              bam_v1_6_bam_alignment_optionalfields_smallcopt
+                                                                                                                currentbamalignmentoptionalfield
+                                                                                                      )
+                                                                                                   | BigCOPT `DL.elem` optionalfieldsl
+                                                                                                   -> ( bam_v1_6_bam_alignment_optionalfields_bigcopt_tag   $
+                                                                                                          fromJust                                          $
+                                                                                                            bam_v1_6_bam_alignment_optionalfields_bigcopt
+                                                                                                              currentbamalignmentoptionalfield
+                                                                                                      )
+                                                                                                      `DB.append`
+                                                                                                      ( DB.singleton 0x43 --'C'
+                                                                                                      )
+                                                                                                      `DB.append`
+                                                                                                      ( DB.singleton                                          $
+                                                                                                          bam_v1_6_bam_alignment_optionalfields_bigcopt_value $
+                                                                                                            fromJust                                          $
+                                                                                                              bam_v1_6_bam_alignment_optionalfields_bigcopt
+                                                                                                                currentbamalignmentoptionalfield
+                                                                                                      )
+                                                                                                   | SmallIOPT `DL.elem` optionalfieldsl
+                                                                                                   -> ( bam_v1_6_bam_alignment_optionalfields_smalliopt_tag $
+                                                                                                          fromJust                                          $
+                                                                                                            bam_v1_6_bam_alignment_optionalfields_smalliopt
+                                                                                                              currentbamalignmentoptionalfield
+                                                                                                      )
+                                                                                                      `DB.append`
+                                                                                                      ( DB.singleton 0x69 --'i'
+                                                                                                      )
+                                                                                                      `DB.append`
+                                                                                                      ( int32ToByteStringLE                                     $
+                                                                                                          bam_v1_6_bam_alignment_optionalfields_smalliopt_value $
+                                                                                                            fromJust                                            $
+                                                                                                              bam_v1_6_bam_alignment_optionalfields_smalliopt
+                                                                                                                currentbamalignmentoptionalfield
+                                                                                                      )
+                                                                                                   | BigIOPT `DL.elem` optionalfieldsl
+                                                                                                   -> ( bam_v1_6_bam_alignment_optionalfields_bigiopt_tag $
+                                                                                                          fromJust                                        $
+                                                                                                            bam_v1_6_bam_alignment_optionalfields_bigiopt
+                                                                                                              currentbamalignmentoptionalfield
+                                                                                                      )
+                                                                                                      `DB.append`
+                                                                                                      ( DB.singleton 0x49 --'I'
+                                                                                                      )
+                                                                                                      `DB.append`
+                                                                                                      ( word32ToByteStringLE                                  $
+                                                                                                          bam_v1_6_bam_alignment_optionalfields_bigiopt_value $
+                                                                                                            fromJust                                          $
+                                                                                                              bam_v1_6_bam_alignment_optionalfields_bigiopt
+                                                                                                                currentbamalignmentoptionalfield
+                                                                                                      )
+                                                                                                   | SmallSOPT `DL.elem` optionalfieldsl
+                                                                                                   -> ( bam_v1_6_bam_alignment_optionalfields_smallsopt_tag $
+                                                                                                          fromJust                                          $
+                                                                                                            bam_v1_6_bam_alignment_optionalfields_smallsopt
+                                                                                                              currentbamalignmentoptionalfield
+                                                                                                      )
+                                                                                                      `DB.append`
+                                                                                                      ( DB.singleton 0x73 --'s'
+                                                                                                      )
+                                                                                                      `DB.append`
+                                                                                                      ( int16ToByteStringLE                                     $
+                                                                                                          bam_v1_6_bam_alignment_optionalfields_smallsopt_value $
+                                                                                                            fromJust                                            $
+                                                                                                              bam_v1_6_bam_alignment_optionalfields_smallsopt
+                                                                                                                currentbamalignmentoptionalfield
+                                                                                                      )
+                                                                                                   | BigSOPT `DL.elem` optionalfieldsl
+                                                                                                   -> ( bam_v1_6_bam_alignment_optionalfields_bigsopt_tag $
+                                                                                                          fromJust                                        $
+                                                                                                            bam_v1_6_bam_alignment_optionalfields_bigsopt
+                                                                                                              currentbamalignmentoptionalfield
+                                                                                                      )
+                                                                                                      `DB.append`
+                                                                                                      ( DB.singleton 0x53 --'S'
+                                                                                                      )
+                                                                                                      `DB.append`
+                                                                                                      ( word16ToByteStringLE                                  $
+                                                                                                          bam_v1_6_bam_alignment_optionalfields_bigsopt_value $
+                                                                                                            fromJust                                          $
+                                                                                                              bam_v1_6_bam_alignment_optionalfields_bigsopt
+                                                                                                                currentbamalignmentoptionalfield
+                                                                                                      )
+                                                                                                   | FOPT `DL.elem` optionalfieldsl
+                                                                                                   -> ( bam_v1_6_bam_alignment_optionalfields_fopt_tag $
+                                                                                                          fromJust                                     $
+                                                                                                            bam_v1_6_bam_alignment_optionalfields_fopt
+                                                                                                              currentbamalignmentoptionalfield
+                                                                                                      )
+                                                                                                      `DB.append`
+                                                                                                      ( DB.singleton 0x66 --'f'
+                                                                                                      )
+                                                                                                      `DB.append`
+                                                                                                      ( word32ToByteStringLE                               $
+                                                                                                          bam_v1_6_bam_alignment_optionalfields_fopt_value $
+                                                                                                            fromJust                                       $
+                                                                                                              bam_v1_6_bam_alignment_optionalfields_fopt
+                                                                                                                currentbamalignmentoptionalfield
+                                                                                                      )
+                                                                                                   | ZOPT `DL.elem` optionalfieldsl
+                                                                                                   -> ( bam_v1_6_bam_alignment_optionalfields_zopt_tag $
+                                                                                                          fromJust                                     $
+                                                                                                            bam_v1_6_bam_alignment_optionalfields_zopt
+                                                                                                              currentbamalignmentoptionalfield
+                                                                                                      )
+                                                                                                      `DB.append`
+                                                                                                      ( DB.singleton 0x5A --'Z'
+                                                                                                      )
+                                                                                                      `DB.append`
+                                                                                                      ( DB.pack                                              $
+                                                                                                          toList                                             $
+                                                                                                            bam_v1_6_bam_alignment_optionalfields_zopt_value $
+                                                                                                              fromJust                                       $
+                                                                                                                bam_v1_6_bam_alignment_optionalfields_zopt
+                                                                                                                  currentbamalignmentoptionalfield
+                                                                                                      )
+                                                                                                      `DB.append`
+                                                                                                      ( DB.singleton 0x00
+                                                                                                      )
+                                                                                                   | HOPT `DL.elem` optionalfieldsl
+                                                                                                   -> ( bam_v1_6_bam_alignment_optionalfields_hopt_tag $
+                                                                                                          fromJust                                     $
+                                                                                                            bam_v1_6_bam_alignment_optionalfields_hopt
+                                                                                                              currentbamalignmentoptionalfield
+                                                                                                      )
+                                                                                                      `DB.append`
+                                                                                                      ( DB.singleton 0x48 --'H'
+                                                                                                      )
+                                                                                                      `DB.append`
+                                                                                                      ( DB.concat $
+                                                                                                          toList
+                                                                                                            ( fmap (\currenthexvalue ->
+                                                                                                                      case ( DBB16.isBase16 ( DBB16T.extractBase16 $
+                                                                                                                                                DBB16.encodeBase16' currenthexvalue
+                                                                                                                                            )
+                                                                                                                           ) of
+                                                                                                                        False ->
+                                                                                                                          error $
+                                                                                                                            show BAM_V1_6_Write_Error_HOPT_Incorrect_Format
+                                                                                                                        True  ->
+                                                                                                                          DBB16T.extractBase16 $
+                                                                                                                            DBB16.encodeBase16' currenthexvalue
+                                                                                                                   )
+                                                                                                              ( bam_v1_6_bam_alignment_optionalfields_hopt_value $
+                                                                                                                  fromJust                                       $
+                                                                                                                    bam_v1_6_bam_alignment_optionalfields_hopt
+                                                                                                                      currentbamalignmentoptionalfield
+                                                                                                              )
+                                                                                                            )
+                                                                                                      )
+                                                                                                      `DB.append`
+                                                                                                      ( DB.singleton 0x00
+                                                                                                      )
+                                                                                                   | BOPT `DL.elem` optionalfieldsl
+                                                                                                   -> do
+                                                                                                     let optionalfieldsboptl = [ case ( bam_v1_6_bam_alignment_optionalfields_bopt_int8 $
+                                                                                                                                          fromJust                                      $
+                                                                                                                                            bam_v1_6_bam_alignment_optionalfields_bopt
+                                                                                                                                              currentbamalignmentoptionalfield
+                                                                                                                                      ) of
+                                                                                                                                   Nothing ->
+                                                                                                                                     BOPTEmpty
+                                                                                                                                   Just _  ->
+                                                                                                                                     BOPTInt8
+                                                                                                                               , case ( bam_v1_6_bam_alignment_optionalfields_bopt_word8 $
+                                                                                                                                          fromJust                                       $
+                                                                                                                                            bam_v1_6_bam_alignment_optionalfields_bopt
+                                                                                                                                              currentbamalignmentoptionalfield
+                                                                                                                                      ) of
+                                                                                                                                   Nothing ->
+                                                                                                                                     BOPTEmpty
+                                                                                                                                   Just _  ->
+                                                                                                                                     BOPTWord8
+                                                                                                                               , case ( bam_v1_6_bam_alignment_optionalfields_bopt_int16 $
+                                                                                                                                          fromJust                                       $
+                                                                                                                                            bam_v1_6_bam_alignment_optionalfields_bopt
+                                                                                                                                              currentbamalignmentoptionalfield
+                                                                                                                                      ) of
+                                                                                                                                   Nothing ->
+                                                                                                                                     BOPTEmpty
+                                                                                                                                   Just _  ->
+                                                                                                                                     BOPTInt16
+                                                                                                                               , case ( bam_v1_6_bam_alignment_optionalfields_bopt_word16 $
+                                                                                                                                          fromJust                                        $
+                                                                                                                                            bam_v1_6_bam_alignment_optionalfields_bopt
+                                                                                                                                              currentbamalignmentoptionalfield
+                                                                                                                                      ) of
+                                                                                                                                   Nothing ->
+                                                                                                                                     BOPTEmpty
+                                                                                                                                   Just _  ->
+                                                                                                                                     BOPTWord16
+                                                                                                                               , case ( bam_v1_6_bam_alignment_optionalfields_bopt_int32 $
+                                                                                                                                          fromJust                                       $
+                                                                                                                                            bam_v1_6_bam_alignment_optionalfields_bopt
+                                                                                                                                              currentbamalignmentoptionalfield
+                                                                                                                                      ) of
+                                                                                                                                   Nothing ->
+                                                                                                                                     BOPTEmpty
+                                                                                                                                   Just _  ->
+                                                                                                                                     BOPTInt32
+                                                                                                                               , case ( bam_v1_6_bam_alignment_optionalfields_bopt_word32 $
+                                                                                                                                          fromJust                                        $
+                                                                                                                                            bam_v1_6_bam_alignment_optionalfields_bopt
+                                                                                                                                              currentbamalignmentoptionalfield
+                                                                                                                                      ) of
+                                                                                                                                   Nothing ->
+                                                                                                                                     BOPTEmpty
+                                                                                                                                   Just _  ->
+                                                                                                                                     BOPTWord32
+                                                                                                                               , case ( bam_v1_6_bam_alignment_optionalfields_bopt_float $
+                                                                                                                                          fromJust                                       $
+                                                                                                                                            bam_v1_6_bam_alignment_optionalfields_bopt
+                                                                                                                                              currentbamalignmentoptionalfield
+                                                                                                                                      ) of
+                                                                                                                                   Nothing ->
+                                                                                                                                     BOPTEmpty
+                                                                                                                                   Just _  ->
+                                                                                                                                     BOPTFloat
+                                                                                                                               ] :: [BAM_V1_6_BAM_Alignment_OptionalFields_BOPT_SumType]
+                                                                                                     if | BOPTInt8 `DL.elem` optionalfieldsboptl
+                                                                                                        -> ( bam_v1_6_bam_alignment_optionalfields_bopt_int8_tag $
+                                                                                                               fromJust                                          $
+                                                                                                                 bam_v1_6_bam_alignment_optionalfields_bopt_int8 $
+                                                                                                                   fromJust                                      $
+                                                                                                                     bam_v1_6_bam_alignment_optionalfields_bopt
+                                                                                                                       currentbamalignmentoptionalfield
+                                                                                                           )
+                                                                                                           `DB.append`
+                                                                                                           ( DB.singleton 0x42 --'B'
+                                                                                                           )
+                                                                                                           `DB.append`
+                                                                                                           ( bam_v1_6_bam_alignment_optionalfields_bopt_int8_type $
+                                                                                                               fromJust                                           $
+                                                                                                                 bam_v1_6_bam_alignment_optionalfields_bopt_int8  $
+                                                                                                                   fromJust                                       $
+                                                                                                                     bam_v1_6_bam_alignment_optionalfields_bopt
+                                                                                                                       currentbamalignmentoptionalfield
+                                                                                                           )
+                                                                                                           `DB.append`
+                                                                                                           ( word32ToByteStringLE                                    $
+                                                                                                               bam_v1_6_bam_alignment_optionalfields_bopt_int8_count $
+                                                                                                                 fromJust                                            $
+                                                                                                                   bam_v1_6_bam_alignment_optionalfields_bopt_int8   $
+                                                                                                                     fromJust                                        $
+                                                                                                                       bam_v1_6_bam_alignment_optionalfields_bopt
+                                                                                                                         currentbamalignmentoptionalfield
+                                                                                                           )
+                                                                                                           `DB.append`
+                                                                                                           ( DB.concat $
+                                                                                                               toList
+                                                                                                                 ( fmap (\currentint8value ->
+                                                                                                                           int8ToByteString currentint8value
+                                                                                                                        )
+                                                                                                                   ( bam_v1_6_bam_alignment_optionalfields_bopt_int8_value $
+                                                                                                                       fromJust                                            $
+                                                                                                                         bam_v1_6_bam_alignment_optionalfields_bopt_int8   $
+                                                                                                                           fromJust                                        $
+                                                                                                                             bam_v1_6_bam_alignment_optionalfields_bopt
+                                                                                                                                currentbamalignmentoptionalfield 
+                                                                                                                   )
+                                                                                                                 )
+                                                                                                           )
+                                                                                                        | BOPTWord8 `DL.elem` optionalfieldsboptl
+                                                                                                        -> ( bam_v1_6_bam_alignment_optionalfields_bopt_word8_tag $
+                                                                                                               fromJust                                           $
+                                                                                                                 bam_v1_6_bam_alignment_optionalfields_bopt_word8 $
+                                                                                                                   fromJust                                       $
+                                                                                                                     bam_v1_6_bam_alignment_optionalfields_bopt
+                                                                                                                       currentbamalignmentoptionalfield
+                                                                                                           )
+                                                                                                           `DB.append`
+                                                                                                           ( DB.singleton 0x42 --'B'
+                                                                                                           )
+                                                                                                           `DB.append`
+                                                                                                           ( bam_v1_6_bam_alignment_optionalfields_bopt_word8_type $
+                                                                                                               fromJust                                            $
+                                                                                                                 bam_v1_6_bam_alignment_optionalfields_bopt_word8  $
+                                                                                                                   fromJust                                        $
+                                                                                                                     bam_v1_6_bam_alignment_optionalfields_bopt
+                                                                                                                       currentbamalignmentoptionalfield
+                                                                                                           )
+                                                                                                           `DB.append`
+                                                                                                           ( word32ToByteStringLE                                     $
+                                                                                                               bam_v1_6_bam_alignment_optionalfields_bopt_word8_count $
+                                                                                                                 fromJust                                             $
+                                                                                                                   bam_v1_6_bam_alignment_optionalfields_bopt_word8   $
+                                                                                                                     fromJust                                         $
+                                                                                                                       bam_v1_6_bam_alignment_optionalfields_bopt
+                                                                                                                         currentbamalignmentoptionalfield
+                                                                                                           )
+                                                                                                           `DB.append`
+                                                                                                           ( DB.concat $
+                                                                                                               toList
+                                                                                                                 ( fmap (\currentword8value ->
+                                                                                                                           DB.singleton currentword8value
+                                                                                                                        )
+                                                                                                                   ( bam_v1_6_bam_alignment_optionalfields_bopt_word8_value $
+                                                                                                                       fromJust                                             $
+                                                                                                                         bam_v1_6_bam_alignment_optionalfields_bopt_word8   $
+                                                                                                                           fromJust                                         $
+                                                                                                                             bam_v1_6_bam_alignment_optionalfields_bopt
+                                                                                                                               currentbamalignmentoptionalfield
+                                                                                                                   )
+                                                                                                                 )
+                                                                                                           )
+                                                                                                        | BOPTInt16 `DL.elem` optionalfieldsboptl
+                                                                                                        -> ( bam_v1_6_bam_alignment_optionalfields_bopt_int16_tag $
+                                                                                                               fromJust                                           $
+                                                                                                                 bam_v1_6_bam_alignment_optionalfields_bopt_int16 $
+                                                                                                                   fromJust                                       $
+                                                                                                                     bam_v1_6_bam_alignment_optionalfields_bopt
+                                                                                                                       currentbamalignmentoptionalfield
+                                                                                                           )
+                                                                                                           `DB.append`
+                                                                                                           ( DB.singleton 0x42 --'B'
+                                                                                                           )
+                                                                                                           `DB.append`
+                                                                                                           ( bam_v1_6_bam_alignment_optionalfields_bopt_int16_type $
+                                                                                                               fromJust                                            $
+                                                                                                                 bam_v1_6_bam_alignment_optionalfields_bopt_int16  $
+                                                                                                                   fromJust                                        $
+                                                                                                                     bam_v1_6_bam_alignment_optionalfields_bopt
+                                                                                                                       currentbamalignmentoptionalfield
+                                                                                                           )
+                                                                                                           `DB.append`
+                                                                                                           ( word32ToByteStringLE                                     $
+                                                                                                               bam_v1_6_bam_alignment_optionalfields_bopt_int16_count $
+                                                                                                                 fromJust                                             $
+                                                                                                                   bam_v1_6_bam_alignment_optionalfields_bopt_int16   $
+                                                                                                                     fromJust                                         $
+                                                                                                                       bam_v1_6_bam_alignment_optionalfields_bopt
+                                                                                                                         currentbamalignmentoptionalfield
+                                                                                                           )
+                                                                                                           `DB.append`
+                                                                                                           ( DB.concat $
+                                                                                                               toList
+                                                                                                                 ( fmap (\currentint16value ->
+                                                                                                                          int16ToByteStringLE currentint16value
+                                                                                                                       )
+                                                                                                                   ( bam_v1_6_bam_alignment_optionalfields_bopt_int16_value $
+                                                                                                                       fromJust                                             $
+                                                                                                                         bam_v1_6_bam_alignment_optionalfields_bopt_int16   $
+                                                                                                                           fromJust                                         $
+                                                                                                                             bam_v1_6_bam_alignment_optionalfields_bopt
+                                                                                                                               currentbamalignmentoptionalfield
+                                                                                                                   )
+                                                                                                                 )
+                                                                                                           )
+                                                                                                        | BOPTWord16 `DL.elem` optionalfieldsboptl
+                                                                                                        -> ( bam_v1_6_bam_alignment_optionalfields_bopt_word16_tag $
+                                                                                                               fromJust                                            $
+                                                                                                                 bam_v1_6_bam_alignment_optionalfields_bopt_word16 $
+                                                                                                                   fromJust                                        $
+                                                                                                                     bam_v1_6_bam_alignment_optionalfields_bopt
+                                                                                                                       currentbamalignmentoptionalfield
+                                                                                                           )
+                                                                                                           `DB.append`
+                                                                                                           ( DB.singleton 0x42 --'B'
+                                                                                                           )
+                                                                                                           `DB.append`
+                                                                                                           ( bam_v1_6_bam_alignment_optionalfields_bopt_word16_type $
+                                                                                                               fromJust                                             $
+                                                                                                                 bam_v1_6_bam_alignment_optionalfields_bopt_word16  $
+                                                                                                                   fromJust                                         $
+                                                                                                                     bam_v1_6_bam_alignment_optionalfields_bopt
+                                                                                                                       currentbamalignmentoptionalfield
+                                                                                                           )
+                                                                                                           `DB.append`
+                                                                                                           ( word32ToByteStringLE                                      $
+                                                                                                               bam_v1_6_bam_alignment_optionalfields_bopt_word16_count $
+                                                                                                                 fromJust                                              $
+                                                                                                                   bam_v1_6_bam_alignment_optionalfields_bopt_word16   $
+                                                                                                                     fromJust                                          $
+                                                                                                                       bam_v1_6_bam_alignment_optionalfields_bopt
+                                                                                                                         currentbamalignmentoptionalfield
+                                                                                                           )
+                                                                                                           `DB.append`
+                                                                                                           ( DB.concat $
+                                                                                                               toList
+                                                                                                                 ( fmap (\currentword16value ->
+                                                                                                                           word16ToByteStringLE currentword16value
+                                                                                                                        )
+                                                                                                                   ( bam_v1_6_bam_alignment_optionalfields_bopt_word16_value $
+                                                                                                                       fromJust                                              $
+                                                                                                                         bam_v1_6_bam_alignment_optionalfields_bopt_word16   $
+                                                                                                                           fromJust                                          $
+                                                                                                                             bam_v1_6_bam_alignment_optionalfields_bopt
+                                                                                                                                currentbamalignmentoptionalfield
+                                                                                                                   )
+                                                                                                                 )
+                                                                                                           )
+                                                                                                        | BOPTInt32 `DL.elem` optionalfieldsboptl
+                                                                                                        -> ( bam_v1_6_bam_alignment_optionalfields_bopt_int32_tag $
+                                                                                                               fromJust                                           $
+                                                                                                                 bam_v1_6_bam_alignment_optionalfields_bopt_int32 $
+                                                                                                                   fromJust                                       $
+                                                                                                                     bam_v1_6_bam_alignment_optionalfields_bopt
+                                                                                                                       currentbamalignmentoptionalfield
+                                                                                                           )
+                                                                                                           `DB.append`
+                                                                                                           ( DB.singleton 0x42 --'B'
+                                                                                                           )
+                                                                                                           `DB.append`
+                                                                                                           ( bam_v1_6_bam_alignment_optionalfields_bopt_int32_type $
+                                                                                                               fromJust                                            $
+                                                                                                                 bam_v1_6_bam_alignment_optionalfields_bopt_int32  $
+                                                                                                                   fromJust                                        $
+                                                                                                                     bam_v1_6_bam_alignment_optionalfields_bopt
+                                                                                                                       currentbamalignmentoptionalfield
+                                                                                                           )
+                                                                                                           `DB.append`
+                                                                                                           ( word32ToByteStringLE                                     $
+                                                                                                               bam_v1_6_bam_alignment_optionalfields_bopt_int32_count $
+                                                                                                                 fromJust                                             $
+                                                                                                                   bam_v1_6_bam_alignment_optionalfields_bopt_int32   $
+                                                                                                                     fromJust                                         $
+                                                                                                                       bam_v1_6_bam_alignment_optionalfields_bopt
+                                                                                                                         currentbamalignmentoptionalfield
+                                                                                                           )
+                                                                                                           `DB.append`
+                                                                                                           ( DB.concat $
+                                                                                                               toList
+                                                                                                                 ( fmap (\currentint32value ->
+                                                                                                                          int32ToByteStringLE currentint32value
+                                                                                                                       )
+                                                                                                                   ( bam_v1_6_bam_alignment_optionalfields_bopt_int32_value $
+                                                                                                                       fromJust                                             $
+                                                                                                                         bam_v1_6_bam_alignment_optionalfields_bopt_int32   $
+                                                                                                                           fromJust                                         $
+                                                                                                                             bam_v1_6_bam_alignment_optionalfields_bopt
+                                                                                                                               currentbamalignmentoptionalfield
+                                                                                                                   )
+                                                                                                                 )
+                                                                                                           )
+                                                                                                        | BOPTWord32 `DL.elem` optionalfieldsboptl
+                                                                                                        -> ( bam_v1_6_bam_alignment_optionalfields_bopt_word32_tag $
+                                                                                                               fromJust                                            $
+                                                                                                                 bam_v1_6_bam_alignment_optionalfields_bopt_word32 $
+                                                                                                                   fromJust                                        $
+                                                                                                                     bam_v1_6_bam_alignment_optionalfields_bopt
+                                                                                                                       currentbamalignmentoptionalfield
+                                                                                                           )
+                                                                                                           `DB.append`
+                                                                                                           ( DB.singleton 0x42 --'B'
+                                                                                                           )
+                                                                                                           `DB.append`
+                                                                                                           ( bam_v1_6_bam_alignment_optionalfields_bopt_word32_type $
+                                                                                                               fromJust                                             $
+                                                                                                                 bam_v1_6_bam_alignment_optionalfields_bopt_word32  $
+                                                                                                                   fromJust                                         $
+                                                                                                                     bam_v1_6_bam_alignment_optionalfields_bopt
+                                                                                                                       currentbamalignmentoptionalfield
+                                                                                                           )
+                                                                                                           `DB.append`
+                                                                                                           ( word32ToByteStringLE                                      $
+                                                                                                               bam_v1_6_bam_alignment_optionalfields_bopt_word32_count $
+                                                                                                                 fromJust                                              $
+                                                                                                                   bam_v1_6_bam_alignment_optionalfields_bopt_word32   $
+                                                                                                                     fromJust                                          $
+                                                                                                                       bam_v1_6_bam_alignment_optionalfields_bopt
+                                                                                                                         currentbamalignmentoptionalfield
+                                                                                                           )
+                                                                                                           `DB.append`
+                                                                                                           ( DB.concat $
+                                                                                                               toList
+                                                                                                                 ( fmap (\currentword32value ->
+                                                                                                                          word32ToByteStringLE currentword32value
+                                                                                                                       )
+                                                                                                                   ( bam_v1_6_bam_alignment_optionalfields_bopt_word32_value $
+                                                                                                                       fromJust                                              $
+                                                                                                                         bam_v1_6_bam_alignment_optionalfields_bopt_word32   $
+                                                                                                                           fromJust                                          $
+                                                                                                                             bam_v1_6_bam_alignment_optionalfields_bopt
+                                                                                                                               currentbamalignmentoptionalfield
+                                                                                                                   )
+                                                                                                                 )
+                                                                                                           )
+                                                                                                        | BOPTFloat `DL.elem` optionalfieldsboptl
+                                                                                                        -> ( bam_v1_6_bam_alignment_optionalfields_bopt_float_tag $
+                                                                                                               fromJust                                           $
+                                                                                                                 bam_v1_6_bam_alignment_optionalfields_bopt_float $
+                                                                                                                   fromJust                                       $
+                                                                                                                     bam_v1_6_bam_alignment_optionalfields_bopt
+                                                                                                                       currentbamalignmentoptionalfield
+                                                                                                           )
+                                                                                                           `DB.append`
+                                                                                                           ( DB.singleton 0x42 --'B'
+                                                                                                           )
+                                                                                                           `DB.append`
+                                                                                                           ( bam_v1_6_bam_alignment_optionalfields_bopt_float_type $
+                                                                                                               fromJust                                            $
+                                                                                                                 bam_v1_6_bam_alignment_optionalfields_bopt_float  $
+                                                                                                                   fromJust                                        $
+                                                                                                                     bam_v1_6_bam_alignment_optionalfields_bopt
+                                                                                                                       currentbamalignmentoptionalfield
+                                                                                                           )
+                                                                                                           `DB.append`
+                                                                                                           ( word32ToByteStringLE                                     $
+                                                                                                               bam_v1_6_bam_alignment_optionalfields_bopt_float_count $
+                                                                                                                 fromJust                                             $
+                                                                                                                   bam_v1_6_bam_alignment_optionalfields_bopt_float   $
+                                                                                                                     fromJust                                         $
+                                                                                                                       bam_v1_6_bam_alignment_optionalfields_bopt
+                                                                                                                         currentbamalignmentoptionalfield
+                                                                                                           )
+                                                                                                           `DB.append`
+                                                                                                           ( DB.concat $
+                                                                                                               toList
+                                                                                                                 ( fmap (\currentfloatvalue ->
+                                                                                                                          floatToByteStringLE currentfloatvalue
+                                                                                                                       )
+                                                                                                                   ( bam_v1_6_bam_alignment_optionalfields_bopt_float_value $
+                                                                                                                       fromJust                                             $
+                                                                                                                         bam_v1_6_bam_alignment_optionalfields_bopt_float   $
+                                                                                                                           fromJust                                         $
+                                                                                                                             bam_v1_6_bam_alignment_optionalfields_bopt
+                                                                                                                               currentbamalignmentoptionalfield
+                                                                                                                   )
+                                                                                                                 )
+                                                                                                           )
+                                                                                                        | BOPTEmpty `DL.elem` optionalfieldsboptl
+                                                                                                        -> DB.empty
+                                                                                                        | otherwise
+                                                                                                        -> DB.empty
+                                                                                                   | Empty `DL.elem` optionalfieldsl
+                                                                                                   -> DB.empty
+                                                                                                   | otherwise
+                                                                                                   -> DB.empty 
+                                                                                             )
+                                                                                        ( bam_v1_6_bam_alignment_optionalfields currentbamalignmentrecord
+                                                                                        )
+                                                               preoptionalfields `DB.append` optionalfields
+                                                            )
+                                                       ( bam_v1_6_bam_bamalignments_alignments bam_v1_6_bam_bamalignments'
+                                                       )
+                let bam_v1_6_bam_bamalignments''' = DB.toStrict        $
+                                                      CCZlibR.compress $
+                                                        DB.fromStrict  $
+                                                          DB.concat    $
+                                                            toList bam_v1_6_bam_bamalignments''
+                -- total Block SIZE minus 1.
+                _ <-
+                  DB.hPutStr h                    $
+                             word16ToByteStringLE $
+                             intToWord16LE ((DB.length bam_v1_6_bam_bamalignments''' + 26) - 1)
+                -- Write the BAM alignment(s).
+                _ <-
+                  DB.hPutStr h
+                             bam_v1_6_bam_bamalignments'''
+                -- CRC-32.
+                _ <-
+                  DB.hPutStr h           $
+                    word32ToByteStringLE $
+                      DDCRC32.crc32      $
+                        DB.concat        $
+                          toList bam_v1_6_bam_bamalignments''
+                -- Input SIZE (length of uncompressed data).
+                DB.hPutStr h                    $
+                           word32ToByteStringLE $
+                             intToWord32LE      $
+                               DB.length        $
+                                 DB.concat      $
+                                   toList bam_v1_6_bam_bamalignments''
+          Just bam_v1_6_bam_bamheader' -> do
+            -- Write to file.
+            -- GZip header.
+            _ <-
+              DB.hPutStr h                                        $
+                         DB.singleton                             $
+                           bam_v1_6_gzip_header_gzip_identifier_1 $
+                             bam_v1_6_bgzfblock_gzip_header currentbgzfblock
+            _ <-
+              DB.hPutStr h                                        $
+                         DB.singleton                             $
+                           bam_v1_6_gzip_header_gzip_identifier_2 $
+                             bam_v1_6_bgzfblock_gzip_header currentbgzfblock
+            _ <-
+              DB.hPutStr h                                         $
+                         DB.singleton                              $
+                           bam_v1_6_gzip_header_compression_method $
+                             bam_v1_6_bgzfblock_gzip_header currentbgzfblock
+            _ <-
+              DB.hPutStr h                                   $
+                         DB.singleton                        $
+                           bam_v1_6_gzip_header_header_flags $
+                             bam_v1_6_bgzfblock_gzip_header currentbgzfblock
+            _ <-
+              DB.hPutStr h                                        $
+                         word32ToByteStringLE                     $
+                           bam_v1_6_gzip_header_modification_time $
+                             bam_v1_6_bgzfblock_gzip_header currentbgzfblock
+            _ <-
+              DB.hPutStr h                                  $
+                         DB.singleton                       $
+                           bam_v1_6_gzip_header_extra_flags $
+                             bam_v1_6_bgzfblock_gzip_header currentbgzfblock
+            _ <-
+              DB.hPutStr h                                       $
+                         DB.singleton                            $
+                           bam_v1_6_gzip_header_operating_system $
+                            bam_v1_6_bgzfblock_gzip_header currentbgzfblock   
+            _ <-
+              DB.hPutStr h                                   $
+                         word16ToByteStringLE                $
+                           bam_v1_6_gzip_header_extra_length $
+                             bam_v1_6_bgzfblock_gzip_header currentbgzfblock
+            -- Subfield Identifier 1.
+            _ <-
+              DB.hPutStr h            $
+                         DB.singleton $
+                           bam_v1_6_bgzfblock_subfield_identifier_one currentbgzfblock
+            -- Subfield Identifier 2.
+            _ <-
+              DB.hPutStr h            $
+                         DB.singleton $
+                           bam_v1_6_bgzfblock_subfield_identifier_two currentbgzfblock
+            -- Subfield LENgth.
+            _ <-
+              DB.hPutStr h                    $
+                         word16ToByteStringLE $
+                           bam_v1_6_bgzfblock_subfield_length currentbgzfblock
+            let bam_v1_6_bam_bamheader'' = bam_v1_6_bam_bamheader_magic bam_v1_6_bam_bamheader'
+                                           `DB.append`
+                                           ( word32ToByteStringLE $
+                                               bam_v1_6_bam_bamheader_l_text bam_v1_6_bam_bamheader'
+                                           )
+                                           `DB.append`
+                                           bam_v1_6_bam_bamheader_text bam_v1_6_bam_bamheader'
+                                           `DB.append`
+                                           ( word32ToByteStringLE $
+                                               bam_v1_6_bam_bamheader_n_ref bam_v1_6_bam_bamheader'
+                                           )
+            let bam_v1_6_bam_bamheader_reference_information' = DB.concat $
+                                                                  toList  $
+                                                                    fmap (\currentreferenceinformation ->
+                                                                             ( word32ToByteStringLE $
+                                                                                 bam_v1_6_bam_reference_information_l_name currentreferenceinformation
+                                                                             )
+                                                                             `DB.append`
+                                                                             bam_v1_6_bam_reference_information_name currentreferenceinformation
+                                                                             `DB.append`
+                                                                             ( word32ToByteStringLE $
+                                                                                 bam_v1_6_bam_reference_information_l_ref currentreferenceinformation
+                                                                             )
+                                                                         )
+                                                                    (bam_v1_6_bam_bamheader_reference_information bam_v1_6_bam_bamheader')
+            let bam_v1_6_bam_bamheader''' = DB.toStrict        $
+                                              CCZlibR.compress $
+                                                DB.fromStrict  $
+                                                  bam_v1_6_bam_bamheader''
+                                                  `DB.append`
+                                                  bam_v1_6_bam_bamheader_reference_information'
+            -- total Block SIZE minus 1.
+            _ <-
+              DB.hPutStr h                    $
+                         word16ToByteStringLE $
+                         intToWord16LE ((DB.length bam_v1_6_bam_bamheader''' + 26) - 1)
+            -- Write the BAM header.
+            _ <-
+              DB.hPutStr h
+                         bam_v1_6_bam_bamheader'''
+            -- CRC-32.
+            _ <-
+              DB.hPutStr h           $
+                word32ToByteStringLE $
+                  DDCRC32.crc32      $
+                    bam_v1_6_bam_bamheader''
+                    `DB.append`
+                    bam_v1_6_bam_bamheader_reference_information'
+            -- Input SIZE (length of uncompressed data).
+            DB.hPutStr h           $
+              word32ToByteStringLE $
+                intToWord32LE      $
+                  DB.length        $
+                    bam_v1_6_bam_bamheader''
+                    `DB.append`
+                    bam_v1_6_bam_bamheader_reference_information'
+
+-- | Write a @"BAM_V1_6"@ to a file.
+--
+-- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+writeBAM_V1_6 :: FilePath -- ^ Output path to BAM file.
+              -> BAM_V1_6
+              -> IO ()
+writeBAM_V1_6 fp bamv16 = do
+  h <- openBinaryFile fp
+                WriteMode
+  deconstructBAM_V1_6 h
+                      bamv16
+  hFlush h
+  hClose h
diff --git a/src/Data/BAM/Version1_6/Write/Error.hs b/src/Data/BAM/Version1_6/Write/Error.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/Write/Error.hs
@@ -0,0 +1,33 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE StrictData            #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.BAM.Version1_6.Write.Error
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.Write.Error ( -- * BAM version 1.6 data type
+                                         BAM_V1_6_Write_Error(..)
+                                       ) where
+
+import Data.Data
+import Generics.Deriving.Base
+
+-- | Custom @"BAM_V1_6"@ (BAM version 1.6) error data type.
+-- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data BAM_V1_6_Write_Error = -- | No data to write to file.
+                            BAM_V1_6_Write_Error_No_Data
+                          | -- | HOPT alignment optional field is not hex-formatted byte array.
+                            BAM_V1_6_Write_Error_HOPT_Incorrect_Format
+  deriving (Eq,Generic,Show,Typeable)
diff --git a/src/Data/BAM/Version1_6/Write/Internal.hs b/src/Data/BAM/Version1_6/Write/Internal.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/BAM/Version1_6/Write/Internal.hs
@@ -0,0 +1,68 @@
+-- |
+-- Module      :  Data.BAM.Version1_6.Write.Internal
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = WARNING
+--
+-- This module is considered __internal__.
+--
+-- The Package Versioning Policy __does not apply__.
+--
+-- The contents of this module may change __in any way whatsoever__
+-- and __without any warning__ between minor versions of this package.
+--
+-- Authors importing this library are expected to track development
+-- closely.
+--
+-- All credit goes to the author(s)/maintainer(s) of the
+-- [containers](https://hackage.haskell.org/package/containers) library
+-- for the above warning text.
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.BAM.Version1_6.Write.Internal ( -- * BAM_V1_6 writing - internal functions
+                                            encodeSeqField  
+                                          ) where
+
+import Data.ByteString as DB hiding (concatMap,length)
+import Data.Bits
+import Data.List       as DL
+import Data.Word
+
+-- | Encode a [Word8] (each byte represents two bases)
+-- into a ByteString representing the SEQ field.
+encodeSeqField :: [Word8]
+               -> DB.ByteString
+encodeSeqField bases =
+  DB.pack $
+    concatMap encodeByte pairs
+  where
+    pairs =
+      case ( odd $ DL.length bases
+           ) of
+        True  ->
+          pairsWithPadding bases
+        False ->
+          pairsWithoutPadding bases
+    encodeByte :: (Word8,Word8)
+               -> [Word8]
+    encodeByte (high,low) =
+      [ (high `shiftL` 4)
+        .|.
+        low
+      ]
+    pairsWithPadding :: [Word8]
+                     -> [(Word8,Word8)]
+    pairsWithPadding []       = []
+    pairsWithPadding [x]      = [(x,0)]
+    pairsWithPadding (x:y:xs) = (x,y) : pairsWithPadding xs
+    pairsWithoutPadding :: [Word8]
+                        -> [(Word8,Word8)]
+    pairsWithoutPadding []       = []
+    pairsWithoutPadding [_]      = []
+    pairsWithoutPadding (x:y:xs) = (x,y) : pairsWithoutPadding xs
diff --git a/src/Data/SAM/Version1_6/Alignment.hs b/src/Data/SAM/Version1_6/Alignment.hs
--- a/src/Data/SAM/Version1_6/Alignment.hs
+++ b/src/Data/SAM/Version1_6/Alignment.hs
@@ -5,7 +5,7 @@
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Alignment
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
diff --git a/src/Data/SAM/Version1_6/Alignment/AOPT.hs b/src/Data/SAM/Version1_6/Alignment/AOPT.hs
deleted file mode 100644
--- a/src/Data/SAM/Version1_6/Alignment/AOPT.hs
+++ /dev/null
@@ -1,68 +0,0 @@
-{-# LANGUAGE DeriveDataTypeable    #-}
-{-# LANGUAGE DeriveGeneric         #-}
-{-# LANGUAGE FlexibleContexts      #-}
-{-# LANGUAGE FlexibleInstances     #-}
-{-# LANGUAGE MultiParamTypeClasses #-}
-{-# LANGUAGE OverloadedStrings     #-}
-{-# LANGUAGE TypeFamilies          #-}
-
--- |
--- Module      :  Data.SAM.Version1_6.Alignment.AOPT
--- Copyright   :  (c) Matthew Mosior 2023
--- License     :  BSD-style
--- Maintainer  :  mattm.github@gmail.com
--- Portability :  portable
---
--- = WARNING
---
--- This module is considered __internal__.
---
--- The Package Versioning Policy __does not apply__.
---
--- The contents of this module may change __in any way whatsoever__
--- and __without any warning__ between minor versions of this package.
---
--- Authors importing this library are expected to track development
--- closely.
---
--- All credit goes to the author(s)/maintainer(s) of the
--- [containers](https://hackage.haskell.org/package/containers) library
--- for the above warning text.
---
--- = Description
---
--- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
-
-module Data.SAM.Version1_6.Alignment.AOPT ( -- * SAM version 1.6 alignment optional fields data type
-                                            SAM_V1_6_Alignment_AOPT(..)
-                                          ) where
-
-import Data.ByteString (ByteString)
-import Data.Data
-import Generics.Deriving.Base
-
-
--- | Custom SAM (version 1.6) @"SAM_V1_6_Alignment_AOPT"@ data type.
---
--- See section 1.5 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
-data SAM_V1_6_Alignment_AOPT = SAM_V1_6_Alignment_AOPT { sam_v1_6_alignment_aopt_tag   :: ByteString 
-                                                       , sam_v1_6_alignment_aopt_value :: ByteString
-                                                       }
-  deriving (Generic,Typeable)
-
-instance Eq SAM_V1_6_Alignment_AOPT where
-  SAM_V1_6_Alignment_AOPT sam_v1_6_alignment_aopt_tag1
-                          sam_v1_6_alignment_aopt_value1 == SAM_V1_6_Alignment_AOPT sam_v1_6_alignment_aopt_tag2
-                                                                                    sam_v1_6_alignment_aopt_value2 = sam_v1_6_alignment_aopt_tag1   == sam_v1_6_alignment_aopt_tag2     &&
-                                                                                                                     sam_v1_6_alignment_aopt_value1  == sam_v1_6_alignment_aopt_value2
-
-instance Show SAM_V1_6_Alignment_AOPT where
-  show (SAM_V1_6_Alignment_AOPT tag
-                                value
-       ) =
-    "SAM_V1_6_Alignment_AOPT { "          ++
-    "sam_v1_6_alignment_aopt_tag = "      ++
-    (show tag)                            ++
-    " , sam_v1_6_alignment_aopt_value = " ++
-    (show value)                          ++
-    " }"
diff --git a/src/Data/SAM/Version1_6/Alignment/BOPT.hs b/src/Data/SAM/Version1_6/Alignment/BOPT.hs
deleted file mode 100644
--- a/src/Data/SAM/Version1_6/Alignment/BOPT.hs
+++ /dev/null
@@ -1,294 +0,0 @@
-{-# LANGUAGE DeriveDataTypeable    #-}
-{-# LANGUAGE DeriveGeneric         #-}
-{-# LANGUAGE FlexibleContexts      #-}
-{-# LANGUAGE FlexibleInstances     #-}
-{-# LANGUAGE MultiParamTypeClasses #-}
-{-# LANGUAGE OverloadedStrings     #-}
-{-# LANGUAGE TypeFamilies          #-}
-
--- |
--- Module      :  Data.SAM.Version1_6.Alignment.BOPT
--- Copyright   :  (c) Matthew Mosior 2023
--- License     :  BSD-style
--- Maintainer  :  mattm.github@gmail.com
--- Portability :  portable
---
--- = WARNING
---
--- This module is considered __internal__.
---
--- The Package Versioning Policy __does not apply__.
---
--- The contents of this module may change __in any way whatsoever__
--- and __without any warning__ between minor versions of this package.
---
--- Authors importing this library are expected to track development
--- closely.
---
--- All credit goes to the author(s)/maintainer(s) of the
--- [containers](https://hackage.haskell.org/package/containers) library
--- for the above warning text.
---
--- = Description
---
--- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
-
-module Data.SAM.Version1_6.Alignment.BOPT ( -- * SAM version 1.6 alignment optional fields data type
-                                            SAM_V1_6_Alignment_BOPT(..),
-                                            SAM_V1_6_Alignment_BOPT_Int8(..),
-                                            SAM_V1_6_Alignment_BOPT_Word8(..),
-                                            SAM_V1_6_Alignment_BOPT_Int16(..),
-                                            SAM_V1_6_Alignment_BOPT_Word16(..),
-                                            SAM_V1_6_Alignment_BOPT_Int32(..),
-                                            SAM_V1_6_Alignment_BOPT_Word32(..),
-                                            SAM_V1_6_Alignment_BOPT_Float(..)
-                                          ) where
-
-import Data.Data
-import Data.Int
-import Data.Sequence
-import Data.Word
-import Generics.Deriving.Base
-
-
--- | Custom SAM (version 1.6) @"SAM_V1_6_Alignment_BOPT"@ data type.
---
--- See section 1.5 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
-data SAM_V1_6_Alignment_BOPT = SAM_V1_6_Alignment_BOPT { sam_v1_6_alignment_bopt_int8   :: Maybe SAM_V1_6_Alignment_BOPT_Int8
-                                                       , sam_v1_6_alignment_bopt_word8  :: Maybe SAM_V1_6_Alignment_BOPT_Word8
-                                                       , sam_v1_6_alignment_bopt_int16  :: Maybe SAM_V1_6_Alignment_BOPT_Int16
-                                                       , sam_v1_6_alignment_bopt_word16 :: Maybe SAM_V1_6_Alignment_BOPT_Word16
-                                                       , sam_v1_6_alignment_bopt_int32  :: Maybe SAM_V1_6_Alignment_BOPT_Int32
-                                                       , sam_v1_6_alignment_bopt_word32 :: Maybe SAM_V1_6_Alignment_BOPT_Word32
-                                                       , sam_v1_6_alignment_bopt_float  :: Maybe SAM_V1_6_Alignment_BOPT_Float
-                                                       }
-  deriving (Generic,Typeable)
-
-instance Eq SAM_V1_6_Alignment_BOPT where
-  SAM_V1_6_Alignment_BOPT sam_v1_6_alignment_bopt_int81
-                          sam_v1_6_alignment_bopt_word81
-                          sam_v1_6_alignment_bopt_int161
-                          sam_v1_6_alignment_bopt_word161
-                          sam_v1_6_alignment_bopt_int321
-                          sam_v1_6_alignment_bopt_word321
-                          sam_v1_6_alignment_bopt_float1 == SAM_V1_6_Alignment_BOPT sam_v1_6_alignment_bopt_int82
-                                                                                    sam_v1_6_alignment_bopt_word82
-                                                                                    sam_v1_6_alignment_bopt_int162
-                                                                                    sam_v1_6_alignment_bopt_word162
-                                                                                    sam_v1_6_alignment_bopt_int322
-                                                                                    sam_v1_6_alignment_bopt_word322
-                                                                                    sam_v1_6_alignment_bopt_float2 = sam_v1_6_alignment_bopt_int81   == sam_v1_6_alignment_bopt_int82   &&
-                                                                                                                     sam_v1_6_alignment_bopt_word81  == sam_v1_6_alignment_bopt_word82  &&
-                                                                                                                     sam_v1_6_alignment_bopt_int161  == sam_v1_6_alignment_bopt_int162  &&
-                                                                                                                     sam_v1_6_alignment_bopt_word161 == sam_v1_6_alignment_bopt_word162 &&
-                                                                                                                     sam_v1_6_alignment_bopt_int321  == sam_v1_6_alignment_bopt_int322  &&
-                                                                                                                     sam_v1_6_alignment_bopt_word321 == sam_v1_6_alignment_bopt_word322 &&
-                                                                                                                     sam_v1_6_alignment_bopt_float1  == sam_v1_6_alignment_bopt_float2
-
-instance Show SAM_V1_6_Alignment_BOPT where
-  show (SAM_V1_6_Alignment_BOPT int8
-                                word8
-                                int16
-                                word16
-                                int32
-                                word32
-                                float
-       ) =
-    "SAM_V1_6_Alignment_BOPT { "           ++
-    "sam_v1_6_alignment_bopt_int8 = "      ++
-    (show int8)                            ++
-    " , sam_v1_6_alignment_bopt_word8 = "  ++
-    (show word8)                           ++
-    " , sam_v1_6_alignment_bopt_int16 = "  ++
-    (show int16)                           ++
-    " , sam_v1_6_alignment_bopt_word16 = " ++
-    (show word16)                          ++
-    " , sam_v1_6_alignment_bopt_int32 = "  ++
-    (show int32)                           ++
-    " , sam_v1_6_alignment_bopt_word32 = " ++
-    (show word32)                          ++
-    " , sam_v1_6_alignment_bopt_float = "  ++
-    (show float)                           ++
-    " }"
-
--- | __c__CsSiIf of the last optional field (type B).
---
--- See section 1.5 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
-data SAM_V1_6_Alignment_BOPT_Int8 = SAM_V1_6_Alignment_BOPT_Int8 { sam_v1_6_alignment_bopt_int8_tag   :: Seq Word8
-                                                                 , sam_v1_6_alignment_bopt_int8_type  :: Word8
-                                                                 , sam_v1_6_alignment_bopt_int8_value :: Seq Int8
-                                                                 }
-  deriving (Generic,Typeable)
-
-instance Eq SAM_V1_6_Alignment_BOPT_Int8 where
-  SAM_V1_6_Alignment_BOPT_Int8 sam_v1_6_alignment_bopt_int8_tag1 sam_v1_6_alignment_bopt_int8_type1 sam_v1_6_alignment_bopt_int8_value1 == SAM_V1_6_Alignment_BOPT_Int8 sam_v1_6_alignment_bopt_int8_tag2 sam_v1_6_alignment_bopt_int8_type2 sam_v1_6_alignment_bopt_int8_value2 = sam_v1_6_alignment_bopt_int8_tag1 == sam_v1_6_alignment_bopt_int8_tag2 && sam_v1_6_alignment_bopt_int8_type1 == sam_v1_6_alignment_bopt_int8_type2 && sam_v1_6_alignment_bopt_int8_value1 == sam_v1_6_alignment_bopt_int8_value2
-
-instance Show SAM_V1_6_Alignment_BOPT_Int8 where
-  show (SAM_V1_6_Alignment_BOPT_Int8 tag
-                                     bopttype
-                                     value
-       ) =
-    "SAM_V1_6_Alignment_BOPT_Int8 { "          ++
-    "sam_v1_6_alignment_bopt_int8_tag  = "     ++
-    (show tag)                                 ++
-    " , sam_v1_6_alignment_bopt_int8_type = "  ++
-    (show bopttype)                            ++
-    " , sam_v1_6_alignment_bopt_int8_value = " ++
-    (show value)                               ++
-    " }"
-
--- | c__C__sSiIf of the last optional field (type B).
---
--- See section 1.5 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
-data SAM_V1_6_Alignment_BOPT_Word8 = SAM_V1_6_Alignment_BOPT_Word8 { sam_v1_6_alignment_bopt_word8_tag   :: Seq Word8
-                                                                   , sam_v1_6_alignment_bopt_word8_type  :: Word8
-                                                                   , sam_v1_6_alignment_bopt_word8_value :: Seq Word8
-                                                                   }
-  deriving (Generic,Typeable)
-
-instance Eq SAM_V1_6_Alignment_BOPT_Word8 where
-  SAM_V1_6_Alignment_BOPT_Word8 sam_v1_6_alignment_bopt_word8_tag1 sam_v1_6_alignment_bopt_word8_type1 sam_v1_6_alignment_bopt_word8_value1 == SAM_V1_6_Alignment_BOPT_Word8 sam_v1_6_alignment_bopt_word8_tag2 sam_v1_6_alignment_bopt_word8_type2 sam_v1_6_alignment_bopt_word8_value2 = sam_v1_6_alignment_bopt_word8_tag1 == sam_v1_6_alignment_bopt_word8_tag2 && sam_v1_6_alignment_bopt_word8_type1 == sam_v1_6_alignment_bopt_word8_type2 && sam_v1_6_alignment_bopt_word8_value1 == sam_v1_6_alignment_bopt_word8_value2
-
-instance Show SAM_V1_6_Alignment_BOPT_Word8 where
-  show (SAM_V1_6_Alignment_BOPT_Word8 tag
-                                      bopttype
-                                      value
-       ) =
-    "SAM_V1_6_Alignment_BOPT_Word8 { "          ++
-    "sam_v1_6_alignment_bopt_word8_tag  = "     ++
-    (show tag)                                  ++
-    " , sam_v1_6_alignment_bopt_word8_type = "  ++
-    (show bopttype)                             ++
-    " , sam_v1_6_alignment_bopt_word8_value = " ++
-    (show value)                                ++
-    " }"
-
--- | cC__s__SiIf of the last optional field (type B).
---
--- See section 1.5 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
-data SAM_V1_6_Alignment_BOPT_Int16 = SAM_V1_6_Alignment_BOPT_Int16 { sam_v1_6_alignment_bopt_int16_tag   :: Seq Word8
-                                                                   , sam_v1_6_alignment_bopt_int16_type  :: Word8
-                                                                   , sam_v1_6_alignment_bopt_int16_value :: Seq Int16
-                                                                   }
-  deriving (Generic,Typeable)
-
-instance Eq SAM_V1_6_Alignment_BOPT_Int16 where
-  SAM_V1_6_Alignment_BOPT_Int16 sam_v1_6_alignment_bopt_int16_tag1 sam_v1_6_alignment_bopt_int16_type1 sam_v1_6_alignment_bopt_int16_value1 == SAM_V1_6_Alignment_BOPT_Int16 sam_v1_6_alignment_bopt_int16_tag2 sam_v1_6_alignment_bopt_int16_type2 sam_v1_6_alignment_bopt_int16_value2 = sam_v1_6_alignment_bopt_int16_tag1 == sam_v1_6_alignment_bopt_int16_tag2 && sam_v1_6_alignment_bopt_int16_type1 == sam_v1_6_alignment_bopt_int16_type2 && sam_v1_6_alignment_bopt_int16_value1 == sam_v1_6_alignment_bopt_int16_value2
-
-instance Show SAM_V1_6_Alignment_BOPT_Int16 where
-  show (SAM_V1_6_Alignment_BOPT_Int16 tag
-                                      bopttype
-                                      value
-       ) =
-    "SAM_V1_6_Alignment_BOPT_Int16 { "          ++
-    "sam_v1_6_alignment_bopt_int16_tag  = "     ++
-    (show tag)                                  ++
-    " , sam_v1_6_alignment_bopt_int16_type = "  ++
-    (show bopttype)                             ++
-    " , sam_v1_6_alignment_bopt_int16_value = " ++
-    (show value)                                ++
-    " }"
-
--- | cCs__S__iIf of the last optional field (type B).
---
--- See section 1.5 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
-data SAM_V1_6_Alignment_BOPT_Word16 = SAM_V1_6_Alignment_BOPT_Word16 { sam_v1_6_alignment_bopt_word16_tag   :: Seq Word8
-                                                                     , sam_v1_6_alignment_bopt_word16_type  :: Word8
-                                                                     , sam_v1_6_alignment_bopt_word16_value :: Seq Word16
-                                                                     }
-  deriving (Generic,Typeable)
-
-instance Eq SAM_V1_6_Alignment_BOPT_Word16 where
-  SAM_V1_6_Alignment_BOPT_Word16 sam_v1_6_alignment_bopt_word16_tag1 sam_v1_6_alignment_bopt_word16_type1 sam_v1_6_alignment_bopt_word16_value1 == SAM_V1_6_Alignment_BOPT_Word16 sam_v1_6_alignment_bopt_word16_tag2 sam_v1_6_alignment_bopt_word16_type2 sam_v1_6_alignment_bopt_word16_value2 = sam_v1_6_alignment_bopt_word16_tag1 == sam_v1_6_alignment_bopt_word16_tag2 && sam_v1_6_alignment_bopt_word16_type1 == sam_v1_6_alignment_bopt_word16_type2 && sam_v1_6_alignment_bopt_word16_value1 == sam_v1_6_alignment_bopt_word16_value2
-
-instance Show SAM_V1_6_Alignment_BOPT_Word16 where
-  show (SAM_V1_6_Alignment_BOPT_Word16 tag
-                                       bopttype
-                                       value
-       ) =
-    "SAM_V1_6_Alignment_BOPT_Word16 { "          ++
-    "sam_v1_6_alignment_bopt_word16_tag  = "     ++
-    (show tag)                                   ++
-    " , sam_v1_6_alignment_bopt_word16_type = "  ++
-    (show bopttype)                              ++
-    " , sam_v1_6_alignment_bopt_word16_value = " ++
-    (show value)                                 ++
-    " }"
-
--- | cCsS__i__If of the last optional field (type B).
---
--- See section 1.5 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
-data SAM_V1_6_Alignment_BOPT_Int32 = SAM_V1_6_Alignment_BOPT_Int32 { sam_v1_6_alignment_bopt_int32_tag   :: Seq Word8
-                                                                   , sam_v1_6_alignment_bopt_int32_type  :: Word8
-                                                                   , sam_v1_6_alignment_bopt_int32_value :: Seq Int32
-                                                                   }
-  deriving (Generic,Typeable)
-
-instance Eq SAM_V1_6_Alignment_BOPT_Int32 where
-  SAM_V1_6_Alignment_BOPT_Int32 sam_v1_6_alignment_bopt_int32_tag1 sam_v1_6_alignment_bopt_int32_type1 sam_v1_6_alignment_bopt_int32_value1 == SAM_V1_6_Alignment_BOPT_Int32 sam_v1_6_alignment_bopt_int32_tag2 sam_v1_6_alignment_bopt_int32_type2 sam_v1_6_alignment_bopt_int32_value2 = sam_v1_6_alignment_bopt_int32_tag1 == sam_v1_6_alignment_bopt_int32_tag2 && sam_v1_6_alignment_bopt_int32_type1 == sam_v1_6_alignment_bopt_int32_type2 && sam_v1_6_alignment_bopt_int32_value1 == sam_v1_6_alignment_bopt_int32_value2
-
-instance Show SAM_V1_6_Alignment_BOPT_Int32 where
-  show (SAM_V1_6_Alignment_BOPT_Int32 tag
-                                      bopttype
-                                      value
-       ) =
-    "SAM_V1_6_Alignment_BOPT_Int32 { "          ++
-    "sam_v1_6_alignment_bopt_int32_tag  = "     ++
-    (show tag)                                  ++
-    " , sam_v1_6_alignment_bopt_int32_type = "  ++
-    (show bopttype)                             ++
-    " , sam_v1_6_alignment_bopt_int32_value = " ++
-    (show value)                                ++
-    " }"
-
--- | cCsSi__I__f of the last optional field (type B).
---
--- See section 1.5 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
-data SAM_V1_6_Alignment_BOPT_Word32 = SAM_V1_6_Alignment_BOPT_Word32 { sam_v1_6_alignment_bopt_word32_tag   :: Seq Word8
-                                                                     , sam_v1_6_alignment_bopt_word32_type  :: Word8
-                                                                     , sam_v1_6_alignment_bopt_word32_value :: Seq Word32
-                                                                     }
-  deriving (Generic,Typeable)
-
-instance Eq SAM_V1_6_Alignment_BOPT_Word32 where
-  SAM_V1_6_Alignment_BOPT_Word32 sam_v1_6_alignment_bopt_word32_tag1 sam_v1_6_alignment_bopt_word32_type1 sam_v1_6_alignment_bopt_word32_value1 == SAM_V1_6_Alignment_BOPT_Word32 sam_v1_6_alignment_bopt_word32_tag2 sam_v1_6_alignment_bopt_word32_type2 sam_v1_6_alignment_bopt_word32_value2 = sam_v1_6_alignment_bopt_word32_tag1 == sam_v1_6_alignment_bopt_word32_tag2 && sam_v1_6_alignment_bopt_word32_type1 == sam_v1_6_alignment_bopt_word32_type2 && sam_v1_6_alignment_bopt_word32_value1 == sam_v1_6_alignment_bopt_word32_value2
-
-instance Show SAM_V1_6_Alignment_BOPT_Word32 where
-  show (SAM_V1_6_Alignment_BOPT_Word32 tag
-                                       bopttype
-                                       value
-       ) =
-    "SAM_V1_6_Alignment_BOPT_Word32 { "          ++
-    "sam_v1_6_alignment_bopt_word32_tag  = "     ++
-    (show tag)                                   ++
-    " , sam_v1_6_alignment_bopt_word32_type = "  ++
-    (show bopttype)                              ++
-    " , sam_v1_6_alignment_bopt_word32_value = " ++
-    (show value)                                 ++
-    " }"
-
--- | cCsSiI__f__ of the last optional field (type B).
---
--- See section 1.5 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
-data SAM_V1_6_Alignment_BOPT_Float = SAM_V1_6_Alignment_BOPT_Float { sam_v1_6_alignment_bopt_float_tag   :: Seq Word8
-                                                                   , sam_v1_6_alignment_bopt_float_type  :: Word8
-                                                                   , sam_v1_6_alignment_bopt_float_value :: Seq Float
-                                                                   }
-  deriving (Generic,Typeable)
-
-instance Eq SAM_V1_6_Alignment_BOPT_Float where
-  SAM_V1_6_Alignment_BOPT_Float sam_v1_6_alignment_bopt_float_tag1 sam_v1_6_alignment_bopt_float_type1 sam_v1_6_alignment_bopt_float_value1 == SAM_V1_6_Alignment_BOPT_Float sam_v1_6_alignment_bopt_float_tag2 sam_v1_6_alignment_bopt_float_type2 sam_v1_6_alignment_bopt_float_value2 = sam_v1_6_alignment_bopt_float_tag1 == sam_v1_6_alignment_bopt_float_tag2 && sam_v1_6_alignment_bopt_float_type1 == sam_v1_6_alignment_bopt_float_type2 && sam_v1_6_alignment_bopt_float_value1 == sam_v1_6_alignment_bopt_float_value2
-
-instance Show SAM_V1_6_Alignment_BOPT_Float where
-  show (SAM_V1_6_Alignment_BOPT_Float tag
-                                      bopttype
-                                      value
-       ) =
-    "SAM_V1_6_Alignment_BOPT_Float { "          ++
-    "sam_v1_6_alignment_bopt_float_tag  = "     ++
-    (show tag)                                  ++
-    " , sam_v1_6_alignment_bopt_float_type = "  ++
-    (show bopttype)                             ++
-    " , sam_v1_6_alignment_bopt_float_value = " ++
-    (show value)                                ++
-    " }"
diff --git a/src/Data/SAM/Version1_6/Alignment/Base.hs b/src/Data/SAM/Version1_6/Alignment/Base.hs
--- a/src/Data/SAM/Version1_6/Alignment/Base.hs
+++ b/src/Data/SAM/Version1_6/Alignment/Base.hs
@@ -4,12 +4,13 @@
 {-# LANGUAGE FlexibleInstances           #-}
 {-# LANGUAGE MultiParamTypeClasses       #-}
 {-# LANGUAGE OverloadedStrings           #-}
+{-# LANGUAGE StrictData                  #-}
 {-# LANGUAGE TypeFamilies                #-}
 {-# OPTIONS_GHC -fno-warn-name-shadowing #-}
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Alignment.Base
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -22,92 +23,83 @@
                                             SAM_V1_6_Alignment(..)
                                           ) where
 
-import Data.SAM.Version1_6.Alignment.AOPT
-import Data.SAM.Version1_6.Alignment.IOPT
-import Data.SAM.Version1_6.Alignment.FOPT
-import Data.SAM.Version1_6.Alignment.ZOPT
-import Data.SAM.Version1_6.Alignment.HOPT
-import Data.SAM.Version1_6.Alignment.BOPT
+import Data.SAM.Version1_6.Alignment.OptionalFields.Base
 
 import Data.ByteString
 import Data.Data
+import Data.Sequence
 import Generics.Deriving.Base
 
 -- | Custom SAM (version 1.6) @"SAM_V1_6_Alignment"@ data type.
 --
 -- See section 1.4 and 1.5 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
-data SAM_V1_6_Alignment = SAM_V1_6_Alignment { sam_v1_6_alignment_qname :: ByteString                    -- ^ Query template NAME.
-                                                                                                         -- reads/segments having identical QNAME are regarded to come from
-                                                                                                         -- the same template. A QNAME ‘*’ indicates the information
-                                                                                                         -- is unavailable. In a SAM file, a read may
-                                                                                                         -- occupy multiple alignment lines, when its alignment is chimeric
-                                                                                                         -- or when multiple mappings are given.
-                                             , sam_v1_6_alignment_flag  :: Int                           -- ^ Combination of bitwise FLAGs.
-                                             , sam_v1_6_alignment_rname :: ByteString                    -- ^ Reference sequence NAME of the alignment.
-                                                                                                         -- If @SQ header lines are present, RNAME (if not
-                                                                                                         -- ‘*’) must be present in one of the SQ-SN tag.
-                                                                                                         -- An unmapped segment without coordinate has a ‘*’ at
-                                                                                                         -- this field. However, an unmapped segment may also have
-                                                                                                         -- an ordinary coordinate such that it can be
-                                                                                                         -- placed at a desired position after sorting.
-                                                                                                         -- If RNAME is ‘*’, no assumptions can be made about POS
-                                                                                                         -- and CIGAR.
-                                             , sam_v1_6_alignment_pos   :: Integer                       -- ^ 1-based leftmost mapping POSition of the first CIGAR
-                                                                                                         -- operation that “consumes” a reference
-                                                                                                         -- base. The first base in a reference sequence has coordinate 1.
-                                                                                                         -- POS is set as 0 for an unmapped read without coordinate.
-                                                                                                         -- If POS is 0, no assumptions can be made about RNAME and CIGAR.
-                                             , sam_v1_6_alignment_mapq  :: Int                           -- ^ MAPping Quality. It equals −10 log10 Pr{mapping position is wrong},
-                                                                                                         -- rounded to the nearest integer. A value 255 indicates that the
-                                                                                                         -- mapping quality is not available.
-                                             , sam_v1_6_alignment_cigar :: ByteString                    -- ^ CIGAR string (set ‘*’ if unavailable).
-                                             , sam_v1_6_alignment_rnext :: ByteString                    -- ^ Reference sequence name of the primary alignment of the
-                                                                                                         -- NEXT read in the template. For the last read, the next read
-                                                                                                         -- is the first read in the template. If @SQ header lines are present,
-                                                                                                         -- RNEXT (if not ‘*’ or ‘=’) must be present in one of the SQ-SN tag.
-                                                                                                         -- This field is set as ‘*’ when the information is unavailable,
-                                                                                                         -- and set as ‘=’ if RNEXT is identical RNAME. If not ‘=’ and the next
-                                                                                                         -- read in the template has one primary mapping (see also bit 0x100 in FLAG),
-                                                                                                         -- this field is identical to RNAME at the primary line of the next read.
-                                                                                                         -- If RNEXT is ‘*’, no assumptions can be made on PNEXT and bit 0x20.
-                                             , sam_v1_6_alignment_pnext :: Integer                       -- ^ 1-based Position of the primary alignment of the NEXT read in
-                                                                                                         -- the template. Set as 0 when the information is unavailable.
-                                                                                                         -- This field equals POS at the primary line of the next read.
-                                                                                                         -- If PNEXT is 0, no assumptions can be made on RNEXT and bit 0x20.
-                                             , sam_v1_6_alignment_tlen  :: Integer                       -- ^ signed observed Template LENgth. For primary reads where the primary
-                                                                                                         -- alignments of all reads in the template are mapped to the same reference
-                                                                                                         -- sequence, the absolute value of TLEN equals the distance between the
-                                                                                                         -- mapped end of the template and the mapped start of the template,
-                                                                                                         -- inclusively (i.e., end − start + 1).
-                                                                                                         -- Note that mapped base is defined to be one that aligns to the
-                                                                                                         -- reference as described by CIGAR, hence excludes soft-clipped bases.
-                                                                                                         -- The TLEN field is positive for the leftmost segment of the template,
-                                                                                                         -- negative for the rightmost, and the sign for any middle segment is undefined.
-                                                                                                         -- If segments cover the same coordinates then the choice of which is leftmost
-                                                                                                         -- and rightmost is arbitrary, but the two ends must still have differing signs.
-                                                                                                         -- It is set as 0 for a single-segment template or when the information
-                                                                                                         -- is unavailable (e.g., when the first or last segment of a multi-segment
-                                                                                                         -- template is unmapped or when the two are mapped to
-                                                                                                         -- different reference sequences).
-                                             , sam_v1_6_alignment_seq   :: ByteString                    -- ^ segment SEQuence. This field can be a ‘*’ when the sequence
-                                                                                                         -- is not stored. If not a ‘*’, the length of the sequence must
-                                                                                                         -- equal the sum of lengths of M/I/S/=/X operations in CIGAR.
-                                                                                                         -- An ‘=’ denotes the base is identical to the reference base.
-                                                                                                         -- No assumptions can be made on the letter cases.
-                                             , sam_v1_6_alignment_qual  :: ByteString                    -- ^ ASCII of base QUALity plus 33 (same as the quality string
-                                                                                                         -- in the Sanger FASTQ format). A base quality is the phred-scaled
-                                                                                                         -- base error probability which equals −10 log10 Pr{base is wrong}.
-                                                                                                         -- This field can be a ‘*’ when quality is not stored.
-                                                                                                         -- If not a ‘*’, SEQ must not be a ‘*’ and the length of the quality
-                                                                                                         -- string ought to equal the length of SEQ.
-                                             , sam_v1_6_alignment_aopt  :: Maybe SAM_V1_6_Alignment_AOPT -- ^ A - [!-~] - Printable characters.
-                                             , sam_v1_6_alignment_iopt  :: Maybe SAM_V1_6_Alignment_IOPT -- ^ i - [-+]?[0-9]+ - Signed integer.
-                                             , sam_v1_6_alignment_fopt  :: Maybe SAM_V1_6_Alignment_FOPT -- ^ f - [-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)? - Single-precision floating number.
-                                             , sam_v1_6_alignment_zopt  :: Maybe SAM_V1_6_Alignment_ZOPT -- ^ Z - [ !-~]* - Printable string, including space.
-                                             , sam_v1_6_alignment_hopt  :: Maybe SAM_V1_6_Alignment_HOPT -- ^ H - ([0-9A-F][0-9A-F])* - Byte array in the Hex format.
-                                             , sam_v1_6_alignment_bopt  :: Maybe SAM_V1_6_Alignment_BOPT -- ^ B - [cCsSiIf]&#8203;(,[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)* - Integer or numeric array.
-                                             }
-  deriving (Generic,Typeable)
+data SAM_V1_6_Alignment = SAM_V1_6_Alignment
+  { sam_v1_6_alignment_qname          :: ByteString                                    -- ^ Query template NAME.
+                                                                                       -- reads/segments having identical QNAME are regarded to come from
+                                                                                       -- the same template. A QNAME ‘*’ indicates the information
+                                                                                       -- is unavailable. In a SAM file, a read may
+                                                                                       -- occupy multiple alignment lines, when its alignment is chimeric
+                                                                                       -- or when multiple mappings are given.
+  , sam_v1_6_alignment_flag           :: Int                                           -- ^ Combination of bitwise FLAGs.
+  , sam_v1_6_alignment_rname          :: ByteString                                    -- ^ Reference sequence NAME of the alignment.
+                                                                                       -- If @SQ header lines are present, RNAME (if not
+                                                                                       -- ‘*’) must be present in one of the SQ-SN tag.
+                                                                                       -- An unmapped segment without coordinate has a ‘*’ at
+                                                                                       -- this field. However, an unmapped segment may also have
+                                                                                       -- an ordinary coordinate such that it can be
+                                                                                       -- placed at a desired position after sorting.
+                                                                                       -- If RNAME is ‘*’, no assumptions can be made about POS
+                                                                                       -- and CIGAR.
+  , sam_v1_6_alignment_pos            :: Integer                                       -- ^ 1-based leftmost mapping POSition of the first CIGAR
+                                                                                       -- operation that “consumes” a reference
+                                                                                       -- base. The first base in a reference sequence has coordinate 1.
+                                                                                       -- POS is set as 0 for an unmapped read without coordinate.
+                                                                                       -- If POS is 0, no assumptions can be made about RNAME and CIGAR.
+  , sam_v1_6_alignment_mapq           :: Int                                           -- ^ MAPping Quality. It equals −10 log10 Pr{mapping position is wrong},
+                                                                                       -- rounded to the nearest integer. A value 255 indicates that the
+                                                                                       -- mapping quality is not available.
+  , sam_v1_6_alignment_cigar          :: ByteString                                    -- ^ CIGAR string (set ‘*’ if unavailable).
+  , sam_v1_6_alignment_rnext          :: ByteString                                    -- ^ Reference sequence name of the primary alignment of the
+                                                                                       -- NEXT read in the template. For the last read, the next read
+                                                                                       -- is the first read in the template. If @SQ header lines are present,
+                                                                                       -- RNEXT (if not ‘*’ or ‘=’) must be present in one of the SQ-SN tag.
+                                                                                       -- This field is set as ‘*’ when the information is unavailable,
+                                                                                       -- and set as ‘=’ if RNEXT is identical RNAME. If not ‘=’ and the next
+                                                                                       -- read in the template has one primary mapping (see also bit 0x100 in FLAG),
+                                                                                       -- this field is identical to RNAME at the primary line of the next read.
+                                                                                       -- If RNEXT is ‘*’, no assumptions can be made on PNEXT and bit 0x20.
+  , sam_v1_6_alignment_pnext          :: Integer                                       -- ^ 1-based Position of the primary alignment of the NEXT read in
+                                                                                       -- the template. Set as 0 when the information is unavailable.
+                                                                                       -- This field equals POS at the primary line of the next read.
+                                                                                       -- If PNEXT is 0, no assumptions can be made on RNEXT and bit 0x20.
+  , sam_v1_6_alignment_tlen           :: Integer                                       -- ^ signed observed Template LENgth. For primary reads where the primary
+                                                                                       -- alignments of all reads in the template are mapped to the same reference
+                                                                                       -- sequence, the absolute value of TLEN equals the distance between the
+                                                                                       -- mapped end of the template and the mapped start of the template,
+                                                                                       -- inclusively (i.e., end − start + 1).
+                                                                                       -- Note that mapped base is defined to be one that aligns to the
+                                                                                       -- reference as described by CIGAR, hence excludes soft-clipped bases.
+                                                                                       -- The TLEN field is positive for the leftmost segment of the template,
+                                                                                       -- negative for the rightmost, and the sign for any middle segment is undefined.
+                                                                                       -- If segments cover the same coordinates then the choice of which is leftmost
+                                                                                       -- and rightmost is arbitrary, but the two ends must still have differing signs.
+                                                                                       -- It is set as 0 for a single-segment template or when the information
+                                                                                       -- is unavailable (e.g., when the first or last segment of a multi-segment
+                                                                                       -- template is unmapped or when the two are mapped to
+                                                                                       -- different reference sequences).
+  , sam_v1_6_alignment_seq            :: ByteString                                    -- ^ segment SEQuence. This field can be a ‘*’ when the sequence
+                                                                                       -- is not stored. If not a ‘*’, the length of the sequence must
+                                                                                       -- equal the sum of lengths of M/I/S/=/X operations in CIGAR.
+                                                                                       -- An ‘=’ denotes the base is identical to the reference base.
+                                                                                       -- No assumptions can be made on the letter cases.
+  , sam_v1_6_alignment_qual           :: ByteString                                    -- ^ ASCII of base QUALity plus 33 (same as the quality string
+                                                                                       -- in the Sanger FASTQ format). A base quality is the phred-scaled
+                                                                                       -- base error probability which equals −10 log10 Pr{base is wrong}.
+                                                                                       -- This field can be a ‘*’ when quality is not stored.
+                                                                                       -- If not a ‘*’, SEQ must not be a ‘*’ and the length of the quality
+                                                                                       -- string ought to equal the length of SEQ.
+  , sam_v1_6_alignment_optionalfields :: Maybe (Seq SAM_V1_6_Alignment_OptionalFields) -- ^ Optional fields.
+  } deriving (Generic,Typeable)
 
 instance Eq SAM_V1_6_Alignment where
   SAM_V1_6_Alignment sam_v1_6_alignment_qname1
@@ -121,80 +113,69 @@
                      sam_v1_6_alignment_tlen1
                      sam_v1_6_alignment_seq1
                      sam_v1_6_alignment_qual1
-                     sam_v1_6_alignment_aopt1
-                     sam_v1_6_alignment_iopt1
-                     sam_v1_6_alignment_fopt1
-                     sam_v1_6_alignment_zopt1
-                     sam_v1_6_alignment_hopt1
-                     sam_v1_6_alignment_bopt1 == SAM_V1_6_Alignment sam_v1_6_alignment_qname2
-                                                                    sam_v1_6_alignment_flag2
-                                                                    sam_v1_6_alignment_rname2
-                                                                    sam_v1_6_alignment_pos2
-                                                                    sam_v1_6_alignment_mapq2
-                                                                    sam_v1_6_alignment_cigar2
-                                                                    sam_v1_6_alignment_rnext2
-                                                                    sam_v1_6_alignment_pnext2
-                                                                    sam_v1_6_alignment_tlen2
-                                                                    sam_v1_6_alignment_seq2
-                                                                    sam_v1_6_alignment_qual2
-                                                                    sam_v1_6_alignment_aopt2
-                                                                    sam_v1_6_alignment_iopt2
-                                                                    sam_v1_6_alignment_fopt2
-                                                                    sam_v1_6_alignment_zopt2
-                                                                    sam_v1_6_alignment_hopt2
-                                                                    sam_v1_6_alignment_bopt2 = sam_v1_6_alignment_qname1 == sam_v1_6_alignment_qname2 &&  
-                                                                                               sam_v1_6_alignment_flag1  == sam_v1_6_alignment_flag2  &&
-                                                                                               sam_v1_6_alignment_rname1 == sam_v1_6_alignment_rname2 &&
-                                                                                               sam_v1_6_alignment_pos1   == sam_v1_6_alignment_pos2   &&
-                                                                                               sam_v1_6_alignment_mapq1  == sam_v1_6_alignment_mapq2  &&
-                                                                                               sam_v1_6_alignment_cigar1 == sam_v1_6_alignment_cigar2 &&
-                                                                                               sam_v1_6_alignment_rnext1 == sam_v1_6_alignment_rnext2 &&
-                                                                                               sam_v1_6_alignment_pnext1 == sam_v1_6_alignment_pnext2 &&
-                                                                                               sam_v1_6_alignment_tlen1  == sam_v1_6_alignment_tlen2  &&
-                                                                                               sam_v1_6_alignment_seq1   == sam_v1_6_alignment_seq2   &&
-                                                                                               sam_v1_6_alignment_qual1  == sam_v1_6_alignment_qual2  &&
-                                                                                               sam_v1_6_alignment_aopt1  == sam_v1_6_alignment_aopt2  &&
-                                                                                               sam_v1_6_alignment_iopt1  == sam_v1_6_alignment_iopt2  &&
-                                                                                               sam_v1_6_alignment_fopt1  == sam_v1_6_alignment_fopt2  &&
-                                                                                               sam_v1_6_alignment_zopt1  == sam_v1_6_alignment_zopt2  &&
-                                                                                               sam_v1_6_alignment_hopt1  == sam_v1_6_alignment_hopt2  &&
-                                                                                               sam_v1_6_alignment_bopt1  == sam_v1_6_alignment_bopt2
+                     sam_v1_6_alignment_optfields1 ==
+    SAM_V1_6_Alignment sam_v1_6_alignment_qname2
+                       sam_v1_6_alignment_flag2
+                       sam_v1_6_alignment_rname2
+                       sam_v1_6_alignment_pos2
+                       sam_v1_6_alignment_mapq2
+                       sam_v1_6_alignment_cigar2
+                       sam_v1_6_alignment_rnext2
+                       sam_v1_6_alignment_pnext2
+                       sam_v1_6_alignment_tlen2
+                       sam_v1_6_alignment_seq2
+                       sam_v1_6_alignment_qual2
+                       sam_v1_6_alignment_optfields2 =
+      sam_v1_6_alignment_qname1     == sam_v1_6_alignment_qname2 &&  
+      sam_v1_6_alignment_flag1      == sam_v1_6_alignment_flag2  &&
+      sam_v1_6_alignment_rname1     == sam_v1_6_alignment_rname2 &&
+      sam_v1_6_alignment_pos1       == sam_v1_6_alignment_pos2   &&
+      sam_v1_6_alignment_mapq1      == sam_v1_6_alignment_mapq2  &&
+      sam_v1_6_alignment_cigar1     == sam_v1_6_alignment_cigar2 &&
+      sam_v1_6_alignment_rnext1     == sam_v1_6_alignment_rnext2 &&
+      sam_v1_6_alignment_pnext1     == sam_v1_6_alignment_pnext2 &&
+      sam_v1_6_alignment_tlen1      == sam_v1_6_alignment_tlen2  &&
+      sam_v1_6_alignment_seq1       == sam_v1_6_alignment_seq2   &&
+      sam_v1_6_alignment_qual1      == sam_v1_6_alignment_qual2  &&
+      sam_v1_6_alignment_optfields1 == sam_v1_6_alignment_optfields2
 
 instance Show SAM_V1_6_Alignment where
-  show (SAM_V1_6_Alignment qname flag rname pos mapq cigar rnext pnext tlen seq qual aopt iopt fopt zopt hopt bopt) =
-    "SAM_V1_6_Alignment { "          ++
-    "sam_v1_6_alignment_qname = "    ++
-    (show qname)                     ++
-    " , sam_v1_6_alignment_flag = "  ++
-    (show flag)                      ++
-    " , sam_v1_6_alignment_rname = " ++
-    (show rname)                     ++
-    " , sam_v1_6_alignment_pos = "   ++
-    (show pos)                       ++
-    " , sam_v1_6_alignment_mapq = "  ++
-    (show mapq)                      ++
-    " , sam_v1_6_alignment_cigar = " ++
-    (show cigar)                     ++
-    " , sam_v1_6_alignment_rnext = " ++
-    (show rnext)                     ++
-    " , sam_v1_6_alignment_pnext = " ++
-    (show pnext)                     ++
-    " , sam_v1_6_alignment_tlen = "  ++
-    (show tlen)                      ++
-    " , sam_v1_6_alignment_seq = "   ++
-    (show seq)                       ++
-    " , sam_v1_6_alignment_qual = "  ++
-    (show qual)                      ++
-    " , sam_v1_6_alignment_aopt = "  ++
-    ( show aopt)                     ++
-    " , sam_v1_6_alignment_iopt = "  ++
-    (show iopt)                      ++
-    " , sam_v1_6_alignment_fopt = "  ++
-    (show fopt)                      ++
-    " , sam_v1_6_alignment_zopt = "  ++
-    (show zopt)                      ++
-    " , sam_v1_6_alignment_hopt = "  ++
-    (show hopt)                      ++
-    " , sam_v1_6_alignment_bopt = "  ++
-    (show bopt)                      ++
+  show (SAM_V1_6_Alignment qname
+                           flag
+                           rname
+                           pos
+                           mapq
+                           cigar
+                           rnext
+                           pnext
+                           tlen
+                           seq
+                           qual
+                           optfields
+       ) =
+    "SAM_V1_6_Alignment { "                   ++
+    "sam_v1_6_alignment_qname = "             ++
+    (show qname)                              ++
+    " , sam_v1_6_alignment_flag = "           ++
+    (show flag)                               ++
+    " , sam_v1_6_alignment_rname = "          ++
+    (show rname)                              ++
+    " , sam_v1_6_alignment_pos = "            ++
+    (show pos)                                ++
+    " , sam_v1_6_alignment_mapq = "           ++
+    (show mapq)                               ++
+    " , sam_v1_6_alignment_cigar = "          ++
+    (show cigar)                              ++
+    " , sam_v1_6_alignment_rnext = "          ++
+    (show rnext)                              ++
+    " , sam_v1_6_alignment_pnext = "          ++
+    (show pnext)                              ++
+    " , sam_v1_6_alignment_tlen = "           ++
+    (show tlen)                               ++
+    " , sam_v1_6_alignment_seq = "            ++
+    (show seq)                                ++
+    " , sam_v1_6_alignment_qual = "           ++
+    (show qual)                               ++
+    " , sam_v1_6_alignment_optionalfields = " ++
+    ( show optfields)                         ++
     " }"
diff --git a/src/Data/SAM/Version1_6/Alignment/FOPT.hs b/src/Data/SAM/Version1_6/Alignment/FOPT.hs
deleted file mode 100644
--- a/src/Data/SAM/Version1_6/Alignment/FOPT.hs
+++ /dev/null
@@ -1,68 +0,0 @@
-{-# LANGUAGE DeriveDataTypeable    #-}
-{-# LANGUAGE DeriveGeneric         #-}
-{-# LANGUAGE FlexibleContexts      #-}
-{-# LANGUAGE FlexibleInstances     #-}
-{-# LANGUAGE MultiParamTypeClasses #-}
-{-# LANGUAGE OverloadedStrings     #-}
-{-# LANGUAGE TypeFamilies          #-}
-
--- |
--- Module      :  Data.SAM.Version1_6.Alignment.FOPT
--- Copyright   :  (c) Matthew Mosior 2023
--- License     :  BSD-style
--- Maintainer  :  mattm.github@gmail.com
--- Portability :  portable
---
--- = WARNING
---
--- This module is considered __internal__.
---
--- The Package Versioning Policy __does not apply__.
---
--- The contents of this module may change __in any way whatsoever__
--- and __without any warning__ between minor versions of this package.
---
--- Authors importing this library are expected to track development
--- closely.
---
--- All credit goes to the author(s)/maintainer(s) of the
--- [containers](https://hackage.haskell.org/package/containers) library
--- for the above warning text.
---
--- = Description
---
--- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
-
-module Data.SAM.Version1_6.Alignment.FOPT ( -- * SAM version 1.6 alignment optional fields data type
-                                            SAM_V1_6_Alignment_FOPT(..)
-                                          ) where
-
-import Data.ByteString (ByteString)
-import Data.Data
-import Generics.Deriving.Base
-
-
--- | Custom SAM (version 1.6) @"SAM_V1_6_Alignment_FOPT"@ data type.
---
--- See section 1.5 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
-data SAM_V1_6_Alignment_FOPT = SAM_V1_6_Alignment_FOPT { sam_v1_6_alignment_fopt_tag   :: ByteString 
-                                                       , sam_v1_6_alignment_fopt_value :: Float
-                                                       }
-  deriving (Generic,Typeable)
-
-instance Eq SAM_V1_6_Alignment_FOPT where
-  SAM_V1_6_Alignment_FOPT sam_v1_6_alignment_fopt_tag1
-                          sam_v1_6_alignment_fopt_value1 == SAM_V1_6_Alignment_FOPT sam_v1_6_alignment_fopt_tag2
-                                                                                    sam_v1_6_alignment_fopt_value2 = sam_v1_6_alignment_fopt_tag1   == sam_v1_6_alignment_fopt_tag2     &&
-                                                                                                                     sam_v1_6_alignment_fopt_value1  == sam_v1_6_alignment_fopt_value2
-
-instance Show SAM_V1_6_Alignment_FOPT where
-  show (SAM_V1_6_Alignment_FOPT tag
-                                value
-       ) =
-    "SAM_V1_6_Alignment_FOPT { "          ++
-    "sam_v1_6_alignment_fopt_tag = "      ++
-    (show tag)                            ++
-    " , sam_v1_6_alignment_fopt_value = " ++
-    (show value)                          ++
-    " }"
diff --git a/src/Data/SAM/Version1_6/Alignment/HOPT.hs b/src/Data/SAM/Version1_6/Alignment/HOPT.hs
deleted file mode 100644
--- a/src/Data/SAM/Version1_6/Alignment/HOPT.hs
+++ /dev/null
@@ -1,68 +0,0 @@
-{-# LANGUAGE DeriveDataTypeable    #-}
-{-# LANGUAGE DeriveGeneric         #-}
-{-# LANGUAGE FlexibleContexts      #-}
-{-# LANGUAGE FlexibleInstances     #-}
-{-# LANGUAGE MultiParamTypeClasses #-}
-{-# LANGUAGE OverloadedStrings     #-}
-{-# LANGUAGE TypeFamilies          #-}
-
--- |
--- Module      :  Data.SAM.Version1_6.Alignment.HOPT
--- Copyright   :  (c) Matthew Mosior 2023
--- License     :  BSD-style
--- Maintainer  :  mattm.github@gmail.com
--- Portability :  portable
---
--- = WARNING
---
--- This module is considered __internal__.
---
--- The Package Versioning Policy __does not apply__.
---
--- The contents of this module may change __in any way whatsoever__
--- and __without any warning__ between minor versions of this package.
---
--- Authors importing this library are expected to track development
--- closely.
---
--- All credit goes to the author(s)/maintainer(s) of the
--- [containers](https://hackage.haskell.org/package/containers) library
--- for the above warning text.
---
--- = Description
---
--- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
-
-module Data.SAM.Version1_6.Alignment.HOPT ( -- * SAM version 1.6 alignment optional fields data type
-                                            SAM_V1_6_Alignment_HOPT(..)
-                                          ) where
-
-import Data.ByteString (ByteString)
-import Data.Data
-import Generics.Deriving.Base
-
-
--- | Custom SAM (version 1.6) @"SAM_V1_6_Alignment_HOPT"@ data type.
---
--- See section 1.5 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
-data SAM_V1_6_Alignment_HOPT = SAM_V1_6_Alignment_HOPT { sam_v1_6_alignment_hopt_tag   :: ByteString 
-                                                       , sam_v1_6_alignment_hopt_value :: ByteString
-                                                       }
-  deriving (Generic,Typeable)
-
-instance Eq SAM_V1_6_Alignment_HOPT where
-  SAM_V1_6_Alignment_HOPT sam_v1_6_alignment_hopt_tag1
-                          sam_v1_6_alignment_hopt_value1 == SAM_V1_6_Alignment_HOPT sam_v1_6_alignment_hopt_tag2
-                                                                                    sam_v1_6_alignment_hopt_value2 = sam_v1_6_alignment_hopt_tag1   == sam_v1_6_alignment_hopt_tag2     &&
-                                                                                                                     sam_v1_6_alignment_hopt_value1  == sam_v1_6_alignment_hopt_value2
-
-instance Show SAM_V1_6_Alignment_HOPT where
-  show (SAM_V1_6_Alignment_HOPT tag
-                                value
-       ) =
-    "SAM_V1_6_Alignment_HOPT { "          ++
-    "sam_v1_6_alignment_hopt_tag = "      ++
-    (show tag)                            ++
-    " , sam_v1_6_alignment_hopt_value = " ++
-    (show value)                          ++
-    " }"
diff --git a/src/Data/SAM/Version1_6/Alignment/IOPT.hs b/src/Data/SAM/Version1_6/Alignment/IOPT.hs
deleted file mode 100644
--- a/src/Data/SAM/Version1_6/Alignment/IOPT.hs
+++ /dev/null
@@ -1,68 +0,0 @@
-{-# LANGUAGE DeriveDataTypeable    #-}
-{-# LANGUAGE DeriveGeneric         #-}
-{-# LANGUAGE FlexibleContexts      #-}
-{-# LANGUAGE FlexibleInstances     #-}
-{-# LANGUAGE MultiParamTypeClasses #-}
-{-# LANGUAGE OverloadedStrings     #-}
-{-# LANGUAGE TypeFamilies          #-}
-
--- |
--- Module      :  Data.SAM.Version1_6.Alignment.IOPT
--- Copyright   :  (c) Matthew Mosior 2023
--- License     :  BSD-style
--- Maintainer  :  mattm.github@gmail.com
--- Portability :  portable
---
--- = WARNING
---
--- This module is considered __internal__.
---
--- The Package Versioning Policy __does not apply__.
---
--- The contents of this module may change __in any way whatsoever__
--- and __without any warning__ between minor versions of this package.
---
--- Authors importing this library are expected to track development
--- closely.
---
--- All credit goes to the author(s)/maintainer(s) of the
--- [containers](https://hackage.haskell.org/package/containers) library
--- for the above warning text.
---
--- = Description
---
--- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
-
-module Data.SAM.Version1_6.Alignment.IOPT ( -- * SAM version 1.6 alignment optional fields data type
-                                            SAM_V1_6_Alignment_IOPT(..)
-                                          ) where
-
-import Data.ByteString (ByteString)
-import Data.Data
-import Generics.Deriving.Base
-
-
--- | Custom SAM (version 1.6) @"SAM_V1_6_Alignment_IOPT"@ data type.
---
--- See section 1.5 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
-data SAM_V1_6_Alignment_IOPT = SAM_V1_6_Alignment_IOPT { sam_v1_6_alignment_iopt_tag   :: ByteString 
-                                                       , sam_v1_6_alignment_iopt_value :: Integer
-                                                       }
-  deriving (Generic,Typeable)
-
-instance Eq SAM_V1_6_Alignment_IOPT where
-  SAM_V1_6_Alignment_IOPT sam_v1_6_alignment_iopt_tag1
-                          sam_v1_6_alignment_iopt_value1 == SAM_V1_6_Alignment_IOPT sam_v1_6_alignment_iopt_tag2
-                                                                                    sam_v1_6_alignment_iopt_value2 = sam_v1_6_alignment_iopt_tag1   == sam_v1_6_alignment_iopt_tag2     &&
-                                                                                                                     sam_v1_6_alignment_iopt_value1  == sam_v1_6_alignment_iopt_value2
-
-instance Show SAM_V1_6_Alignment_IOPT where
-  show (SAM_V1_6_Alignment_IOPT tag
-                                value
-       ) =
-    "SAM_V1_6_Alignment_IOPT { "          ++
-    "sam_v1_6_alignment_iopt_tag = "      ++
-    (show tag)                            ++
-    " , sam_v1_6_alignment_iopt_value = " ++
-    (show value)                          ++
-    " }"
diff --git a/src/Data/SAM/Version1_6/Alignment/OptionalFields/AOPT.hs b/src/Data/SAM/Version1_6/Alignment/OptionalFields/AOPT.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/SAM/Version1_6/Alignment/OptionalFields/AOPT.hs
@@ -0,0 +1,70 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE StrictData            #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.SAM.Version1_6.Alignment.OptionalFields.AOPT
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = WARNING
+--
+-- This module is considered __internal__.
+--
+-- The Package Versioning Policy __does not apply__.
+--
+-- The contents of this module may change __in any way whatsoever__
+-- and __without any warning__ between minor versions of this package.
+--
+-- Authors importing this library are expected to track development
+-- closely.
+--
+-- All credit goes to the author(s)/maintainer(s) of the
+-- [containers](https://hackage.haskell.org/package/containers) library
+-- for the above warning text.
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.SAM.Version1_6.Alignment.OptionalFields.AOPT ( -- * SAM version 1.6 alignment optional fields data type
+                                                           SAM_V1_6_Alignment_OptionalFields_AOPT(..)
+                                                         ) where
+
+import Data.ByteString (ByteString)
+import Data.Data
+import Generics.Deriving.Base
+
+-- | Custom SAM (version 1.6) @"SAM_V1_6_Alignment_AOPT"@ data type.
+--
+-- See section 1.5 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data SAM_V1_6_Alignment_OptionalFields_AOPT = SAM_V1_6_Alignment_OptionalFields_AOPT
+  { sam_v1_6_alignment_optionalfields_aopt_tag   :: ByteString 
+  , sam_v1_6_alignment_optionalfields_aopt_value :: ByteString
+  } deriving (Generic,Typeable)
+
+instance Eq SAM_V1_6_Alignment_OptionalFields_AOPT where
+  SAM_V1_6_Alignment_OptionalFields_AOPT sam_v1_6_alignment_optionalfields_aopt_tag1
+                                         sam_v1_6_alignment_optionalfields_aopt_value1 ==
+    SAM_V1_6_Alignment_OptionalFields_AOPT sam_v1_6_alignment_optionalfields_aopt_tag2
+                                           sam_v1_6_alignment_optionalfields_aopt_value2 =
+      sam_v1_6_alignment_optionalfields_aopt_tag1   == sam_v1_6_alignment_optionalfields_aopt_tag2 &&
+      sam_v1_6_alignment_optionalfields_aopt_value1 == sam_v1_6_alignment_optionalfields_aopt_value2
+
+instance Show SAM_V1_6_Alignment_OptionalFields_AOPT where
+  show (SAM_V1_6_Alignment_OptionalFields_AOPT tag
+                                               value
+       ) =
+    "SAM_V1_6_Alignment_OptionalFields_AOPT { "          ++
+    "sam_v1_6_alignment_optionalfields_aopt_tag = "      ++
+    (show tag)                                           ++
+    " , sam_v1_6_alignment_optionalfields_aopt_value = " ++
+    (show value)                                         ++
+    " }"
diff --git a/src/Data/SAM/Version1_6/Alignment/OptionalFields/BOPT.hs b/src/Data/SAM/Version1_6/Alignment/OptionalFields/BOPT.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/SAM/Version1_6/Alignment/OptionalFields/BOPT.hs
@@ -0,0 +1,352 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE StrictData            #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.SAM.Version1_6.Alignment.OptionalFields.BOPT
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = WARNING
+--
+-- This module is considered __internal__.
+--
+-- The Package Versioning Policy __does not apply__.
+--
+-- The contents of this module may change __in any way whatsoever__
+-- and __without any warning__ between minor versions of this package.
+--
+-- Authors importing this library are expected to track development
+-- closely.
+--
+-- All credit goes to the author(s)/maintainer(s) of the
+-- [containers](https://hackage.haskell.org/package/containers) library
+-- for the above warning text.
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.SAM.Version1_6.Alignment.OptionalFields.BOPT ( -- * SAM version 1.6 alignment optional fields data type
+                                                           SAM_V1_6_Alignment_OptionalFields_BOPT(..),
+                                                           SAM_V1_6_Alignment_OptionalFields_BOPT_Int8(..),
+                                                           SAM_V1_6_Alignment_OptionalFields_BOPT_Word8(..),
+                                                           SAM_V1_6_Alignment_OptionalFields_BOPT_Int16(..),
+                                                           SAM_V1_6_Alignment_OptionalFields_BOPT_Word16(..),
+                                                           SAM_V1_6_Alignment_OptionalFields_BOPT_Int32(..),
+                                                           SAM_V1_6_Alignment_OptionalFields_BOPT_Word32(..),
+                                                           SAM_V1_6_Alignment_OptionalFields_BOPT_Float(..)
+                                                         ) where
+
+import Data.Data
+import Data.Int
+import Data.Sequence
+import Data.Word
+import Generics.Deriving.Base
+
+-- | Custom SAM (version 1.6) @"SAM_V1_6_Alignment_OptionalFields_BOPT"@ data type.
+--
+-- See section 1.5 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data SAM_V1_6_Alignment_OptionalFields_BOPT = SAM_V1_6_Alignment_OptionalFields_BOPT
+  { sam_v1_6_alignment_optionalfields_bopt_int8   :: Maybe SAM_V1_6_Alignment_OptionalFields_BOPT_Int8
+  , sam_v1_6_alignment_optionalfields_bopt_word8  :: Maybe SAM_V1_6_Alignment_OptionalFields_BOPT_Word8
+  , sam_v1_6_alignment_optionalfields_bopt_int16  :: Maybe SAM_V1_6_Alignment_OptionalFields_BOPT_Int16
+  , sam_v1_6_alignment_optionalfields_bopt_word16 :: Maybe SAM_V1_6_Alignment_OptionalFields_BOPT_Word16
+  , sam_v1_6_alignment_optionalfields_bopt_int32  :: Maybe SAM_V1_6_Alignment_OptionalFields_BOPT_Int32
+  , sam_v1_6_alignment_optionalfields_bopt_word32 :: Maybe SAM_V1_6_Alignment_OptionalFields_BOPT_Word32
+  , sam_v1_6_alignment_optionalfields_bopt_float  :: Maybe SAM_V1_6_Alignment_OptionalFields_BOPT_Float
+  } deriving (Generic,Typeable)
+
+instance Eq SAM_V1_6_Alignment_OptionalFields_BOPT where
+  SAM_V1_6_Alignment_OptionalFields_BOPT sam_v1_6_alignment_optionalfields_bopt_int81
+                                         sam_v1_6_alignment_optionalfields_bopt_word81
+                                         sam_v1_6_alignment_optionalfields_bopt_int161
+                                         sam_v1_6_alignment_optionalfields_bopt_word161
+                                         sam_v1_6_alignment_optionalfields_bopt_int321
+                                         sam_v1_6_alignment_optionalfields_bopt_word321
+                                         sam_v1_6_alignment_optionalfields_bopt_float1 ==
+    SAM_V1_6_Alignment_OptionalFields_BOPT sam_v1_6_alignment_optionalfields_bopt_int82
+                                           sam_v1_6_alignment_optionalfields_bopt_word82
+                                           sam_v1_6_alignment_optionalfields_bopt_int162
+                                           sam_v1_6_alignment_optionalfields_bopt_word162
+                                           sam_v1_6_alignment_optionalfields_bopt_int322
+                                           sam_v1_6_alignment_optionalfields_bopt_word322
+                                           sam_v1_6_alignment_optionalfields_bopt_float2 =
+      sam_v1_6_alignment_optionalfields_bopt_int81   == sam_v1_6_alignment_optionalfields_bopt_int82   &&
+      sam_v1_6_alignment_optionalfields_bopt_word81  == sam_v1_6_alignment_optionalfields_bopt_word82  &&
+      sam_v1_6_alignment_optionalfields_bopt_int161  == sam_v1_6_alignment_optionalfields_bopt_int162  &&
+      sam_v1_6_alignment_optionalfields_bopt_word161 == sam_v1_6_alignment_optionalfields_bopt_word162 &&
+      sam_v1_6_alignment_optionalfields_bopt_int321  == sam_v1_6_alignment_optionalfields_bopt_int322  &&
+      sam_v1_6_alignment_optionalfields_bopt_word321 == sam_v1_6_alignment_optionalfields_bopt_word322 &&
+      sam_v1_6_alignment_optionalfields_bopt_float1  == sam_v1_6_alignment_optionalfields_bopt_float2
+
+instance Show SAM_V1_6_Alignment_OptionalFields_BOPT where
+  show (SAM_V1_6_Alignment_OptionalFields_BOPT int8
+                                word8
+                                int16
+                                word16
+                                int32
+                                word32
+                                float
+       ) =
+    "SAM_V1_6_Alignment_OptionalFields_BOPT { "           ++
+    "sam_v1_6_alignment_optionalfields_bopt_int8 = "      ++
+    (show int8)                                           ++
+    " , sam_v1_6_alignment_optionalfields_bopt_word8 = "  ++
+    (show word8)                                          ++
+    " , sam_v1_6_alignment_optionalfields_bopt_int16 = "  ++
+    (show int16)                                          ++
+    " , sam_v1_6_alignment_optionalfields_bopt_word16 = " ++
+    (show word16)                                         ++
+    " , sam_v1_6_alignment_optionalfields_bopt_int32 = "  ++
+    (show int32)                                          ++
+    " , sam_v1_6_alignment_optionalfields_bopt_word32 = " ++
+    (show word32)                                         ++
+    " , sam_v1_6_alignment_optionalfields_bopt_float = "  ++
+    (show float)                                          ++
+    " }"
+
+-- | __c__CsSiIf of the last optional field (type B).
+--
+-- See section 1.5 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data SAM_V1_6_Alignment_OptionalFields_BOPT_Int8 = SAM_V1_6_Alignment_OptionalFields_BOPT_Int8
+  { sam_v1_6_alignment_optionalfields_bopt_int8_tag   :: Seq Word8
+  , sam_v1_6_alignment_optionalfields_bopt_int8_type  :: Word8
+  , sam_v1_6_alignment_optionalfields_bopt_int8_value :: Seq Int8
+  } deriving (Generic,Typeable)
+
+instance Eq SAM_V1_6_Alignment_OptionalFields_BOPT_Int8 where
+  SAM_V1_6_Alignment_OptionalFields_BOPT_Int8 sam_v1_6_alignment_optionalfields_bopt_int8_tag1
+                                              sam_v1_6_alignment_optionalfields_bopt_int8_type1
+                                              sam_v1_6_alignment_optionalfields_bopt_int8_value1 ==
+    SAM_V1_6_Alignment_OptionalFields_BOPT_Int8 sam_v1_6_alignment_optionalfields_bopt_int8_tag2
+                                                sam_v1_6_alignment_optionalfields_bopt_int8_type2
+                                                sam_v1_6_alignment_optionalfields_bopt_int8_value2 =
+      sam_v1_6_alignment_optionalfields_bopt_int8_tag1 == sam_v1_6_alignment_optionalfields_bopt_int8_tag2   &&
+      sam_v1_6_alignment_optionalfields_bopt_int8_type1 == sam_v1_6_alignment_optionalfields_bopt_int8_type2 &&
+      sam_v1_6_alignment_optionalfields_bopt_int8_value1 == sam_v1_6_alignment_optionalfields_bopt_int8_value2
+
+instance Show SAM_V1_6_Alignment_OptionalFields_BOPT_Int8 where
+  show (SAM_V1_6_Alignment_OptionalFields_BOPT_Int8 tag
+                                                    bopttype
+                                                    value
+       ) =
+    "SAM_V1_6_Alignment_OptionalFields_BOPT_Int8 { "          ++
+    "sam_v1_6_alignment_optionalfields_bopt_int8_tag  = "     ++
+    (show tag)                                                ++
+    " , sam_v1_6_alignment_optionalfields_bopt_int8_type = "  ++
+    (show bopttype)                                           ++
+    " , sam_v1_6_alignment_optionalfields_bopt_int8_value = " ++
+    (show value)                                              ++
+    " }"
+
+-- | c__C__sSiIf of the last optional field (type B).
+--
+-- See section 1.5 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data SAM_V1_6_Alignment_OptionalFields_BOPT_Word8 = SAM_V1_6_Alignment_OptionalFields_BOPT_Word8
+  { sam_v1_6_alignment_optionalfields_bopt_word8_tag   :: Seq Word8
+  , sam_v1_6_alignment_optionalfields_bopt_word8_type  :: Word8
+  , sam_v1_6_alignment_optionalfields_bopt_word8_value :: Seq Word8
+  } deriving (Generic,Typeable)
+
+instance Eq SAM_V1_6_Alignment_OptionalFields_BOPT_Word8 where
+  SAM_V1_6_Alignment_OptionalFields_BOPT_Word8 sam_v1_6_alignment_optionalfields_bopt_word8_tag1
+                                               sam_v1_6_alignment_optionalfields_bopt_word8_type1
+                                               sam_v1_6_alignment_optionalfields_bopt_word8_value1 ==
+    SAM_V1_6_Alignment_OptionalFields_BOPT_Word8 sam_v1_6_alignment_optionalfields_bopt_word8_tag2
+                                                 sam_v1_6_alignment_optionalfields_bopt_word8_type2
+                                                 sam_v1_6_alignment_optionalfields_bopt_word8_value2 =
+      sam_v1_6_alignment_optionalfields_bopt_word8_tag1 == sam_v1_6_alignment_optionalfields_bopt_word8_tag2   &&
+      sam_v1_6_alignment_optionalfields_bopt_word8_type1 == sam_v1_6_alignment_optionalfields_bopt_word8_type2 &&
+      sam_v1_6_alignment_optionalfields_bopt_word8_value1 == sam_v1_6_alignment_optionalfields_bopt_word8_value2
+
+instance Show SAM_V1_6_Alignment_OptionalFields_BOPT_Word8 where
+  show (SAM_V1_6_Alignment_OptionalFields_BOPT_Word8 tag
+                                                     bopttype
+                                                     value
+       ) =
+    "SAM_V1_6_Alignment_OptionalFields_BOPT_Word8 { "          ++
+    "sam_v1_6_alignment_optionalfields_bopt_word8_tag  = "     ++
+    (show tag)                                                 ++
+    " , sam_v1_6_alignment_optionalfields_bopt_word8_type = "  ++
+    (show bopttype)                                            ++
+    " , sam_v1_6_alignment_optionalfields_bopt_word8_value = " ++
+    (show value)                                               ++
+    " }"
+
+-- | cC__s__SiIf of the last optional field (type B).
+--
+-- See section 1.5 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data SAM_V1_6_Alignment_OptionalFields_BOPT_Int16 = SAM_V1_6_Alignment_OptionalFields_BOPT_Int16
+  { sam_v1_6_alignment_optionalfields_bopt_int16_tag   :: Seq Word8
+  , sam_v1_6_alignment_optionalfields_bopt_int16_type  :: Word8
+  , sam_v1_6_alignment_optionalfields_bopt_int16_value :: Seq Int16
+  } deriving (Generic,Typeable)
+
+instance Eq SAM_V1_6_Alignment_OptionalFields_BOPT_Int16 where
+  SAM_V1_6_Alignment_OptionalFields_BOPT_Int16 sam_v1_6_alignment_optionalfields_bopt_int16_tag1
+                                               sam_v1_6_alignment_optionalfields_bopt_int16_type1
+                                               sam_v1_6_alignment_optionalfields_bopt_int16_value1 ==
+    SAM_V1_6_Alignment_OptionalFields_BOPT_Int16 sam_v1_6_alignment_optionalfields_bopt_int16_tag2
+                                                 sam_v1_6_alignment_optionalfields_bopt_int16_type2
+                                                 sam_v1_6_alignment_optionalfields_bopt_int16_value2 =
+      sam_v1_6_alignment_optionalfields_bopt_int16_tag1 == sam_v1_6_alignment_optionalfields_bopt_int16_tag2   &&
+      sam_v1_6_alignment_optionalfields_bopt_int16_type1 == sam_v1_6_alignment_optionalfields_bopt_int16_type2 &&
+      sam_v1_6_alignment_optionalfields_bopt_int16_value1 == sam_v1_6_alignment_optionalfields_bopt_int16_value2
+
+instance Show SAM_V1_6_Alignment_OptionalFields_BOPT_Int16 where
+  show (SAM_V1_6_Alignment_OptionalFields_BOPT_Int16 tag
+                                                     bopttype
+                                                     value
+       ) =
+    "SAM_V1_6_Alignment_OptionalFields_BOPT_Int16 { "          ++
+    "sam_v1_6_alignment_optionalfields_bopt_int16_tag  = "     ++
+    (show tag)                                                 ++
+    " , sam_v1_6_alignment_optionalfields_bopt_int16_type = "  ++
+    (show bopttype)                                            ++
+    " , sam_v1_6_alignment_optionalfields_bopt_int16_value = " ++
+    (show value)                                               ++
+    " }"
+
+-- | cCs__S__iIf of the last optional field (type B).
+--
+-- See section 1.5 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data SAM_V1_6_Alignment_OptionalFields_BOPT_Word16 = SAM_V1_6_Alignment_OptionalFields_BOPT_Word16
+  { sam_v1_6_alignment_optionalfields_bopt_word16_tag   :: Seq Word8
+  , sam_v1_6_alignment_optionalfields_bopt_word16_type  :: Word8
+  , sam_v1_6_alignment_optionalfields_bopt_word16_value :: Seq Word16
+  } deriving (Generic,Typeable)
+
+instance Eq SAM_V1_6_Alignment_OptionalFields_BOPT_Word16 where
+  SAM_V1_6_Alignment_OptionalFields_BOPT_Word16 sam_v1_6_alignment_optionalfields_bopt_word16_tag1
+                                                sam_v1_6_alignment_optionalfields_bopt_word16_type1
+                                                sam_v1_6_alignment_optionalfields_bopt_word16_value1 ==
+    SAM_V1_6_Alignment_OptionalFields_BOPT_Word16 sam_v1_6_alignment_optionalfields_bopt_word16_tag2
+                                                  sam_v1_6_alignment_optionalfields_bopt_word16_type2
+                                                  sam_v1_6_alignment_optionalfields_bopt_word16_value2 =
+      sam_v1_6_alignment_optionalfields_bopt_word16_tag1 == sam_v1_6_alignment_optionalfields_bopt_word16_tag2   &&
+      sam_v1_6_alignment_optionalfields_bopt_word16_type1 == sam_v1_6_alignment_optionalfields_bopt_word16_type2 &&
+      sam_v1_6_alignment_optionalfields_bopt_word16_value1 == sam_v1_6_alignment_optionalfields_bopt_word16_value2
+
+instance Show SAM_V1_6_Alignment_OptionalFields_BOPT_Word16 where
+  show (SAM_V1_6_Alignment_OptionalFields_BOPT_Word16 tag
+                                                      bopttype
+                                                      value
+       ) =
+    "SAM_V1_6_Alignment_OptionalFields_BOPT_Word16 { "          ++
+    "sam_v1_6_alignment_optionalfields_bopt_word16_tag  = "     ++
+    (show tag)                                                  ++
+    " , sam_v1_6_alignment_optionalfields_bopt_word16_type = "  ++
+    (show bopttype)                                             ++
+    " , sam_v1_6_alignment_optionalfields_bopt_word16_value = " ++
+    (show value)                                                ++
+    " }"
+
+-- | cCsS__i__If of the last optional field (type B).
+--
+-- See section 1.5 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data SAM_V1_6_Alignment_OptionalFields_BOPT_Int32 = SAM_V1_6_Alignment_OptionalFields_BOPT_Int32
+  { sam_v1_6_alignment_optionalfields_bopt_int32_tag   :: Seq Word8
+  , sam_v1_6_alignment_optionalfields_bopt_int32_type  :: Word8
+  , sam_v1_6_alignment_optionalfields_bopt_int32_value :: Seq Int32
+  } deriving (Generic,Typeable)
+
+instance Eq SAM_V1_6_Alignment_OptionalFields_BOPT_Int32 where
+  SAM_V1_6_Alignment_OptionalFields_BOPT_Int32 sam_v1_6_alignment_optionalfields_bopt_int32_tag1
+                                               sam_v1_6_alignment_optionalfields_bopt_int32_type1
+                                               sam_v1_6_alignment_optionalfields_bopt_int32_value1 ==
+    SAM_V1_6_Alignment_OptionalFields_BOPT_Int32 sam_v1_6_alignment_optionalfields_bopt_int32_tag2
+                                                 sam_v1_6_alignment_optionalfields_bopt_int32_type2
+                                                 sam_v1_6_alignment_optionalfields_bopt_int32_value2 =
+      sam_v1_6_alignment_optionalfields_bopt_int32_tag1 == sam_v1_6_alignment_optionalfields_bopt_int32_tag2   &&
+      sam_v1_6_alignment_optionalfields_bopt_int32_type1 == sam_v1_6_alignment_optionalfields_bopt_int32_type2 &&
+      sam_v1_6_alignment_optionalfields_bopt_int32_value1 == sam_v1_6_alignment_optionalfields_bopt_int32_value2
+
+instance Show SAM_V1_6_Alignment_OptionalFields_BOPT_Int32 where
+  show (SAM_V1_6_Alignment_OptionalFields_BOPT_Int32 tag
+                                                     bopttype
+                                                     value
+       ) =
+    "SAM_V1_6_Alignment_OptionalFields_BOPT_Int32 { "          ++
+    "sam_v1_6_alignment_optionalfields_bopt_int32_tag  = "     ++
+    (show tag)                                                 ++
+    " , sam_v1_6_alignment_optionalfields_bopt_int32_type = "  ++
+    (show bopttype)                                            ++
+    " , sam_v1_6_alignment_optionalfields_bopt_int32_value = " ++
+    (show value)                                               ++
+    " }"
+
+-- | cCsSi__I__f of the last optional field (type B).
+--
+-- See section 1.5 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data SAM_V1_6_Alignment_OptionalFields_BOPT_Word32 = SAM_V1_6_Alignment_OptionalFields_BOPT_Word32
+  { sam_v1_6_alignment_optionalfields_bopt_word32_tag   :: Seq Word8
+  , sam_v1_6_alignment_optionalfields_bopt_word32_type  :: Word8
+  , sam_v1_6_alignment_optionalfields_bopt_word32_value :: Seq Word32
+  } deriving (Generic,Typeable)
+
+instance Eq SAM_V1_6_Alignment_OptionalFields_BOPT_Word32 where
+  SAM_V1_6_Alignment_OptionalFields_BOPT_Word32 sam_v1_6_alignment_optionalfields_bopt_word32_tag1
+                                                sam_v1_6_alignment_optionalfields_bopt_word32_type1
+                                                sam_v1_6_alignment_optionalfields_bopt_word32_value1 ==
+    SAM_V1_6_Alignment_OptionalFields_BOPT_Word32 sam_v1_6_alignment_optionalfields_bopt_word32_tag2
+                                                  sam_v1_6_alignment_optionalfields_bopt_word32_type2
+                                                  sam_v1_6_alignment_optionalfields_bopt_word32_value2 =
+      sam_v1_6_alignment_optionalfields_bopt_word32_tag1 == sam_v1_6_alignment_optionalfields_bopt_word32_tag2   &&
+      sam_v1_6_alignment_optionalfields_bopt_word32_type1 == sam_v1_6_alignment_optionalfields_bopt_word32_type2 &&
+      sam_v1_6_alignment_optionalfields_bopt_word32_value1 == sam_v1_6_alignment_optionalfields_bopt_word32_value2
+
+instance Show SAM_V1_6_Alignment_OptionalFields_BOPT_Word32 where
+  show (SAM_V1_6_Alignment_OptionalFields_BOPT_Word32 tag
+                                                      bopttype
+                                                      value
+       ) =
+    "SAM_V1_6_Alignment_OptionalFields_BOPT_Word32 { "          ++
+    "sam_v1_6_alignment_optionalfields_bopt_word32_tag  = "     ++
+    (show tag)                                                  ++
+    " , sam_v1_6_alignment_optionalfields_bopt_word32_type = "  ++
+    (show bopttype)                                             ++
+    " , sam_v1_6_alignment_optionalfields_bopt_word32_value = " ++
+    (show value)                                                ++
+    " }"
+
+-- | cCsSiI__f__ of the last optional field (type B).
+--
+-- See section 1.5 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data SAM_V1_6_Alignment_OptionalFields_BOPT_Float = SAM_V1_6_Alignment_OptionalFields_BOPT_Float
+  { sam_v1_6_alignment_optionalfields_bopt_float_tag   :: Seq Word8
+  , sam_v1_6_alignment_optionalfields_bopt_float_type  :: Word8
+  , sam_v1_6_alignment_optionalfields_bopt_float_value :: Seq Float
+  } deriving (Generic,Typeable)
+
+instance Eq SAM_V1_6_Alignment_OptionalFields_BOPT_Float where
+  SAM_V1_6_Alignment_OptionalFields_BOPT_Float sam_v1_6_alignment_optionalfields_bopt_float_tag1
+                                               sam_v1_6_alignment_optionalfields_bopt_float_type1
+                                               sam_v1_6_alignment_optionalfields_bopt_float_value1 ==
+    SAM_V1_6_Alignment_OptionalFields_BOPT_Float sam_v1_6_alignment_optionalfields_bopt_float_tag2
+                                                 sam_v1_6_alignment_optionalfields_bopt_float_type2
+                                                 sam_v1_6_alignment_optionalfields_bopt_float_value2 =
+      sam_v1_6_alignment_optionalfields_bopt_float_tag1   == sam_v1_6_alignment_optionalfields_bopt_float_tag2  &&
+      sam_v1_6_alignment_optionalfields_bopt_float_type1  == sam_v1_6_alignment_optionalfields_bopt_float_type2 &&
+      sam_v1_6_alignment_optionalfields_bopt_float_value1 == sam_v1_6_alignment_optionalfields_bopt_float_value2
+
+instance Show SAM_V1_6_Alignment_OptionalFields_BOPT_Float where
+  show (SAM_V1_6_Alignment_OptionalFields_BOPT_Float tag
+                                                     bopttype
+                                                     value
+       ) =
+    "SAM_V1_6_Alignment_OptionalFields_BOPT_Float { "          ++
+    "sam_v1_6_alignment_optionalfields_bopt_float_tag  = "     ++
+    (show tag)                                                 ++
+    " , sam_v1_6_alignment_optionalfields_bopt_float_type = "  ++
+    (show bopttype)                                            ++
+    " , sam_v1_6_alignment_optionalfields_bopt_float_value = " ++
+    (show value)                                               ++
+    " }"
diff --git a/src/Data/SAM/Version1_6/Alignment/OptionalFields/Base.hs b/src/Data/SAM/Version1_6/Alignment/OptionalFields/Base.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/SAM/Version1_6/Alignment/OptionalFields/Base.hs
@@ -0,0 +1,89 @@
+{-# LANGUAGE DeriveDataTypeable          #-}
+{-# LANGUAGE DeriveGeneric               #-}
+{-# LANGUAGE FlexibleContexts            #-}
+{-# LANGUAGE FlexibleInstances           #-}
+{-# LANGUAGE MultiParamTypeClasses       #-}
+{-# LANGUAGE OverloadedStrings           #-}
+{-# LANGUAGE StrictData                  #-}
+{-# LANGUAGE TypeFamilies                #-}
+{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
+
+-- |
+-- Module      :  Data.SAM.Version1_6.Alignment.OptionalFields.Base
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.SAM.Version1_6.Alignment.OptionalFields.Base ( -- * SAM version 1.6 alignment optional data types
+                                                           SAM_V1_6_Alignment_OptionalFields(..)
+                                                         ) where
+
+import Data.SAM.Version1_6.Alignment.OptionalFields.AOPT
+import Data.SAM.Version1_6.Alignment.OptionalFields.IOPT
+import Data.SAM.Version1_6.Alignment.OptionalFields.FOPT
+import Data.SAM.Version1_6.Alignment.OptionalFields.ZOPT
+import Data.SAM.Version1_6.Alignment.OptionalFields.HOPT
+import Data.SAM.Version1_6.Alignment.OptionalFields.BOPT
+
+import Data.Data
+import Generics.Deriving.Base
+
+-- | Custom SAM (version 1.6) @"SAM_V1_6_Alignment_OptionalFields"@ data type.
+--
+-- See section 1.4 and 1.5 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data SAM_V1_6_Alignment_OptionalFields = SAM_V1_6_Alignment_OptionalFields
+  { sam_v1_6_alignment_optionalfields_aopt  :: Maybe SAM_V1_6_Alignment_OptionalFields_AOPT -- ^ A - [!-~] - Printable characters.
+  , sam_v1_6_alignment_optionalfields_iopt  :: Maybe SAM_V1_6_Alignment_OptionalFields_IOPT -- ^ i - [-+]?[0-9]+ - Signed integer.
+  , sam_v1_6_alignment_optionalfields_fopt  :: Maybe SAM_V1_6_Alignment_OptionalFields_FOPT -- ^ f - [-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)? - Single-precision floating number.
+  , sam_v1_6_alignment_optionalfields_zopt  :: Maybe SAM_V1_6_Alignment_OptionalFields_ZOPT -- ^ Z - [ !-~]* - Printable string, including space.
+  , sam_v1_6_alignment_optionalfields_hopt  :: Maybe SAM_V1_6_Alignment_OptionalFields_HOPT -- ^ H - ([0-9A-F][0-9A-F])* - Byte array in the Hex format.
+  , sam_v1_6_alignment_optionalfields_bopt  :: Maybe SAM_V1_6_Alignment_OptionalFields_BOPT -- ^ B - [cCsSiIf]&#8203;(,[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)* - Integer or numeric array.
+  } deriving (Generic,Typeable)
+
+instance Eq SAM_V1_6_Alignment_OptionalFields where
+  SAM_V1_6_Alignment_OptionalFields sam_v1_6_alignment_optionalfields_aopt1
+                                    sam_v1_6_alignment_optionalfields_iopt1
+                                    sam_v1_6_alignment_optionalfields_fopt1
+                                    sam_v1_6_alignment_optionalfields_zopt1
+                                    sam_v1_6_alignment_optionalfields_hopt1
+                                    sam_v1_6_alignment_optionalfields_bopt1 ==
+    SAM_V1_6_Alignment_OptionalFields sam_v1_6_alignment_optionalfields_aopt2
+                                      sam_v1_6_alignment_optionalfields_iopt2
+                                      sam_v1_6_alignment_optionalfields_fopt2
+                                      sam_v1_6_alignment_optionalfields_zopt2
+                                      sam_v1_6_alignment_optionalfields_hopt2
+                                      sam_v1_6_alignment_optionalfields_bopt2 =
+      sam_v1_6_alignment_optionalfields_aopt1  == sam_v1_6_alignment_optionalfields_aopt2  &&
+      sam_v1_6_alignment_optionalfields_iopt1  == sam_v1_6_alignment_optionalfields_iopt2  &&
+      sam_v1_6_alignment_optionalfields_fopt1  == sam_v1_6_alignment_optionalfields_fopt2  &&
+      sam_v1_6_alignment_optionalfields_zopt1  == sam_v1_6_alignment_optionalfields_zopt2  &&
+      sam_v1_6_alignment_optionalfields_hopt1  == sam_v1_6_alignment_optionalfields_hopt2  &&
+      sam_v1_6_alignment_optionalfields_bopt1  == sam_v1_6_alignment_optionalfields_bopt2
+
+instance Show SAM_V1_6_Alignment_OptionalFields where
+  show (SAM_V1_6_Alignment_OptionalFields aopt
+                                          iopt
+                                          fopt
+                                          zopt
+                                          hopt
+                                          bopt
+       ) =
+    "SAM_V1_6_Alignment_OptionalFields { "          ++
+    "sam_v1_6_alignment_optionalfields_aopt = "     ++
+    ( show aopt)                                    ++
+    " , sam_v1_6_alignment_optionalfields_iopt = "  ++
+    (show iopt)                                     ++
+    " , sam_v1_6_alignment_optionalfields_fopt = "  ++
+    (show fopt)                                     ++
+    " , sam_v1_6_alignment_optionalfields_zopt = "  ++
+    (show zopt)                                     ++
+    " , sam_v1_6_alignment_optionalfields_hopt = "  ++
+    (show hopt)                                     ++
+    " , sam_v1_6_alignment_optionalfields_bopt = "  ++
+    (show bopt)                                     ++
+    " }"
diff --git a/src/Data/SAM/Version1_6/Alignment/OptionalFields/FOPT.hs b/src/Data/SAM/Version1_6/Alignment/OptionalFields/FOPT.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/SAM/Version1_6/Alignment/OptionalFields/FOPT.hs
@@ -0,0 +1,70 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE StrictData            #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.SAM.Version1_6.Alignment.OptionalFields.FOPT
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = WARNING
+--
+-- This module is considered __internal__.
+--
+-- The Package Versioning Policy __does not apply__.
+--
+-- The contents of this module may change __in any way whatsoever__
+-- and __without any warning__ between minor versions of this package.
+--
+-- Authors importing this library are expected to track development
+-- closely.
+--
+-- All credit goes to the author(s)/maintainer(s) of the
+-- [containers](https://hackage.haskell.org/package/containers) library
+-- for the above warning text.
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.SAM.Version1_6.Alignment.OptionalFields.FOPT ( -- * SAM version 1.6 alignment optional fields data type
+                                                           SAM_V1_6_Alignment_OptionalFields_FOPT(..)
+                                                         ) where
+
+import Data.ByteString (ByteString)
+import Data.Data
+import Generics.Deriving.Base
+
+-- | Custom SAM (version 1.6) @"SAM_V1_6_Alignment_OptionalFields_FOPT"@ data type.
+--
+-- See section 1.5 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data SAM_V1_6_Alignment_OptionalFields_FOPT = SAM_V1_6_Alignment_OptionalFields_FOPT
+  { sam_v1_6_alignment_optionalfields_fopt_tag   :: ByteString 
+  , sam_v1_6_alignment_optionalfields_fopt_value :: Float
+  } deriving (Generic,Typeable)
+
+instance Eq SAM_V1_6_Alignment_OptionalFields_FOPT where
+  SAM_V1_6_Alignment_OptionalFields_FOPT sam_v1_6_alignment_optionalfields_fopt_tag1
+                                         sam_v1_6_alignment_optionalfields_fopt_value1 ==
+    SAM_V1_6_Alignment_OptionalFields_FOPT sam_v1_6_alignment_optionalfields_fopt_tag2
+                                           sam_v1_6_alignment_optionalfields_fopt_value2 =
+      sam_v1_6_alignment_optionalfields_fopt_tag1 == sam_v1_6_alignment_optionalfields_fopt_tag2 &&
+      sam_v1_6_alignment_optionalfields_fopt_value1 == sam_v1_6_alignment_optionalfields_fopt_value2
+
+instance Show SAM_V1_6_Alignment_OptionalFields_FOPT where
+  show (SAM_V1_6_Alignment_OptionalFields_FOPT tag
+                                               value
+       ) =
+    "SAM_V1_6_Alignment_OptionalFields_FOPT { "          ++
+    "sam_v1_6_alignment_optionalfields_fopt_tag = "      ++
+    (show tag)                                           ++
+    " , sam_v1_6_alignment_optionalfields_fopt_value = " ++
+    (show value)                                         ++
+    " }"
diff --git a/src/Data/SAM/Version1_6/Alignment/OptionalFields/HOPT.hs b/src/Data/SAM/Version1_6/Alignment/OptionalFields/HOPT.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/SAM/Version1_6/Alignment/OptionalFields/HOPT.hs
@@ -0,0 +1,70 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE StrictData            #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.SAM.Version1_6.Alignment.OptionalFields.HOPT
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = WARNING
+--
+-- This module is considered __internal__.
+--
+-- The Package Versioning Policy __does not apply__.
+--
+-- The contents of this module may change __in any way whatsoever__
+-- and __without any warning__ between minor versions of this package.
+--
+-- Authors importing this library are expected to track development
+-- closely.
+--
+-- All credit goes to the author(s)/maintainer(s) of the
+-- [containers](https://hackage.haskell.org/package/containers) library
+-- for the above warning text.
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.SAM.Version1_6.Alignment.OptionalFields.HOPT ( -- * SAM version 1.6 alignment optional fields data type
+                                                           SAM_V1_6_Alignment_OptionalFields_HOPT(..)
+                                                         ) where
+
+import Data.ByteString (ByteString)
+import Data.Data
+import Generics.Deriving.Base
+
+-- | Custom SAM (version 1.6) @"SAM_V1_6_Alignment_OptionalFields_HOPT"@ data type.
+--
+-- See section 1.5 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data SAM_V1_6_Alignment_OptionalFields_HOPT = SAM_V1_6_Alignment_OptionalFields_HOPT
+  { sam_v1_6_alignment_optionalfields_hopt_tag   :: ByteString 
+  , sam_v1_6_alignment_optionalfields_hopt_value :: ByteString
+  } deriving (Generic,Typeable)
+
+instance Eq SAM_V1_6_Alignment_OptionalFields_HOPT where
+  SAM_V1_6_Alignment_OptionalFields_HOPT sam_v1_6_alignment_optionalfields_hopt_tag1
+                                         sam_v1_6_alignment_optionalfields_hopt_value1 ==
+    SAM_V1_6_Alignment_OptionalFields_HOPT sam_v1_6_alignment_optionalfields_hopt_tag2
+                                           sam_v1_6_alignment_optionalfields_hopt_value2 =
+      sam_v1_6_alignment_optionalfields_hopt_tag1   == sam_v1_6_alignment_optionalfields_hopt_tag2 &&
+      sam_v1_6_alignment_optionalfields_hopt_value1 == sam_v1_6_alignment_optionalfields_hopt_value2
+
+instance Show SAM_V1_6_Alignment_OptionalFields_HOPT where
+  show (SAM_V1_6_Alignment_OptionalFields_HOPT tag
+                                               value
+       ) =
+    "SAM_V1_6_Alignment_OptionalFields_HOPT { "          ++
+    "sam_v1_6_alignment_optionalfields_hopt_tag = "      ++
+    (show tag)                                           ++
+    " , sam_v1_6_alignment_optionalfields_hopt_value = " ++
+    (show value)                                         ++
+    " }"
diff --git a/src/Data/SAM/Version1_6/Alignment/OptionalFields/IOPT.hs b/src/Data/SAM/Version1_6/Alignment/OptionalFields/IOPT.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/SAM/Version1_6/Alignment/OptionalFields/IOPT.hs
@@ -0,0 +1,70 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE StrictData            #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.SAM.Version1_6.Alignment.OptionalFields.IOPT
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = WARNING
+--
+-- This module is considered __internal__.
+--
+-- The Package Versioning Policy __does not apply__.
+--
+-- The contents of this module may change __in any way whatsoever__
+-- and __without any warning__ between minor versions of this package.
+--
+-- Authors importing this library are expected to track development
+-- closely.
+--
+-- All credit goes to the author(s)/maintainer(s) of the
+-- [containers](https://hackage.haskell.org/package/containers) library
+-- for the above warning text.
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.SAM.Version1_6.Alignment.OptionalFields.IOPT ( -- * SAM version 1.6 alignment optional fields data type
+                                                           SAM_V1_6_Alignment_OptionalFields_IOPT(..)
+                                                         ) where
+
+import Data.ByteString (ByteString)
+import Data.Data
+import Generics.Deriving.Base
+
+-- | Custom SAM (version 1.6) @"SAM_V1_6_Alignment_OptionalFields_IOPT"@ data type.
+--
+-- See section 1.5 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data SAM_V1_6_Alignment_OptionalFields_IOPT = SAM_V1_6_Alignment_OptionalFields_IOPT
+  { sam_v1_6_alignment_optionalfields_iopt_tag   :: ByteString 
+  , sam_v1_6_alignment_optionalfields_iopt_value :: Integer
+  } deriving (Generic,Typeable)
+
+instance Eq SAM_V1_6_Alignment_OptionalFields_IOPT where
+  SAM_V1_6_Alignment_OptionalFields_IOPT sam_v1_6_alignment_optionalfields_iopt_tag1
+                                         sam_v1_6_alignment_optionalfields_iopt_value1 ==
+    SAM_V1_6_Alignment_OptionalFields_IOPT sam_v1_6_alignment_optionalfields_iopt_tag2
+                                           sam_v1_6_alignment_optionalfields_iopt_value2 =
+      sam_v1_6_alignment_optionalfields_iopt_tag1   == sam_v1_6_alignment_optionalfields_iopt_tag2 &&
+      sam_v1_6_alignment_optionalfields_iopt_value1 == sam_v1_6_alignment_optionalfields_iopt_value2
+
+instance Show SAM_V1_6_Alignment_OptionalFields_IOPT where
+  show (SAM_V1_6_Alignment_OptionalFields_IOPT tag
+                                               value
+       ) =
+    "SAM_V1_6_Alignment_OptionalFields_IOPT { "          ++
+    "sam_v1_6_alignment_optionalfields_iopt_tag = "      ++
+    (show tag)                                           ++
+    " , sam_v1_6_alignment_optionalfields_iopt_value = " ++
+    (show value)                                         ++
+    " }"
diff --git a/src/Data/SAM/Version1_6/Alignment/OptionalFields/ZOPT.hs b/src/Data/SAM/Version1_6/Alignment/OptionalFields/ZOPT.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/SAM/Version1_6/Alignment/OptionalFields/ZOPT.hs
@@ -0,0 +1,70 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE StrictData            #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.SAM.Version1_6.Alignment.OptionalFields.ZOPT
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = WARNING
+--
+-- This module is considered __internal__.
+--
+-- The Package Versioning Policy __does not apply__.
+--
+-- The contents of this module may change __in any way whatsoever__
+-- and __without any warning__ between minor versions of this package.
+--
+-- Authors importing this library are expected to track development
+-- closely.
+--
+-- All credit goes to the author(s)/maintainer(s) of the
+-- [containers](https://hackage.haskell.org/package/containers) library
+-- for the above warning text.
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.SAM.Version1_6.Alignment.OptionalFields.ZOPT ( -- * SAM version 1.6 alignment optional fields data type
+                                                           SAM_V1_6_Alignment_OptionalFields_ZOPT(..)
+                                                         ) where
+
+import Data.ByteString (ByteString)
+import Data.Data
+import Generics.Deriving.Base
+
+-- | Custom SAM (version 1.6) @"SAM_V1_6_Alignment_OptionalFields_ZOPT"@ data type.
+--
+-- See section 1.5 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+data SAM_V1_6_Alignment_OptionalFields_ZOPT = SAM_V1_6_Alignment_OptionalFields_ZOPT
+  { sam_v1_6_alignment_optionalfields_zopt_tag   :: ByteString 
+  , sam_v1_6_alignment_optionalfields_zopt_value :: ByteString
+  } deriving (Generic,Typeable)
+
+instance Eq SAM_V1_6_Alignment_OptionalFields_ZOPT where
+  SAM_V1_6_Alignment_OptionalFields_ZOPT sam_v1_6_alignment_optionalfields_zopt_tag1
+                                         sam_v1_6_alignment_optionalfields_zopt_value1 ==
+    SAM_V1_6_Alignment_OptionalFields_ZOPT sam_v1_6_alignment_optionalfields_zopt_tag2
+                                           sam_v1_6_alignment_optionalfields_zopt_value2 =
+      sam_v1_6_alignment_optionalfields_zopt_tag1   == sam_v1_6_alignment_optionalfields_zopt_tag2 &&
+      sam_v1_6_alignment_optionalfields_zopt_value1 == sam_v1_6_alignment_optionalfields_zopt_value2
+
+instance Show SAM_V1_6_Alignment_OptionalFields_ZOPT where
+  show (SAM_V1_6_Alignment_OptionalFields_ZOPT tag
+                                               value
+       ) =
+    "SAM_V1_6_Alignment_OptionalFields_ZOPT { "          ++
+    "sam_v1_6_alignment_optionalfields_zopt_tag = "      ++
+    (show tag)                                           ++
+    " , sam_v1_6_alignment_optionalfields_zopt_value = " ++
+    (show value)                                         ++
+    " }"
diff --git a/src/Data/SAM/Version1_6/Alignment/ZOPT.hs b/src/Data/SAM/Version1_6/Alignment/ZOPT.hs
deleted file mode 100644
--- a/src/Data/SAM/Version1_6/Alignment/ZOPT.hs
+++ /dev/null
@@ -1,68 +0,0 @@
-{-# LANGUAGE DeriveDataTypeable    #-}
-{-# LANGUAGE DeriveGeneric         #-}
-{-# LANGUAGE FlexibleContexts      #-}
-{-# LANGUAGE FlexibleInstances     #-}
-{-# LANGUAGE MultiParamTypeClasses #-}
-{-# LANGUAGE OverloadedStrings     #-}
-{-# LANGUAGE TypeFamilies          #-}
-
--- |
--- Module      :  Data.SAM.Version1_6.Alignment.ZOPT
--- Copyright   :  (c) Matthew Mosior 2023
--- License     :  BSD-style
--- Maintainer  :  mattm.github@gmail.com
--- Portability :  portable
---
--- = WARNING
---
--- This module is considered __internal__.
---
--- The Package Versioning Policy __does not apply__.
---
--- The contents of this module may change __in any way whatsoever__
--- and __without any warning__ between minor versions of this package.
---
--- Authors importing this library are expected to track development
--- closely.
---
--- All credit goes to the author(s)/maintainer(s) of the
--- [containers](https://hackage.haskell.org/package/containers) library
--- for the above warning text.
---
--- = Description
---
--- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
-
-module Data.SAM.Version1_6.Alignment.ZOPT ( -- * SAM version 1.6 alignment optional fields data type
-                                            SAM_V1_6_Alignment_ZOPT(..)
-                                          ) where
-
-import Data.ByteString (ByteString)
-import Data.Data
-import Generics.Deriving.Base
-
-
--- | Custom SAM (version 1.6) @"SAM_V1_6_Alignment_ZOPT"@ data type.
---
--- See section 1.5 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
-data SAM_V1_6_Alignment_ZOPT = SAM_V1_6_Alignment_ZOPT { sam_v1_6_alignment_zopt_tag   :: ByteString 
-                                                       , sam_v1_6_alignment_zopt_value :: ByteString
-                                                       }
-  deriving (Generic,Typeable)
-
-instance Eq SAM_V1_6_Alignment_ZOPT where
-  SAM_V1_6_Alignment_ZOPT sam_v1_6_alignment_zopt_tag1
-                          sam_v1_6_alignment_zopt_value1 == SAM_V1_6_Alignment_ZOPT sam_v1_6_alignment_zopt_tag2
-                                                                                    sam_v1_6_alignment_zopt_value2 = sam_v1_6_alignment_zopt_tag1   == sam_v1_6_alignment_zopt_tag2     &&
-                                                                                                                     sam_v1_6_alignment_zopt_value1  == sam_v1_6_alignment_zopt_value2
-
-instance Show SAM_V1_6_Alignment_ZOPT where
-  show (SAM_V1_6_Alignment_ZOPT tag
-                                value
-       ) =
-    "SAM_V1_6_Alignment_ZOPT { "          ++
-    "sam_v1_6_alignment_zopt_tag = "      ++
-    (show tag)                            ++
-    " , sam_v1_6_alignment_zopt_value = " ++
-    (show value)                          ++
-    " }"
diff --git a/src/Data/SAM/Version1_6/Header.hs b/src/Data/SAM/Version1_6/Header.hs
--- a/src/Data/SAM/Version1_6/Header.hs
+++ b/src/Data/SAM/Version1_6/Header.hs
@@ -5,7 +5,7 @@
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Header
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
diff --git a/src/Data/SAM/Version1_6/Header/CO.hs b/src/Data/SAM/Version1_6/Header/CO.hs
--- a/src/Data/SAM/Version1_6/Header/CO.hs
+++ b/src/Data/SAM/Version1_6/Header/CO.hs
@@ -4,11 +4,12 @@
 {-# LANGUAGE FlexibleInstances     #-}
 {-# LANGUAGE MultiParamTypeClasses #-}
 {-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE StrictData            #-}
 {-# LANGUAGE TypeFamilies          #-}
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Header.CO
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -28,12 +29,14 @@
 -- | Custom SAM (version 1.6) @"SAM_V1_6_One_Line_Comment"@ data type.
 --
 -- See section 1.3 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
-newtype SAM_V1_6_One_Line_Comment = SAM_V1_6_One_Line_Comment { sam_v1_6_one_line_comment_value :: ByteString
-                                                              }
-  deriving (Generic,Typeable)
+newtype SAM_V1_6_One_Line_Comment = SAM_V1_6_One_Line_Comment
+  { sam_v1_6_one_line_comment_value :: ByteString
+  } deriving (Generic,Typeable)
 
 instance Eq SAM_V1_6_One_Line_Comment where
-  SAM_V1_6_One_Line_Comment sam_v1_6_one_line_comment_value1 == SAM_V1_6_One_Line_Comment sam_v1_6_one_line_comment_value2 = sam_v1_6_one_line_comment_value1 == sam_v1_6_one_line_comment_value2
+  SAM_V1_6_One_Line_Comment sam_v1_6_one_line_comment_value1 ==
+    SAM_V1_6_One_Line_Comment sam_v1_6_one_line_comment_value2 =
+      sam_v1_6_one_line_comment_value1 == sam_v1_6_one_line_comment_value2
 
 instance Show SAM_V1_6_One_Line_Comment where
   show (SAM_V1_6_One_Line_Comment value) = "SAM_V1_6_One_Line_Comment { "       ++
diff --git a/src/Data/SAM/Version1_6/Header/HD.hs b/src/Data/SAM/Version1_6/Header/HD.hs
--- a/src/Data/SAM/Version1_6/Header/HD.hs
+++ b/src/Data/SAM/Version1_6/Header/HD.hs
@@ -4,11 +4,12 @@
 {-# LANGUAGE FlexibleInstances     #-}
 {-# LANGUAGE MultiParamTypeClasses #-}
 {-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE StrictData            #-}
 {-# LANGUAGE TypeFamilies          #-}
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Header.HD
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -33,24 +34,26 @@
 -- | Custom SAM (version 1.6) @"SAM_V1_6_File_Level_Metadata"@ data type.
 --
 -- See section 1.3 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
-data SAM_V1_6_File_Level_Metadata = SAM_V1_6_File_Level_Metadata { sam_v1_6_file_level_metadata_format_version     :: SAM_V1_6_File_Level_Metadata_Format_Version
-                                                                 , sam_v1_6_file_level_metadata_sorting_order      :: Maybe SAM_V1_6_File_Level_Metadata_Sorting_Order
-                                                                 , sam_v1_6_file_level_metadata_alignment_grouping :: Maybe SAM_V1_6_File_Level_Metadata_Alignment_Grouping
-                                                                 , sam_v1_6_file_level_metadata_subsorting_order   :: Maybe SAM_V1_6_File_Level_Metadata_SubSorting_Order
-                                                                 }
-   deriving (Generic,Typeable)
+data SAM_V1_6_File_Level_Metadata = SAM_V1_6_File_Level_Metadata
+  { sam_v1_6_file_level_metadata_format_version     :: SAM_V1_6_File_Level_Metadata_Format_Version
+  , sam_v1_6_file_level_metadata_sorting_order      :: Maybe SAM_V1_6_File_Level_Metadata_Sorting_Order
+  , sam_v1_6_file_level_metadata_alignment_grouping :: Maybe SAM_V1_6_File_Level_Metadata_Alignment_Grouping
+  , sam_v1_6_file_level_metadata_subsorting_order   :: Maybe SAM_V1_6_File_Level_Metadata_SubSorting_Order
+  } deriving (Generic,Typeable)
 
 instance Eq SAM_V1_6_File_Level_Metadata where
   SAM_V1_6_File_Level_Metadata sam_v1_6_file_level_metadata_format_version1
                                sam_v1_6_file_level_metadata_sorting_order1
                                sam_v1_6_file_level_metadata_alignment_grouping1
-                               sam_v1_6_file_level_metadata_subsorting_order1 == SAM_V1_6_File_Level_Metadata sam_v1_6_file_level_metadata_format_version2
-                                                                                                              sam_v1_6_file_level_metadata_sorting_order2
-                                                                                                              sam_v1_6_file_level_metadata_alignment_grouping2
-                                                                                                              sam_v1_6_file_level_metadata_subsorting_order2 = sam_v1_6_file_level_metadata_format_version1     == sam_v1_6_file_level_metadata_format_version2     &&
-                                                                                                                                                               sam_v1_6_file_level_metadata_sorting_order1      == sam_v1_6_file_level_metadata_sorting_order2      &&
-                                                                                                                                                               sam_v1_6_file_level_metadata_alignment_grouping1 == sam_v1_6_file_level_metadata_alignment_grouping2 &&
-                                                                                                                                                               sam_v1_6_file_level_metadata_subsorting_order1   == sam_v1_6_file_level_metadata_subsorting_order2
+                               sam_v1_6_file_level_metadata_subsorting_order1 ==
+    SAM_V1_6_File_Level_Metadata sam_v1_6_file_level_metadata_format_version2
+                                 sam_v1_6_file_level_metadata_sorting_order2
+                                 sam_v1_6_file_level_metadata_alignment_grouping2
+                                 sam_v1_6_file_level_metadata_subsorting_order2 =
+      sam_v1_6_file_level_metadata_format_version1     == sam_v1_6_file_level_metadata_format_version2     &&
+      sam_v1_6_file_level_metadata_sorting_order1      == sam_v1_6_file_level_metadata_sorting_order2      &&
+      sam_v1_6_file_level_metadata_alignment_grouping1 == sam_v1_6_file_level_metadata_alignment_grouping2 &&
+      sam_v1_6_file_level_metadata_subsorting_order1   == sam_v1_6_file_level_metadata_subsorting_order2
 
 instance Show SAM_V1_6_File_Level_Metadata where
   show (SAM_V1_6_File_Level_Metadata version sorting_order alignment_grouping subsorting_order) =
@@ -66,12 +69,14 @@
     " }" 
 
 -- | VN tag for @"SAM_V1_6_File_Level_Metadata"@.
-newtype SAM_V1_6_File_Level_Metadata_Format_Version = SAM_V1_6_File_Level_Metadata_Format_Version { sam_v1_6_file_level_metadata_format_version_value :: ByteString
-                                                                                                  }
-  deriving (Generic,Typeable)
+newtype SAM_V1_6_File_Level_Metadata_Format_Version = SAM_V1_6_File_Level_Metadata_Format_Version
+  { sam_v1_6_file_level_metadata_format_version_value :: ByteString
+  } deriving (Generic,Typeable)
 
 instance Eq SAM_V1_6_File_Level_Metadata_Format_Version where
-  SAM_V1_6_File_Level_Metadata_Format_Version sam_v1_6_file_level_metadata_format_version_value1 == SAM_V1_6_File_Level_Metadata_Format_Version sam_v1_6_file_level_metadata_format_version_value2 = sam_v1_6_file_level_metadata_format_version_value1 == sam_v1_6_file_level_metadata_format_version_value2
+  SAM_V1_6_File_Level_Metadata_Format_Version sam_v1_6_file_level_metadata_format_version_value1 ==
+    SAM_V1_6_File_Level_Metadata_Format_Version sam_v1_6_file_level_metadata_format_version_value2 =
+      sam_v1_6_file_level_metadata_format_version_value1 == sam_v1_6_file_level_metadata_format_version_value2
 
 instance Show SAM_V1_6_File_Level_Metadata_Format_Version where
   show (SAM_V1_6_File_Level_Metadata_Format_Version value) =
@@ -81,12 +86,14 @@
     " }"
 
 -- | SO tag for @"SAM_V1_6_File_Level_Metadata"@.
-newtype SAM_V1_6_File_Level_Metadata_Sorting_Order = SAM_V1_6_File_Level_Metadata_Sorting_Order { sam_v1_6_file_level_metadata_sorting_order_value :: ByteString
-                                                                                                }
-  deriving (Generic,Typeable)
+newtype SAM_V1_6_File_Level_Metadata_Sorting_Order = SAM_V1_6_File_Level_Metadata_Sorting_Order
+  { sam_v1_6_file_level_metadata_sorting_order_value :: ByteString
+  } deriving (Generic,Typeable)
 
 instance Eq SAM_V1_6_File_Level_Metadata_Sorting_Order where
-  SAM_V1_6_File_Level_Metadata_Sorting_Order sam_v1_6_file_level_metadata_sorting_order_value1 == SAM_V1_6_File_Level_Metadata_Sorting_Order sam_v1_6_file_level_metadata_sorting_order_value2 = sam_v1_6_file_level_metadata_sorting_order_value1 == sam_v1_6_file_level_metadata_sorting_order_value2
+  SAM_V1_6_File_Level_Metadata_Sorting_Order sam_v1_6_file_level_metadata_sorting_order_value1 ==
+    SAM_V1_6_File_Level_Metadata_Sorting_Order sam_v1_6_file_level_metadata_sorting_order_value2 =
+      sam_v1_6_file_level_metadata_sorting_order_value1 == sam_v1_6_file_level_metadata_sorting_order_value2
 
 instance Show SAM_V1_6_File_Level_Metadata_Sorting_Order where
   show (SAM_V1_6_File_Level_Metadata_Sorting_Order value) =
@@ -96,12 +103,14 @@
     " }"
 
 -- | GO tag for @"SAM_V1_6_File_Level_Metadata"@.
-newtype SAM_V1_6_File_Level_Metadata_Alignment_Grouping = SAM_V1_6_File_Level_Metadata_Alignment_Grouping { sam_v1_6_file_level_metadata_alignment_grouping_value :: ByteString
-                                                                                                          }
-  deriving (Generic,Typeable)
+newtype SAM_V1_6_File_Level_Metadata_Alignment_Grouping = SAM_V1_6_File_Level_Metadata_Alignment_Grouping
+  { sam_v1_6_file_level_metadata_alignment_grouping_value :: ByteString
+  } deriving (Generic,Typeable)
 
 instance Eq SAM_V1_6_File_Level_Metadata_Alignment_Grouping where
-  SAM_V1_6_File_Level_Metadata_Alignment_Grouping sam_v1_6_file_level_metadata_alignment_grouping_value1 == SAM_V1_6_File_Level_Metadata_Alignment_Grouping sam_v1_6_file_level_metadata_alignment_grouping_value2 = sam_v1_6_file_level_metadata_alignment_grouping_value1 == sam_v1_6_file_level_metadata_alignment_grouping_value2
+  SAM_V1_6_File_Level_Metadata_Alignment_Grouping sam_v1_6_file_level_metadata_alignment_grouping_value1 ==
+    SAM_V1_6_File_Level_Metadata_Alignment_Grouping sam_v1_6_file_level_metadata_alignment_grouping_value2 =
+      sam_v1_6_file_level_metadata_alignment_grouping_value1 == sam_v1_6_file_level_metadata_alignment_grouping_value2
 
 instance Show SAM_V1_6_File_Level_Metadata_Alignment_Grouping where
   show (SAM_V1_6_File_Level_Metadata_Alignment_Grouping value) =
@@ -111,12 +120,14 @@
     " }"
 
 -- | SS tag for @"SAM_V1_6_File_Level_Metadata"@.
-newtype SAM_V1_6_File_Level_Metadata_SubSorting_Order = SAM_V1_6_File_Level_Metadata_SubSorting_Order { sam_v1_6_file_level_metadata_subsorting_order_value :: ByteString
-                                                                                                      }
-  deriving (Generic,Typeable)
+newtype SAM_V1_6_File_Level_Metadata_SubSorting_Order = SAM_V1_6_File_Level_Metadata_SubSorting_Order
+  { sam_v1_6_file_level_metadata_subsorting_order_value :: ByteString
+  } deriving (Generic,Typeable)
 
 instance Eq SAM_V1_6_File_Level_Metadata_SubSorting_Order where
-  SAM_V1_6_File_Level_Metadata_SubSorting_Order sam_v1_6_file_level_metadata_subsorting_order_value1 == SAM_V1_6_File_Level_Metadata_SubSorting_Order sam_v1_6_file_level_metadata_subsorting_order_value2 = sam_v1_6_file_level_metadata_subsorting_order_value1 == sam_v1_6_file_level_metadata_subsorting_order_value2
+  SAM_V1_6_File_Level_Metadata_SubSorting_Order sam_v1_6_file_level_metadata_subsorting_order_value1 ==
+    SAM_V1_6_File_Level_Metadata_SubSorting_Order sam_v1_6_file_level_metadata_subsorting_order_value2 =
+      sam_v1_6_file_level_metadata_subsorting_order_value1 == sam_v1_6_file_level_metadata_subsorting_order_value2
 
 instance Show SAM_V1_6_File_Level_Metadata_SubSorting_Order where
   show (SAM_V1_6_File_Level_Metadata_SubSorting_Order value) =
diff --git a/src/Data/SAM/Version1_6/Header/PG.hs b/src/Data/SAM/Version1_6/Header/PG.hs
--- a/src/Data/SAM/Version1_6/Header/PG.hs
+++ b/src/Data/SAM/Version1_6/Header/PG.hs
@@ -4,11 +4,12 @@
 {-# LANGUAGE FlexibleInstances     #-}
 {-# LANGUAGE MultiParamTypeClasses #-}
 {-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE StrictData            #-}
 {-# LANGUAGE TypeFamilies          #-}
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Header.PG
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -35,14 +36,14 @@
 -- | Custom SAM (version 1.6) @"SAM_V1_6_Program"@ data type.
 --
 -- See section 1.3 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
-data SAM_V1_6_Program = SAM_V1_6_Program { sam_v1_6_program_record_identifier :: SAM_V1_6_Program_Record_Identifier
-                                         , sam_v1_6_program_name              :: Maybe SAM_V1_6_Program_Name
-                                         , sam_v1_6_program_command_line      :: Maybe SAM_V1_6_Program_Command_Line
-                                         , sam_v1_6_program_previous_pg_id    :: Maybe SAM_V1_6_Program_Previous_PG_ID
-                                         , sam_v1_6_program_description       :: Maybe SAM_V1_6_Program_Description
-                                         , sam_v1_6_program_version           :: Maybe SAM_V1_6_Program_Version
-                                         }
-  deriving (Generic,Typeable)
+data SAM_V1_6_Program = SAM_V1_6_Program
+  { sam_v1_6_program_record_identifier :: SAM_V1_6_Program_Record_Identifier
+  , sam_v1_6_program_name              :: Maybe SAM_V1_6_Program_Name
+  , sam_v1_6_program_command_line      :: Maybe SAM_V1_6_Program_Command_Line
+  , sam_v1_6_program_previous_pg_id    :: Maybe SAM_V1_6_Program_Previous_PG_ID
+  , sam_v1_6_program_description       :: Maybe SAM_V1_6_Program_Description
+  , sam_v1_6_program_version           :: Maybe SAM_V1_6_Program_Version
+  } deriving (Generic,Typeable)
 
 instance Eq SAM_V1_6_Program where
   SAM_V1_6_Program sam_v1_6_program_record_identifier1
@@ -50,17 +51,19 @@
                    sam_v1_6_program_command_line1
                    sam_v1_6_program_previous_pg_id1
                    sam_v1_6_program_description1
-                   sam_v1_6_program_version1 == SAM_V1_6_Program sam_v1_6_program_record_identifier2
-                                                                 sam_v1_6_program_name2
-                                                                 sam_v1_6_program_command_line2
-                                                                 sam_v1_6_program_previous_pg_id2
-                                                                 sam_v1_6_program_description2
-                                                                 sam_v1_6_program_version2 = sam_v1_6_program_record_identifier1 == sam_v1_6_program_record_identifier2 &&
-                                                                                             sam_v1_6_program_name1              == sam_v1_6_program_name2              &&
-                                                                                             sam_v1_6_program_command_line1      == sam_v1_6_program_command_line2      &&
-                                                                                             sam_v1_6_program_previous_pg_id1    == sam_v1_6_program_previous_pg_id2    &&
-                                                                                             sam_v1_6_program_description1       == sam_v1_6_program_description2       &&
-                                                                                             sam_v1_6_program_version1           == sam_v1_6_program_version2
+                   sam_v1_6_program_version1 ==
+    SAM_V1_6_Program sam_v1_6_program_record_identifier2
+                     sam_v1_6_program_name2
+                     sam_v1_6_program_command_line2
+                     sam_v1_6_program_previous_pg_id2
+                     sam_v1_6_program_description2
+                     sam_v1_6_program_version2 =
+      sam_v1_6_program_record_identifier1 == sam_v1_6_program_record_identifier2 &&
+      sam_v1_6_program_name1              == sam_v1_6_program_name2              &&
+      sam_v1_6_program_command_line1      == sam_v1_6_program_command_line2      &&
+      sam_v1_6_program_previous_pg_id1    == sam_v1_6_program_previous_pg_id2    &&
+      sam_v1_6_program_description1       == sam_v1_6_program_description2       &&
+      sam_v1_6_program_version1           == sam_v1_6_program_version2
 
 instance Show SAM_V1_6_Program where
   show (SAM_V1_6_Program record_identifier name command_line previous_pg_id description version) =
@@ -80,12 +83,14 @@
     " }"
 
 -- | ID tag for @"SAM_V1_6_Program"@.
-newtype SAM_V1_6_Program_Record_Identifier = SAM_V1_6_Program_Record_Identifier { sam_v1_6_program_record_identifier_value :: ByteString
-                                                                                }
-  deriving (Generic,Typeable)
+newtype SAM_V1_6_Program_Record_Identifier = SAM_V1_6_Program_Record_Identifier
+  { sam_v1_6_program_record_identifier_value :: ByteString
+  } deriving (Generic,Typeable)
 
 instance Eq SAM_V1_6_Program_Record_Identifier where
-  SAM_V1_6_Program_Record_Identifier sam_v1_6_program_record_identifier_value1 == SAM_V1_6_Program_Record_Identifier sam_v1_6_program_record_identifier_value2 = sam_v1_6_program_record_identifier_value1 == sam_v1_6_program_record_identifier_value2
+  SAM_V1_6_Program_Record_Identifier sam_v1_6_program_record_identifier_value1 ==
+    SAM_V1_6_Program_Record_Identifier sam_v1_6_program_record_identifier_value2 =
+      sam_v1_6_program_record_identifier_value1 == sam_v1_6_program_record_identifier_value2
 
 instance Show SAM_V1_6_Program_Record_Identifier where
   show (SAM_V1_6_Program_Record_Identifier value) =
@@ -95,12 +100,14 @@
     " }"
 
 -- | PN tag for @"SAM_V1_6_Program"@.
-newtype SAM_V1_6_Program_Name = SAM_V1_6_Program_Name { sam_v1_6_program_name_value :: ByteString
-                                                      }
-  deriving (Generic,Typeable)
+newtype SAM_V1_6_Program_Name = SAM_V1_6_Program_Name
+  { sam_v1_6_program_name_value :: ByteString
+  } deriving (Generic,Typeable)
 
 instance Eq SAM_V1_6_Program_Name where
-  SAM_V1_6_Program_Name sam_v1_6_program_name_value1 == SAM_V1_6_Program_Name sam_v1_6_program_name_value2 = sam_v1_6_program_name_value1 == sam_v1_6_program_name_value2
+  SAM_V1_6_Program_Name sam_v1_6_program_name_value1 ==
+    SAM_V1_6_Program_Name sam_v1_6_program_name_value2 =
+      sam_v1_6_program_name_value1 == sam_v1_6_program_name_value2
 
 instance Show SAM_V1_6_Program_Name where
   show (SAM_V1_6_Program_Name value) =
@@ -110,12 +117,14 @@
     " }"
 
 -- | CL tag for @"SAM_V1_6_Program"@.
-newtype SAM_V1_6_Program_Command_Line = SAM_V1_6_Program_Command_Line { sam_v1_6_program_command_line_value :: ByteString
-                                                                      }
-  deriving (Generic,Typeable)
+newtype SAM_V1_6_Program_Command_Line = SAM_V1_6_Program_Command_Line
+  { sam_v1_6_program_command_line_value :: ByteString
+  } deriving (Generic,Typeable)
 
 instance Eq SAM_V1_6_Program_Command_Line where
-  SAM_V1_6_Program_Command_Line sam_v1_6_program_command_line_value1 == SAM_V1_6_Program_Command_Line sam_v1_6_program_command_line_value2 = sam_v1_6_program_command_line_value1 == sam_v1_6_program_command_line_value2
+  SAM_V1_6_Program_Command_Line sam_v1_6_program_command_line_value1 ==
+    SAM_V1_6_Program_Command_Line sam_v1_6_program_command_line_value2 =
+      sam_v1_6_program_command_line_value1 == sam_v1_6_program_command_line_value2
 
 instance Show SAM_V1_6_Program_Command_Line where
   show (SAM_V1_6_Program_Command_Line value) =
@@ -125,12 +134,14 @@
     " }"
 
 -- | PP tag for @"SAM_V1_6_Program"@.
-newtype SAM_V1_6_Program_Previous_PG_ID = SAM_V1_6_Program_Previous_PG_ID { sam_v1_6_program_previous_pg_id_value :: ByteString
-                                                                          }
-  deriving (Generic,Typeable)
+newtype SAM_V1_6_Program_Previous_PG_ID = SAM_V1_6_Program_Previous_PG_ID
+  { sam_v1_6_program_previous_pg_id_value :: ByteString
+  } deriving (Generic,Typeable)
 
 instance Eq SAM_V1_6_Program_Previous_PG_ID where
-  SAM_V1_6_Program_Previous_PG_ID sam_v1_6_program_previous_pg_id_value1 == SAM_V1_6_Program_Previous_PG_ID sam_v1_6_program_previous_pg_id_value2 = sam_v1_6_program_previous_pg_id_value1 == sam_v1_6_program_previous_pg_id_value2
+  SAM_V1_6_Program_Previous_PG_ID sam_v1_6_program_previous_pg_id_value1 ==
+    SAM_V1_6_Program_Previous_PG_ID sam_v1_6_program_previous_pg_id_value2 =
+      sam_v1_6_program_previous_pg_id_value1 == sam_v1_6_program_previous_pg_id_value2
 
 instance Show SAM_V1_6_Program_Previous_PG_ID where
   show (SAM_V1_6_Program_Previous_PG_ID value) =
@@ -140,12 +151,14 @@
     " }"
 
 -- | DS tag for @"SAM_V1_6_Program"@.
-newtype SAM_V1_6_Program_Description = SAM_V1_6_Program_Description { sam_v1_6_program_description_value :: ByteString
-                                                                    }
-  deriving (Generic,Typeable)
+newtype SAM_V1_6_Program_Description = SAM_V1_6_Program_Description
+  { sam_v1_6_program_description_value :: ByteString
+  } deriving (Generic,Typeable)
 
 instance Eq SAM_V1_6_Program_Description where
-  SAM_V1_6_Program_Description sam_v1_6_program_description_value1 == SAM_V1_6_Program_Description sam_v1_6_program_description_value2 = sam_v1_6_program_description_value1 == sam_v1_6_program_description_value2
+  SAM_V1_6_Program_Description sam_v1_6_program_description_value1 ==
+    SAM_V1_6_Program_Description sam_v1_6_program_description_value2 =
+      sam_v1_6_program_description_value1 == sam_v1_6_program_description_value2
 
 instance Show SAM_V1_6_Program_Description where
   show (SAM_V1_6_Program_Description value) =
@@ -155,12 +168,14 @@
     " }"
 
 -- | VN tag for @"SAM_V1_6_Program"@.
-newtype SAM_V1_6_Program_Version = SAM_V1_6_Program_Version { sam_v1_6_program_version_value :: ByteString
-                                                            }
-  deriving (Generic,Typeable)
+newtype SAM_V1_6_Program_Version = SAM_V1_6_Program_Version
+  { sam_v1_6_program_version_value :: ByteString
+  } deriving (Generic,Typeable)
 
 instance Eq SAM_V1_6_Program_Version where
-  SAM_V1_6_Program_Version sam_v1_6_program_version_value1 == SAM_V1_6_Program_Version sam_v1_6_program_version_value2 = sam_v1_6_program_version_value1 == sam_v1_6_program_version_value2
+  SAM_V1_6_Program_Version sam_v1_6_program_version_value1 ==
+    SAM_V1_6_Program_Version sam_v1_6_program_version_value2 =
+      sam_v1_6_program_version_value1 == sam_v1_6_program_version_value2
 
 instance Show SAM_V1_6_Program_Version where
   show (SAM_V1_6_Program_Version value) =
diff --git a/src/Data/SAM/Version1_6/Header/RG.hs b/src/Data/SAM/Version1_6/Header/RG.hs
--- a/src/Data/SAM/Version1_6/Header/RG.hs
+++ b/src/Data/SAM/Version1_6/Header/RG.hs
@@ -4,11 +4,12 @@
 {-# LANGUAGE FlexibleInstances     #-}
 {-# LANGUAGE MultiParamTypeClasses #-}
 {-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE StrictData            #-}
 {-# LANGUAGE TypeFamilies          #-}
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Header.RG
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -43,22 +44,22 @@
 -- | Custom SAM (version 1.6) @"SAM_V1_6_Read_Group"@ data type.
 --
 -- See section 1.3 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
-data SAM_V1_6_Read_Group = SAM_V1_6_Read_Group { sam_v1_6_read_group_identifier                   :: SAM_V1_6_Read_Group_Identifier
-                                               , sam_v1_6_read_group_barcode_sequence             :: Maybe SAM_V1_6_Read_Group_Barcode_Sequence
-                                               , sam_v1_6_read_group_sequencing_center            :: Maybe SAM_V1_6_Read_Group_Sequencing_Center
-                                               , sam_v1_6_read_group_description                  :: Maybe SAM_V1_6_Read_Group_Description
-                                               , sam_v1_6_read_group_run_date                     :: Maybe SAM_V1_6_Read_Group_Run_Date
-                                               , sam_v1_6_read_group_flow_order                   :: Maybe SAM_V1_6_Read_Group_Flow_Order
-                                               , sam_v1_6_read_group_key_sequence                 :: Maybe SAM_V1_6_Read_Group_Key_Sequence
-                                               , sam_v1_6_read_group_library                      :: Maybe SAM_V1_6_Read_Group_Library
-                                               , sam_v1_6_read_group_programs                     :: Maybe SAM_V1_6_Read_Group_Programs
-                                               , sam_v1_6_read_group_predicted_median_insert_size :: Maybe SAM_V1_6_Read_Group_Predicted_Median_Insert_Size
-                                               , sam_v1_6_read_group_platform                     :: Maybe SAM_V1_6_Read_Group_Platform
-                                               , sam_v1_6_read_group_platform_model               :: Maybe SAM_V1_6_Read_Group_Platform_Model
-                                               , sam_v1_6_read_group_platform_unit                :: Maybe SAM_V1_6_Read_Group_Platform_Unit
-                                               , sam_v1_6_read_group_sample                       :: Maybe SAM_V1_6_Read_Group_Sample
-                                               }
-  deriving (Generic,Typeable)
+data SAM_V1_6_Read_Group = SAM_V1_6_Read_Group
+  { sam_v1_6_read_group_identifier                   :: SAM_V1_6_Read_Group_Identifier
+  , sam_v1_6_read_group_barcode_sequence             :: Maybe SAM_V1_6_Read_Group_Barcode_Sequence
+  , sam_v1_6_read_group_sequencing_center            :: Maybe SAM_V1_6_Read_Group_Sequencing_Center
+  , sam_v1_6_read_group_description                  :: Maybe SAM_V1_6_Read_Group_Description
+  , sam_v1_6_read_group_run_date                     :: Maybe SAM_V1_6_Read_Group_Run_Date
+  , sam_v1_6_read_group_flow_order                   :: Maybe SAM_V1_6_Read_Group_Flow_Order
+  , sam_v1_6_read_group_key_sequence                 :: Maybe SAM_V1_6_Read_Group_Key_Sequence
+  , sam_v1_6_read_group_library                      :: Maybe SAM_V1_6_Read_Group_Library
+  , sam_v1_6_read_group_programs                     :: Maybe SAM_V1_6_Read_Group_Programs
+  , sam_v1_6_read_group_predicted_median_insert_size :: Maybe SAM_V1_6_Read_Group_Predicted_Median_Insert_Size
+  , sam_v1_6_read_group_platform                     :: Maybe SAM_V1_6_Read_Group_Platform
+  , sam_v1_6_read_group_platform_model               :: Maybe SAM_V1_6_Read_Group_Platform_Model
+  , sam_v1_6_read_group_platform_unit                :: Maybe SAM_V1_6_Read_Group_Platform_Unit
+  , sam_v1_6_read_group_sample                       :: Maybe SAM_V1_6_Read_Group_Sample
+  } deriving (Generic,Typeable)
 
 instance Eq SAM_V1_6_Read_Group where
   SAM_V1_6_Read_Group sam_v1_6_read_group_identifier1
@@ -74,33 +75,35 @@
                       sam_v1_6_read_group_platform1
                       sam_v1_6_read_group_platform_model1
                       sam_v1_6_read_group_platform_unit1
-                      sam_v1_6_read_group_sample1 == SAM_V1_6_Read_Group sam_v1_6_read_group_identifier2
-                                                                         sam_v1_6_read_group_barcode_sequence2
-                                                                         sam_v1_6_read_group_sequencing_center2
-                                                                         sam_v1_6_read_group_description2
-                                                                         sam_v1_6_read_group_run_date2
-                                                                         sam_v1_6_read_group_flow_order2
-                                                                         sam_v1_6_read_group_key_sequence2
-                                                                         sam_v1_6_read_group_library2
-                                                                         sam_v1_6_read_group_programs2
-                                                                         sam_v1_6_read_group_predicted_median_insert_size2
-                                                                         sam_v1_6_read_group_platform2
-                                                                         sam_v1_6_read_group_platform_model2
-                                                                         sam_v1_6_read_group_platform_unit2
-                                                                         sam_v1_6_read_group_sample2 = sam_v1_6_read_group_identifier1                    == sam_v1_6_read_group_identifier2                    &&
-                                                                                                       sam_v1_6_read_group_barcode_sequence1             == sam_v1_6_read_group_barcode_sequence2             &&
-                                                                                                       sam_v1_6_read_group_sequencing_center1            == sam_v1_6_read_group_sequencing_center2            &&
-                                                                                                       sam_v1_6_read_group_description1                  == sam_v1_6_read_group_description2                  &&
-                                                                                                       sam_v1_6_read_group_run_date1                     == sam_v1_6_read_group_run_date2                     &&
-                                                                                                       sam_v1_6_read_group_flow_order1                   == sam_v1_6_read_group_flow_order2                   &&
-                                                                                                       sam_v1_6_read_group_key_sequence1                 == sam_v1_6_read_group_key_sequence2                 &&
-                                                                                                       sam_v1_6_read_group_library1                      == sam_v1_6_read_group_library2                      &&
-                                                                                                       sam_v1_6_read_group_programs1                     == sam_v1_6_read_group_programs2                     &&
-                                                                                                       sam_v1_6_read_group_predicted_median_insert_size1 == sam_v1_6_read_group_predicted_median_insert_size2 &&
-                                                                                                       sam_v1_6_read_group_platform1                     == sam_v1_6_read_group_platform2                     &&
-                                                                                                       sam_v1_6_read_group_platform_model1               == sam_v1_6_read_group_platform_model2               &&
-                                                                                                       sam_v1_6_read_group_platform_unit1                == sam_v1_6_read_group_platform_unit2                &&
-                                                                                                       sam_v1_6_read_group_sample1                       == sam_v1_6_read_group_sample2
+                      sam_v1_6_read_group_sample1 ==
+    SAM_V1_6_Read_Group sam_v1_6_read_group_identifier2
+                        sam_v1_6_read_group_barcode_sequence2
+                        sam_v1_6_read_group_sequencing_center2
+                        sam_v1_6_read_group_description2
+                        sam_v1_6_read_group_run_date2
+                        sam_v1_6_read_group_flow_order2
+                        sam_v1_6_read_group_key_sequence2
+                        sam_v1_6_read_group_library2
+                        sam_v1_6_read_group_programs2
+                        sam_v1_6_read_group_predicted_median_insert_size2
+                        sam_v1_6_read_group_platform2
+                        sam_v1_6_read_group_platform_model2
+                        sam_v1_6_read_group_platform_unit2
+                        sam_v1_6_read_group_sample2 =
+      sam_v1_6_read_group_identifier1                   == sam_v1_6_read_group_identifier2                   &&
+      sam_v1_6_read_group_barcode_sequence1             == sam_v1_6_read_group_barcode_sequence2             &&
+      sam_v1_6_read_group_sequencing_center1            == sam_v1_6_read_group_sequencing_center2            &&
+      sam_v1_6_read_group_description1                  == sam_v1_6_read_group_description2                  &&
+      sam_v1_6_read_group_run_date1                     == sam_v1_6_read_group_run_date2                     &&
+      sam_v1_6_read_group_flow_order1                   == sam_v1_6_read_group_flow_order2                   &&
+      sam_v1_6_read_group_key_sequence1                 == sam_v1_6_read_group_key_sequence2                 &&
+      sam_v1_6_read_group_library1                      == sam_v1_6_read_group_library2                      &&
+      sam_v1_6_read_group_programs1                     == sam_v1_6_read_group_programs2                     &&
+      sam_v1_6_read_group_predicted_median_insert_size1 == sam_v1_6_read_group_predicted_median_insert_size2 &&
+      sam_v1_6_read_group_platform1                     == sam_v1_6_read_group_platform2                     &&
+      sam_v1_6_read_group_platform_model1               == sam_v1_6_read_group_platform_model2               &&
+      sam_v1_6_read_group_platform_unit1                == sam_v1_6_read_group_platform_unit2                &&
+      sam_v1_6_read_group_sample1                       == sam_v1_6_read_group_sample2
 
 instance Show SAM_V1_6_Read_Group where
   show (SAM_V1_6_Read_Group group_identifier
@@ -150,12 +153,14 @@
     " }"
 
 -- | ID tag for @"SAM_V1_6_Read_Group"@.
-newtype SAM_V1_6_Read_Group_Identifier = SAM_V1_6_Read_Group_Identifier { sam_v1_6_read_group_identifier_value :: ByteString
-                                                                        }
-  deriving (Generic,Typeable)
+newtype SAM_V1_6_Read_Group_Identifier = SAM_V1_6_Read_Group_Identifier
+  { sam_v1_6_read_group_identifier_value :: ByteString
+  } deriving (Generic,Typeable)
 
 instance Eq SAM_V1_6_Read_Group_Identifier where
-  SAM_V1_6_Read_Group_Identifier sam_v1_6_read_group_identifier_value1 == SAM_V1_6_Read_Group_Identifier sam_v1_6_read_group_identifier_value2 = sam_v1_6_read_group_identifier_value1 == sam_v1_6_read_group_identifier_value2
+  SAM_V1_6_Read_Group_Identifier sam_v1_6_read_group_identifier_value1 ==
+    SAM_V1_6_Read_Group_Identifier sam_v1_6_read_group_identifier_value2 =
+      sam_v1_6_read_group_identifier_value1 == sam_v1_6_read_group_identifier_value2
 
 instance Show SAM_V1_6_Read_Group_Identifier where
   show (SAM_V1_6_Read_Group_Identifier value) =
@@ -165,12 +170,14 @@
     " }"
 
 -- | BC tag for @"SAM_V1_6_Read_Group"@.
-newtype SAM_V1_6_Read_Group_Barcode_Sequence = SAM_V1_6_Read_Group_Barcode_Sequence { sam_v1_6_read_group_barcode_sequence_value :: ByteString
-                                                                                    }
-  deriving (Generic,Typeable)
+newtype SAM_V1_6_Read_Group_Barcode_Sequence = SAM_V1_6_Read_Group_Barcode_Sequence
+  { sam_v1_6_read_group_barcode_sequence_value :: ByteString
+  } deriving (Generic,Typeable)
 
 instance Eq SAM_V1_6_Read_Group_Barcode_Sequence where
-  SAM_V1_6_Read_Group_Barcode_Sequence sam_v1_6_read_group_barcode_sequence_value1 == SAM_V1_6_Read_Group_Barcode_Sequence sam_v1_6_read_group_barcode_sequence_value2 = sam_v1_6_read_group_barcode_sequence_value1 == sam_v1_6_read_group_barcode_sequence_value2
+  SAM_V1_6_Read_Group_Barcode_Sequence sam_v1_6_read_group_barcode_sequence_value1 ==
+    SAM_V1_6_Read_Group_Barcode_Sequence sam_v1_6_read_group_barcode_sequence_value2 =
+      sam_v1_6_read_group_barcode_sequence_value1 == sam_v1_6_read_group_barcode_sequence_value2
 
 instance Show SAM_V1_6_Read_Group_Barcode_Sequence where
   show (SAM_V1_6_Read_Group_Barcode_Sequence value) =
@@ -180,12 +187,14 @@
     " }"
 
 -- | CN tag for @"SAM_V1_6_Read_Group"@.
-newtype SAM_V1_6_Read_Group_Sequencing_Center = SAM_V1_6_Read_Group_Sequencing_Center { sam_v1_6_read_group_sequencing_center_value :: ByteString
-                                                                                      }
-  deriving (Generic,Typeable)
+newtype SAM_V1_6_Read_Group_Sequencing_Center = SAM_V1_6_Read_Group_Sequencing_Center
+  { sam_v1_6_read_group_sequencing_center_value :: ByteString
+  } deriving (Generic,Typeable)
 
 instance Eq SAM_V1_6_Read_Group_Sequencing_Center where
-  SAM_V1_6_Read_Group_Sequencing_Center sam_v1_6_read_group_sequencing_center_value1 == SAM_V1_6_Read_Group_Sequencing_Center sam_v1_6_read_group_sequencing_center_value2 = sam_v1_6_read_group_sequencing_center_value1 == sam_v1_6_read_group_sequencing_center_value2
+  SAM_V1_6_Read_Group_Sequencing_Center sam_v1_6_read_group_sequencing_center_value1 ==
+    SAM_V1_6_Read_Group_Sequencing_Center sam_v1_6_read_group_sequencing_center_value2 =
+      sam_v1_6_read_group_sequencing_center_value1 == sam_v1_6_read_group_sequencing_center_value2
 
 instance Show SAM_V1_6_Read_Group_Sequencing_Center where
   show (SAM_V1_6_Read_Group_Sequencing_Center value) =
@@ -195,12 +204,14 @@
     " }"
 
 -- | DS tag for @"SAM_V1_6_Read_Group"@.
-newtype SAM_V1_6_Read_Group_Description = SAM_V1_6_Read_Group_Description { sam_v1_6_read_group_description_value :: ByteString
-                                                                          }
-  deriving (Generic,Typeable)
+newtype SAM_V1_6_Read_Group_Description = SAM_V1_6_Read_Group_Description
+  { sam_v1_6_read_group_description_value :: ByteString
+  } deriving (Generic,Typeable)
 
 instance Eq SAM_V1_6_Read_Group_Description where
-  SAM_V1_6_Read_Group_Description sam_v1_6_read_group_description_value1 == SAM_V1_6_Read_Group_Description sam_v1_6_read_group_description_value2 = sam_v1_6_read_group_description_value1 == sam_v1_6_read_group_description_value2
+  SAM_V1_6_Read_Group_Description sam_v1_6_read_group_description_value1 ==
+    SAM_V1_6_Read_Group_Description sam_v1_6_read_group_description_value2 =
+      sam_v1_6_read_group_description_value1 == sam_v1_6_read_group_description_value2
 
 instance Show SAM_V1_6_Read_Group_Description where
   show (SAM_V1_6_Read_Group_Description value) =
@@ -210,12 +221,14 @@
     " }"
 
 -- | DT tag for @"SAM_V1_6_Read_Group"@.
-newtype SAM_V1_6_Read_Group_Run_Date = SAM_V1_6_Read_Group_Run_Date { sam_v1_6_read_group_run_date_value :: ByteString
-                                                                    }
-  deriving (Generic,Typeable)
+newtype SAM_V1_6_Read_Group_Run_Date = SAM_V1_6_Read_Group_Run_Date
+  { sam_v1_6_read_group_run_date_value :: ByteString
+  } deriving (Generic,Typeable)
 
 instance Eq SAM_V1_6_Read_Group_Run_Date where
-  SAM_V1_6_Read_Group_Run_Date sam_v1_6_read_group_run_date_value1 == SAM_V1_6_Read_Group_Run_Date sam_v1_6_read_group_run_date_value2 = sam_v1_6_read_group_run_date_value1 == sam_v1_6_read_group_run_date_value2
+  SAM_V1_6_Read_Group_Run_Date sam_v1_6_read_group_run_date_value1 ==
+    SAM_V1_6_Read_Group_Run_Date sam_v1_6_read_group_run_date_value2 =
+      sam_v1_6_read_group_run_date_value1 == sam_v1_6_read_group_run_date_value2
 
 instance Show SAM_V1_6_Read_Group_Run_Date where
   show (SAM_V1_6_Read_Group_Run_Date value) =
@@ -225,12 +238,14 @@
     " }"
 
 -- | FO tag for @"SAM_V1_6_Read_Group"@.
-newtype SAM_V1_6_Read_Group_Flow_Order = SAM_V1_6_Read_Group_Flow_Order { sam_v1_6_read_group_flow_order_value :: ByteString
-                                                                        }
-  deriving (Generic,Typeable)
+newtype SAM_V1_6_Read_Group_Flow_Order = SAM_V1_6_Read_Group_Flow_Order
+  { sam_v1_6_read_group_flow_order_value :: ByteString
+  } deriving (Generic,Typeable)
 
 instance Eq SAM_V1_6_Read_Group_Flow_Order where
-  SAM_V1_6_Read_Group_Flow_Order sam_v1_6_one_line_comment_value1 == SAM_V1_6_Read_Group_Flow_Order sam_v1_6_read_group_flow_order_value2 = sam_v1_6_one_line_comment_value1 == sam_v1_6_read_group_flow_order_value2
+  SAM_V1_6_Read_Group_Flow_Order sam_v1_6_one_line_comment_value1 ==
+    SAM_V1_6_Read_Group_Flow_Order sam_v1_6_read_group_flow_order_value2 =
+      sam_v1_6_one_line_comment_value1 == sam_v1_6_read_group_flow_order_value2
 
 instance Show SAM_V1_6_Read_Group_Flow_Order where
   show (SAM_V1_6_Read_Group_Flow_Order value) =
@@ -240,12 +255,14 @@
     " }"
 
 -- | KS tag for @"SAM_V1_6_Read_Group"@.
-newtype SAM_V1_6_Read_Group_Key_Sequence = SAM_V1_6_Read_Group_Key_Sequence { sam_v1_6_read_group_key_sequence_value :: ByteString
-                                                                            }
-  deriving (Generic,Typeable)
+newtype SAM_V1_6_Read_Group_Key_Sequence = SAM_V1_6_Read_Group_Key_Sequence
+  { sam_v1_6_read_group_key_sequence_value :: ByteString
+  } deriving (Generic,Typeable)
 
 instance Eq SAM_V1_6_Read_Group_Key_Sequence where
-  SAM_V1_6_Read_Group_Key_Sequence sam_v1_6_read_group_key_sequence_value1 == SAM_V1_6_Read_Group_Key_Sequence sam_v1_6_read_group_key_sequence_value2 = sam_v1_6_read_group_key_sequence_value1 == sam_v1_6_read_group_key_sequence_value2
+  SAM_V1_6_Read_Group_Key_Sequence sam_v1_6_read_group_key_sequence_value1 ==
+    SAM_V1_6_Read_Group_Key_Sequence sam_v1_6_read_group_key_sequence_value2 =
+      sam_v1_6_read_group_key_sequence_value1 == sam_v1_6_read_group_key_sequence_value2
 
 instance Show SAM_V1_6_Read_Group_Key_Sequence where
   show (SAM_V1_6_Read_Group_Key_Sequence value) =
@@ -255,12 +272,14 @@
     " }"
 
 -- | LB tag for @"SAM_V1_6_Read_Group"@.
-newtype SAM_V1_6_Read_Group_Library = SAM_V1_6_Read_Group_Library { sam_v1_6_read_group_library_value :: ByteString
-                                                                  }
-  deriving (Generic,Typeable)
+newtype SAM_V1_6_Read_Group_Library = SAM_V1_6_Read_Group_Library
+  { sam_v1_6_read_group_library_value :: ByteString
+  } deriving (Generic,Typeable)
 
 instance Eq SAM_V1_6_Read_Group_Library where
-  SAM_V1_6_Read_Group_Library sam_v1_6_read_group_library_value1 == SAM_V1_6_Read_Group_Library sam_v1_6_read_group_library_value2 = sam_v1_6_read_group_library_value1 == sam_v1_6_read_group_library_value2
+  SAM_V1_6_Read_Group_Library sam_v1_6_read_group_library_value1 ==
+    SAM_V1_6_Read_Group_Library sam_v1_6_read_group_library_value2 =
+      sam_v1_6_read_group_library_value1 == sam_v1_6_read_group_library_value2
 
 instance Show SAM_V1_6_Read_Group_Library where
   show (SAM_V1_6_Read_Group_Library value) =
@@ -270,12 +289,14 @@
     " }"
 
 -- | PG tag for @"SAM_V1_6_Read_Group"@.
-newtype SAM_V1_6_Read_Group_Programs = SAM_V1_6_Read_Group_Programs { sam_v1_6_read_group_programs_value :: ByteString
-                                                                    }
-  deriving (Generic,Typeable)
+newtype SAM_V1_6_Read_Group_Programs = SAM_V1_6_Read_Group_Programs
+  { sam_v1_6_read_group_programs_value :: ByteString
+  } deriving (Generic,Typeable)
 
 instance Eq SAM_V1_6_Read_Group_Programs where
-  SAM_V1_6_Read_Group_Programs sam_v1_6_read_group_programs_value1 == SAM_V1_6_Read_Group_Programs sam_v1_6_read_group_programs_value2 = sam_v1_6_read_group_programs_value1 == sam_v1_6_read_group_programs_value2
+  SAM_V1_6_Read_Group_Programs sam_v1_6_read_group_programs_value1 ==
+    SAM_V1_6_Read_Group_Programs sam_v1_6_read_group_programs_value2 =
+      sam_v1_6_read_group_programs_value1 == sam_v1_6_read_group_programs_value2
 
 instance Show SAM_V1_6_Read_Group_Programs where
   show (SAM_V1_6_Read_Group_Programs value) =
@@ -285,12 +306,14 @@
     " }"
 
 -- | PI tag for @"SAM_V1_6_Read_Group"@.
-newtype SAM_V1_6_Read_Group_Predicted_Median_Insert_Size = SAM_V1_6_Read_Group_Predicted_Median_Insert_Size { sam_v1_6_read_group_predicted_median_insert_size_value :: ByteString
-                                                                                                            }
-  deriving (Generic,Typeable)
+newtype SAM_V1_6_Read_Group_Predicted_Median_Insert_Size = SAM_V1_6_Read_Group_Predicted_Median_Insert_Size
+  { sam_v1_6_read_group_predicted_median_insert_size_value :: ByteString
+  } deriving (Generic,Typeable)
 
 instance Eq SAM_V1_6_Read_Group_Predicted_Median_Insert_Size where
-  SAM_V1_6_Read_Group_Predicted_Median_Insert_Size sam_v1_6_read_group_predicted_median_insert_size_value1 == SAM_V1_6_Read_Group_Predicted_Median_Insert_Size sam_v1_6_read_group_predicted_median_insert_size_value2 = sam_v1_6_read_group_predicted_median_insert_size_value1 == sam_v1_6_read_group_predicted_median_insert_size_value2
+  SAM_V1_6_Read_Group_Predicted_Median_Insert_Size sam_v1_6_read_group_predicted_median_insert_size_value1 ==
+    SAM_V1_6_Read_Group_Predicted_Median_Insert_Size sam_v1_6_read_group_predicted_median_insert_size_value2 =
+      sam_v1_6_read_group_predicted_median_insert_size_value1 == sam_v1_6_read_group_predicted_median_insert_size_value2
 
 instance Show SAM_V1_6_Read_Group_Predicted_Median_Insert_Size where
   show (SAM_V1_6_Read_Group_Predicted_Median_Insert_Size value) =
@@ -300,12 +323,14 @@
     " }"
 
 -- | PL tag for @"SAM_V1_6_Read_Group"@.
-newtype SAM_V1_6_Read_Group_Platform = SAM_V1_6_Read_Group_Platform { sam_v1_6_read_group_platform_value :: ByteString
-                                                                    }
-  deriving (Generic,Typeable)
+newtype SAM_V1_6_Read_Group_Platform = SAM_V1_6_Read_Group_Platform
+  { sam_v1_6_read_group_platform_value :: ByteString
+  } deriving (Generic,Typeable)
 
 instance Eq SAM_V1_6_Read_Group_Platform where
-  SAM_V1_6_Read_Group_Platform sam_v1_6_read_group_platform_value1 == SAM_V1_6_Read_Group_Platform sam_v1_6_read_group_platform_value2 = sam_v1_6_read_group_platform_value1 == sam_v1_6_read_group_platform_value2
+  SAM_V1_6_Read_Group_Platform sam_v1_6_read_group_platform_value1 ==
+    SAM_V1_6_Read_Group_Platform sam_v1_6_read_group_platform_value2 =
+      sam_v1_6_read_group_platform_value1 == sam_v1_6_read_group_platform_value2
 
 instance Show SAM_V1_6_Read_Group_Platform where
   show (SAM_V1_6_Read_Group_Platform value) =
@@ -315,12 +340,14 @@
     " }"
 
 -- | PM tag for @"SAM_V1_6_Read_Group"@.
-newtype SAM_V1_6_Read_Group_Platform_Model = SAM_V1_6_Read_Group_Platform_Model { sam_v1_6_read_group_platform_model_value :: ByteString
-                                                                                }
-  deriving (Generic,Typeable)
+newtype SAM_V1_6_Read_Group_Platform_Model = SAM_V1_6_Read_Group_Platform_Model
+  { sam_v1_6_read_group_platform_model_value :: ByteString
+  } deriving (Generic,Typeable)
 
 instance Eq SAM_V1_6_Read_Group_Platform_Model where
-  SAM_V1_6_Read_Group_Platform_Model sam_v1_6_read_group_platform_model_value1 == SAM_V1_6_Read_Group_Platform_Model sam_v1_6_read_group_platform_model_value2 = sam_v1_6_read_group_platform_model_value1 == sam_v1_6_read_group_platform_model_value2
+  SAM_V1_6_Read_Group_Platform_Model sam_v1_6_read_group_platform_model_value1 ==
+    SAM_V1_6_Read_Group_Platform_Model sam_v1_6_read_group_platform_model_value2 =
+      sam_v1_6_read_group_platform_model_value1 == sam_v1_6_read_group_platform_model_value2
 
 instance Show SAM_V1_6_Read_Group_Platform_Model where
   show (SAM_V1_6_Read_Group_Platform_Model value) =
@@ -330,12 +357,14 @@
     " }"
 
 -- | PU tag for @"SAM_V1_6_Read_Group"@.
-newtype SAM_V1_6_Read_Group_Platform_Unit = SAM_V1_6_Read_Group_Platform_Unit { sam_v1_6_read_group_platform_unit_value :: ByteString
-                                                                              }
-  deriving (Generic,Typeable)
+newtype SAM_V1_6_Read_Group_Platform_Unit = SAM_V1_6_Read_Group_Platform_Unit
+  { sam_v1_6_read_group_platform_unit_value :: ByteString
+  } deriving (Generic,Typeable)
 
 instance Eq SAM_V1_6_Read_Group_Platform_Unit where
-  SAM_V1_6_Read_Group_Platform_Unit sam_v1_6_read_group_platform_unit_value1 == SAM_V1_6_Read_Group_Platform_Unit sam_v1_6_read_group_platform_unit_value2 = sam_v1_6_read_group_platform_unit_value1 == sam_v1_6_read_group_platform_unit_value2
+  SAM_V1_6_Read_Group_Platform_Unit sam_v1_6_read_group_platform_unit_value1 ==
+    SAM_V1_6_Read_Group_Platform_Unit sam_v1_6_read_group_platform_unit_value2 =
+      sam_v1_6_read_group_platform_unit_value1 == sam_v1_6_read_group_platform_unit_value2
 
 instance Show SAM_V1_6_Read_Group_Platform_Unit where
   show (SAM_V1_6_Read_Group_Platform_Unit value) =
@@ -345,12 +374,14 @@
     " }"
 
 -- | SM tag for @"SAM_V1_6_Read_Group"@.
-newtype SAM_V1_6_Read_Group_Sample = SAM_V1_6_Read_Group_Sample { sam_v1_6_read_group_sample_value :: ByteString
-                                                                }
-  deriving (Generic,Typeable)
+newtype SAM_V1_6_Read_Group_Sample = SAM_V1_6_Read_Group_Sample
+  { sam_v1_6_read_group_sample_value :: ByteString
+  } deriving (Generic,Typeable)
 
 instance Eq SAM_V1_6_Read_Group_Sample where
-  SAM_V1_6_Read_Group_Sample sam_v1_6_read_group_sample_value1 == SAM_V1_6_Read_Group_Sample sam_v1_6_read_group_sample_value2 = sam_v1_6_read_group_sample_value1 == sam_v1_6_read_group_sample_value2
+  SAM_V1_6_Read_Group_Sample sam_v1_6_read_group_sample_value1 ==
+    SAM_V1_6_Read_Group_Sample sam_v1_6_read_group_sample_value2 =
+      sam_v1_6_read_group_sample_value1 == sam_v1_6_read_group_sample_value2
 
 instance Show SAM_V1_6_Read_Group_Sample where
   show (SAM_V1_6_Read_Group_Sample value) =
diff --git a/src/Data/SAM/Version1_6/Header/SQ.hs b/src/Data/SAM/Version1_6/Header/SQ.hs
--- a/src/Data/SAM/Version1_6/Header/SQ.hs
+++ b/src/Data/SAM/Version1_6/Header/SQ.hs
@@ -4,11 +4,12 @@
 {-# LANGUAGE FlexibleInstances     #-}
 {-# LANGUAGE MultiParamTypeClasses #-}
 {-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE StrictData            #-}
 {-# LANGUAGE TypeFamilies          #-}
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Header.SQ
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -39,18 +40,18 @@
 -- | Custom SAM (version 1.6) @"SAM_V1_6_Reference_Sequence_Dictionary"@ data type.
 --
 -- See section 1.3 of the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
-data SAM_V1_6_Reference_Sequence_Dictionary = SAM_V1_6_Reference_Sequence_Dictionary { sam_v1_6_reference_sequence_dictionary_reference_sequence_name                        :: SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Name
-                                                                                     , sam_v1_6_reference_sequence_dictionary_reference_sequence_length                      :: SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Length
-                                                                                     , sam_v1_6_reference_sequence_dictionary_alternative_locus                              :: Maybe SAM_V1_6_Reference_Sequence_Dictionary_Alternative_Locus
-                                                                                     , sam_v1_6_reference_sequence_dictionary_alternative_reference_sequence_names           :: Maybe SAM_V1_6_Reference_Sequence_Dictionary_Alternative_Reference_Sequence_Names
-                                                                                     , sam_v1_6_reference_sequence_dictionary_genome_assembly_identifier                     :: Maybe SAM_V1_6_Reference_Sequence_Dictionary_Genome_Assembly_Identifier
-                                                                                     , sam_v1_6_reference_sequence_dictionary_description                                    :: Maybe SAM_V1_6_Reference_Sequence_Dictionary_Description
-                                                                                     , sam_v1_6_reference_sequence_dictionary_md5_checksum                                   :: Maybe SAM_V1_6_Reference_Sequence_Dictionary_MD5_Checksum
-                                                                                     , sam_v1_6_reference_sequence_dictionary_species                                        :: Maybe SAM_V1_6_Reference_Sequence_Dictionary_Species
-                                                                                     , sam_v1_6_reference_sequence_dictionary_molecule_topology                              :: Maybe SAM_V1_6_Reference_Sequence_Dictionary_Molecule_Topology                                       
-                                                                                     , sam_v1_6_reference_sequence_dictionary_uri                                            :: Maybe SAM_V1_6_Reference_Sequence_Dictionary_URI 
-                                                                                     }
-  deriving (Generic,Typeable)
+data SAM_V1_6_Reference_Sequence_Dictionary = SAM_V1_6_Reference_Sequence_Dictionary
+  { sam_v1_6_reference_sequence_dictionary_reference_sequence_name                        :: SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Name
+  , sam_v1_6_reference_sequence_dictionary_reference_sequence_length                      :: SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Length
+  , sam_v1_6_reference_sequence_dictionary_alternative_locus                              :: Maybe SAM_V1_6_Reference_Sequence_Dictionary_Alternative_Locus
+  , sam_v1_6_reference_sequence_dictionary_alternative_reference_sequence_names           :: Maybe SAM_V1_6_Reference_Sequence_Dictionary_Alternative_Reference_Sequence_Names
+  , sam_v1_6_reference_sequence_dictionary_genome_assembly_identifier                     :: Maybe SAM_V1_6_Reference_Sequence_Dictionary_Genome_Assembly_Identifier
+  , sam_v1_6_reference_sequence_dictionary_description                                    :: Maybe SAM_V1_6_Reference_Sequence_Dictionary_Description
+  , sam_v1_6_reference_sequence_dictionary_md5_checksum                                   :: Maybe SAM_V1_6_Reference_Sequence_Dictionary_MD5_Checksum
+  , sam_v1_6_reference_sequence_dictionary_species                                        :: Maybe SAM_V1_6_Reference_Sequence_Dictionary_Species
+  , sam_v1_6_reference_sequence_dictionary_molecule_topology                              :: Maybe SAM_V1_6_Reference_Sequence_Dictionary_Molecule_Topology                                       
+  , sam_v1_6_reference_sequence_dictionary_uri                                            :: Maybe SAM_V1_6_Reference_Sequence_Dictionary_URI 
+  } deriving (Generic,Typeable)
 
 instance Eq SAM_V1_6_Reference_Sequence_Dictionary where
   SAM_V1_6_Reference_Sequence_Dictionary sam_v1_6_reference_sequence_dictionary_reference_sequence_name1
@@ -62,25 +63,27 @@
                                          sam_v1_6_reference_sequence_dictionary_md5_checksum1
                                          sam_v1_6_reference_sequence_dictionary_species1
                                          sam_v1_6_reference_sequence_dictionary_molecule_topology1
-                                         sam_v1_6_reference_sequence_dictionary_uri1 == SAM_V1_6_Reference_Sequence_Dictionary sam_v1_6_reference_sequence_dictionary_reference_sequence_name2
-                                                                                                                               sam_v1_6_reference_sequence_dictionary_reference_sequence_length2
-                                                                                                                               sam_v1_6_reference_sequence_dictionary_reference_alternative_locus2
-                                                                                                                               sam_v1_6_reference_sequence_dictionary_reference_alternative_reference_sequence_names2
-                                                                                                                               sam_v1_6_reference_sequence_dictionary_genome_assembly_identifier2
-                                                                                                                               sam_v1_6_reference_sequence_dictionary_description2
-                                                                                                                               sam_v1_6_reference_sequence_dictionary_md5_checksum2
-                                                                                                                               sam_v1_6_reference_sequence_dictionary_species2
-                                                                                                                               sam_v1_6_reference_sequence_dictionary_molecule_topology2
-                                                                                                                               sam_v1_6_reference_sequence_dictionary_uri2 = sam_v1_6_reference_sequence_dictionary_reference_sequence_name1                        == sam_v1_6_reference_sequence_dictionary_reference_sequence_name2                        &&
-                                                                                                                                                                             sam_v1_6_reference_sequence_dictionary_reference_sequence_length1                      == sam_v1_6_reference_sequence_dictionary_reference_sequence_length2                      &&
-                                                                                                                                                                             sam_v1_6_reference_sequence_dictionary_reference_alternative_locus1                    == sam_v1_6_reference_sequence_dictionary_reference_alternative_locus2                    &&
-                                                                                                                                                                             sam_v1_6_reference_sequence_dictionary_reference_alternative_reference_sequence_names1 == sam_v1_6_reference_sequence_dictionary_reference_alternative_reference_sequence_names2 &&
-                                                                                                                                                                             sam_v1_6_reference_sequence_dictionary_genome_assembly_identifier1                     == sam_v1_6_reference_sequence_dictionary_genome_assembly_identifier2                     &&
-                                                                                                                                                                             sam_v1_6_reference_sequence_dictionary_description1                                    == sam_v1_6_reference_sequence_dictionary_description2                                    &&
-                                                                                                                                                                             sam_v1_6_reference_sequence_dictionary_md5_checksum1                                   == sam_v1_6_reference_sequence_dictionary_md5_checksum2                                   &&
-                                                                                                                                                                             sam_v1_6_reference_sequence_dictionary_species1                                        == sam_v1_6_reference_sequence_dictionary_species2                                        &&
-                                                                                                                                                                             sam_v1_6_reference_sequence_dictionary_molecule_topology1                              == sam_v1_6_reference_sequence_dictionary_molecule_topology2                              &&
-                                                                                                                                                                             sam_v1_6_reference_sequence_dictionary_uri1                                            == sam_v1_6_reference_sequence_dictionary_uri2
+                                         sam_v1_6_reference_sequence_dictionary_uri1 ==
+    SAM_V1_6_Reference_Sequence_Dictionary sam_v1_6_reference_sequence_dictionary_reference_sequence_name2
+                                           sam_v1_6_reference_sequence_dictionary_reference_sequence_length2
+                                           sam_v1_6_reference_sequence_dictionary_reference_alternative_locus2
+                                           sam_v1_6_reference_sequence_dictionary_reference_alternative_reference_sequence_names2
+                                           sam_v1_6_reference_sequence_dictionary_genome_assembly_identifier2
+                                           sam_v1_6_reference_sequence_dictionary_description2
+                                           sam_v1_6_reference_sequence_dictionary_md5_checksum2
+                                           sam_v1_6_reference_sequence_dictionary_species2
+                                           sam_v1_6_reference_sequence_dictionary_molecule_topology2
+                                           sam_v1_6_reference_sequence_dictionary_uri2 =
+      sam_v1_6_reference_sequence_dictionary_reference_sequence_name1                        == sam_v1_6_reference_sequence_dictionary_reference_sequence_name2                        &&
+      sam_v1_6_reference_sequence_dictionary_reference_sequence_length1                      == sam_v1_6_reference_sequence_dictionary_reference_sequence_length2                      &&
+      sam_v1_6_reference_sequence_dictionary_reference_alternative_locus1                    == sam_v1_6_reference_sequence_dictionary_reference_alternative_locus2                    &&
+      sam_v1_6_reference_sequence_dictionary_reference_alternative_reference_sequence_names1 == sam_v1_6_reference_sequence_dictionary_reference_alternative_reference_sequence_names2 &&
+      sam_v1_6_reference_sequence_dictionary_genome_assembly_identifier1                     == sam_v1_6_reference_sequence_dictionary_genome_assembly_identifier2                     &&
+      sam_v1_6_reference_sequence_dictionary_description1                                    == sam_v1_6_reference_sequence_dictionary_description2                                    &&
+      sam_v1_6_reference_sequence_dictionary_md5_checksum1                                   == sam_v1_6_reference_sequence_dictionary_md5_checksum2                                   &&
+      sam_v1_6_reference_sequence_dictionary_species1                                        == sam_v1_6_reference_sequence_dictionary_species2                                        &&
+      sam_v1_6_reference_sequence_dictionary_molecule_topology1                              == sam_v1_6_reference_sequence_dictionary_molecule_topology2                              &&
+      sam_v1_6_reference_sequence_dictionary_uri1                                            == sam_v1_6_reference_sequence_dictionary_uri2
 
 instance Show SAM_V1_6_Reference_Sequence_Dictionary where
   show (SAM_V1_6_Reference_Sequence_Dictionary reference_sequence_name
@@ -118,12 +121,14 @@
     " }"
 
 -- | SN tag for @"SAM_V1_6_Reference_Sequence_Dictionary"@.
-newtype SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Name = SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Name { sam_v1_6_reference_sequence_dictionary_reference_sequence_name_value :: ByteString 
-                                                                                                                                        }
-  deriving (Generic,Typeable)
+newtype SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Name = SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Name
+  { sam_v1_6_reference_sequence_dictionary_reference_sequence_name_value :: ByteString 
+  } deriving (Generic,Typeable)
 
 instance Eq SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Name where
-  SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Name sam_v1_6_reference_sequence_dictionary_reference_sequence_name_value1 == SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Name sam_v1_6_reference_sequence_dictionary_reference_sequence_name_value2 = sam_v1_6_reference_sequence_dictionary_reference_sequence_name_value1 == sam_v1_6_reference_sequence_dictionary_reference_sequence_name_value2  
+  SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Name sam_v1_6_reference_sequence_dictionary_reference_sequence_name_value1 ==
+    SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Name sam_v1_6_reference_sequence_dictionary_reference_sequence_name_value2 =
+      sam_v1_6_reference_sequence_dictionary_reference_sequence_name_value1 == sam_v1_6_reference_sequence_dictionary_reference_sequence_name_value2  
 
 instance Show SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Name where
   show (SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Name value) =
@@ -133,12 +138,14 @@
     " }"
 
 -- | LN tag for @"SAM_V1_6_Reference_Sequence_Dictionary"@.
-newtype SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Length = SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Length { sam_v1_6_reference_sequence_dictionary_reference_sequence_length_value :: ByteString
-                                                                                                                                            }
-  deriving (Generic,Typeable)
+newtype SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Length = SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Length
+  { sam_v1_6_reference_sequence_dictionary_reference_sequence_length_value :: ByteString
+  } deriving (Generic,Typeable)
 
 instance Eq SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Length where
-  SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Length sam_v1_6_reference_sequence_dictionary_reference_sequence_length_value1 == SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Length sam_v1_6_reference_sequence_dictionary_reference_sequence_length_value2 = sam_v1_6_reference_sequence_dictionary_reference_sequence_length_value1 == sam_v1_6_reference_sequence_dictionary_reference_sequence_length_value2
+  SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Length sam_v1_6_reference_sequence_dictionary_reference_sequence_length_value1 ==
+    SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Length sam_v1_6_reference_sequence_dictionary_reference_sequence_length_value2 =
+      sam_v1_6_reference_sequence_dictionary_reference_sequence_length_value1 == sam_v1_6_reference_sequence_dictionary_reference_sequence_length_value2
 
 instance Show SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Length where
   show (SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Length value) =
@@ -148,12 +155,14 @@
     " }"
 
 -- | AH tag for @"SAM_V1_6_Reference_Sequence_Dictionary"@.
-newtype SAM_V1_6_Reference_Sequence_Dictionary_Alternative_Locus = SAM_V1_6_Reference_Sequence_Dictionary_Alternative_Locus { sam_v1_6_reference_sequence_dictionary_alternative_locus_value :: ByteString
-                                                                                                                            }
-  deriving (Generic,Typeable)
+newtype SAM_V1_6_Reference_Sequence_Dictionary_Alternative_Locus = SAM_V1_6_Reference_Sequence_Dictionary_Alternative_Locus
+  { sam_v1_6_reference_sequence_dictionary_alternative_locus_value :: ByteString
+  } deriving (Generic,Typeable)
 
 instance Eq SAM_V1_6_Reference_Sequence_Dictionary_Alternative_Locus where
-  SAM_V1_6_Reference_Sequence_Dictionary_Alternative_Locus sam_v1_6_reference_sequence_dictionary_alternative_locus_value1 == SAM_V1_6_Reference_Sequence_Dictionary_Alternative_Locus sam_v1_6_reference_sequence_dictionary_alternative_locus_value2 = sam_v1_6_reference_sequence_dictionary_alternative_locus_value1 == sam_v1_6_reference_sequence_dictionary_alternative_locus_value2
+  SAM_V1_6_Reference_Sequence_Dictionary_Alternative_Locus sam_v1_6_reference_sequence_dictionary_alternative_locus_value1 ==
+    SAM_V1_6_Reference_Sequence_Dictionary_Alternative_Locus sam_v1_6_reference_sequence_dictionary_alternative_locus_value2 =
+      sam_v1_6_reference_sequence_dictionary_alternative_locus_value1 == sam_v1_6_reference_sequence_dictionary_alternative_locus_value2
 
 instance Show SAM_V1_6_Reference_Sequence_Dictionary_Alternative_Locus where
   show (SAM_V1_6_Reference_Sequence_Dictionary_Alternative_Locus value) =
@@ -163,12 +172,14 @@
     " }"
 
 -- | AN tag for @"SAM_V1_6_Reference_Sequence_Dictionary"@.
-newtype SAM_V1_6_Reference_Sequence_Dictionary_Alternative_Reference_Sequence_Names = SAM_V1_6_Reference_Sequence_Dictionary_Alternative_Reference_Sequence_Names { sam_v1_6_reference_sequence_dictionary_alternative_reference_sequence_names_value :: ByteString
-                                                                                                                                                                  }
-  deriving (Generic,Typeable)
+newtype SAM_V1_6_Reference_Sequence_Dictionary_Alternative_Reference_Sequence_Names = SAM_V1_6_Reference_Sequence_Dictionary_Alternative_Reference_Sequence_Names
+  { sam_v1_6_reference_sequence_dictionary_alternative_reference_sequence_names_value :: ByteString
+  } deriving (Generic,Typeable)
 
 instance Eq SAM_V1_6_Reference_Sequence_Dictionary_Alternative_Reference_Sequence_Names where
-  SAM_V1_6_Reference_Sequence_Dictionary_Alternative_Reference_Sequence_Names sam_v1_6_reference_sequence_dictionary_alternative_reference_sequence_names_value1 == SAM_V1_6_Reference_Sequence_Dictionary_Alternative_Reference_Sequence_Names sam_v1_6_reference_sequence_dictionary_alternative_reference_sequence_names_value2 = sam_v1_6_reference_sequence_dictionary_alternative_reference_sequence_names_value1 == sam_v1_6_reference_sequence_dictionary_alternative_reference_sequence_names_value2
+  SAM_V1_6_Reference_Sequence_Dictionary_Alternative_Reference_Sequence_Names sam_v1_6_reference_sequence_dictionary_alternative_reference_sequence_names_value1 ==
+    SAM_V1_6_Reference_Sequence_Dictionary_Alternative_Reference_Sequence_Names sam_v1_6_reference_sequence_dictionary_alternative_reference_sequence_names_value2 =
+      sam_v1_6_reference_sequence_dictionary_alternative_reference_sequence_names_value1 == sam_v1_6_reference_sequence_dictionary_alternative_reference_sequence_names_value2
 
 instance Show SAM_V1_6_Reference_Sequence_Dictionary_Alternative_Reference_Sequence_Names where
   show (SAM_V1_6_Reference_Sequence_Dictionary_Alternative_Reference_Sequence_Names value) =
@@ -178,12 +189,14 @@
     " }"
 
 -- | AS tag for @"SAM_V1_6_Reference_Sequence_Dictionary"@.
-newtype SAM_V1_6_Reference_Sequence_Dictionary_Genome_Assembly_Identifier = SAM_V1_6_Reference_Sequence_Dictionary_Genome_Assembly_Identifier { sam_v1_6_reference_sequence_dictionary_genome_assembly_identifier_value :: ByteString
-                                                                                                                                              }
-  deriving (Generic,Typeable)
+newtype SAM_V1_6_Reference_Sequence_Dictionary_Genome_Assembly_Identifier = SAM_V1_6_Reference_Sequence_Dictionary_Genome_Assembly_Identifier
+  { sam_v1_6_reference_sequence_dictionary_genome_assembly_identifier_value :: ByteString
+  } deriving (Generic,Typeable)
 
 instance Eq SAM_V1_6_Reference_Sequence_Dictionary_Genome_Assembly_Identifier where
-  SAM_V1_6_Reference_Sequence_Dictionary_Genome_Assembly_Identifier sam_v1_6_reference_sequence_dictionary_genome_assembly_identifier_value1 == SAM_V1_6_Reference_Sequence_Dictionary_Genome_Assembly_Identifier sam_v1_6_reference_sequence_dictionary_genome_assembly_identifier_value2 = sam_v1_6_reference_sequence_dictionary_genome_assembly_identifier_value1 == sam_v1_6_reference_sequence_dictionary_genome_assembly_identifier_value2
+  SAM_V1_6_Reference_Sequence_Dictionary_Genome_Assembly_Identifier sam_v1_6_reference_sequence_dictionary_genome_assembly_identifier_value1 ==
+    SAM_V1_6_Reference_Sequence_Dictionary_Genome_Assembly_Identifier sam_v1_6_reference_sequence_dictionary_genome_assembly_identifier_value2 =
+      sam_v1_6_reference_sequence_dictionary_genome_assembly_identifier_value1 == sam_v1_6_reference_sequence_dictionary_genome_assembly_identifier_value2
 
 instance Show SAM_V1_6_Reference_Sequence_Dictionary_Genome_Assembly_Identifier where
   show (SAM_V1_6_Reference_Sequence_Dictionary_Genome_Assembly_Identifier value) =
@@ -193,12 +206,14 @@
     " }"
 
 -- | DS tag for @"SAM_V1_6_Reference_Sequence_Dictionary"@.
-newtype SAM_V1_6_Reference_Sequence_Dictionary_Description = SAM_V1_6_Reference_Sequence_Dictionary_Description { sam_v1_6_reference_sequence_dictionary_description_value :: ByteString
-                                                                                                                }
-  deriving (Generic,Typeable)
+newtype SAM_V1_6_Reference_Sequence_Dictionary_Description = SAM_V1_6_Reference_Sequence_Dictionary_Description
+  { sam_v1_6_reference_sequence_dictionary_description_value :: ByteString
+  } deriving (Generic,Typeable)
 
 instance Eq SAM_V1_6_Reference_Sequence_Dictionary_Description where
-  SAM_V1_6_Reference_Sequence_Dictionary_Description sam_v1_6_reference_sequence_dictionary_description_value1 == SAM_V1_6_Reference_Sequence_Dictionary_Description sam_v1_6_reference_sequence_dictionary_description_value2 = sam_v1_6_reference_sequence_dictionary_description_value1 == sam_v1_6_reference_sequence_dictionary_description_value2
+  SAM_V1_6_Reference_Sequence_Dictionary_Description sam_v1_6_reference_sequence_dictionary_description_value1 ==
+    SAM_V1_6_Reference_Sequence_Dictionary_Description sam_v1_6_reference_sequence_dictionary_description_value2 =
+      sam_v1_6_reference_sequence_dictionary_description_value1 == sam_v1_6_reference_sequence_dictionary_description_value2
 
 instance Show SAM_V1_6_Reference_Sequence_Dictionary_Description where
   show (SAM_V1_6_Reference_Sequence_Dictionary_Description value) =
@@ -208,12 +223,14 @@
     " }"
 
 -- | M5 tag for @"SAM_V1_6_Reference_Sequence_Dictionary"@.
-newtype SAM_V1_6_Reference_Sequence_Dictionary_MD5_Checksum = SAM_V1_6_Reference_Sequence_Dictionary_MD5_Checksum { sam_v1_6_reference_sequence_dictionary_md5_checksum_value :: ByteString
-                                                                                                                  }
-  deriving (Generic,Typeable)
+newtype SAM_V1_6_Reference_Sequence_Dictionary_MD5_Checksum = SAM_V1_6_Reference_Sequence_Dictionary_MD5_Checksum
+  { sam_v1_6_reference_sequence_dictionary_md5_checksum_value :: ByteString
+  } deriving (Generic,Typeable)
 
 instance Eq SAM_V1_6_Reference_Sequence_Dictionary_MD5_Checksum where
-  SAM_V1_6_Reference_Sequence_Dictionary_MD5_Checksum sam_v1_6_reference_sequence_dictionary_md5_checksum_value1 == SAM_V1_6_Reference_Sequence_Dictionary_MD5_Checksum sam_v1_6_reference_sequence_dictionary_md5_checksum_value2 = sam_v1_6_reference_sequence_dictionary_md5_checksum_value1 == sam_v1_6_reference_sequence_dictionary_md5_checksum_value2
+  SAM_V1_6_Reference_Sequence_Dictionary_MD5_Checksum sam_v1_6_reference_sequence_dictionary_md5_checksum_value1 ==
+    SAM_V1_6_Reference_Sequence_Dictionary_MD5_Checksum sam_v1_6_reference_sequence_dictionary_md5_checksum_value2 =
+      sam_v1_6_reference_sequence_dictionary_md5_checksum_value1 == sam_v1_6_reference_sequence_dictionary_md5_checksum_value2
 
 instance Show SAM_V1_6_Reference_Sequence_Dictionary_MD5_Checksum where
   show (SAM_V1_6_Reference_Sequence_Dictionary_MD5_Checksum value) =
@@ -223,12 +240,14 @@
     " }"
 
 -- | SP tag for @"SAM_V1_6_Reference_Sequence_Dictionary"@.
-newtype SAM_V1_6_Reference_Sequence_Dictionary_Species = SAM_V1_6_Reference_Sequence_Dictionary_Species { sam_v1_6_reference_sequence_dictionary_species_value :: ByteString
-                                                                                                        }
-  deriving (Generic,Typeable)
+newtype SAM_V1_6_Reference_Sequence_Dictionary_Species = SAM_V1_6_Reference_Sequence_Dictionary_Species
+  { sam_v1_6_reference_sequence_dictionary_species_value :: ByteString
+  } deriving (Generic,Typeable)
 
 instance Eq SAM_V1_6_Reference_Sequence_Dictionary_Species where
-  SAM_V1_6_Reference_Sequence_Dictionary_Species sam_v1_6_reference_sequence_dictionary_species_value1 == SAM_V1_6_Reference_Sequence_Dictionary_Species sam_v1_6_reference_sequence_dictionary_species_value2 = sam_v1_6_reference_sequence_dictionary_species_value1 == sam_v1_6_reference_sequence_dictionary_species_value2
+  SAM_V1_6_Reference_Sequence_Dictionary_Species sam_v1_6_reference_sequence_dictionary_species_value1 ==
+    SAM_V1_6_Reference_Sequence_Dictionary_Species sam_v1_6_reference_sequence_dictionary_species_value2 =
+      sam_v1_6_reference_sequence_dictionary_species_value1 == sam_v1_6_reference_sequence_dictionary_species_value2
 
 instance Show SAM_V1_6_Reference_Sequence_Dictionary_Species where
   show (SAM_V1_6_Reference_Sequence_Dictionary_Species value) =
@@ -238,12 +257,14 @@
     " }"
 
 -- | TP tag for @"SAM_V1_6_Reference_Sequence_Dictionary"@.
-newtype SAM_V1_6_Reference_Sequence_Dictionary_Molecule_Topology = SAM_V1_6_Reference_Sequence_Dictionary_Molecule_Topology { sam_v1_6_reference_sequence_dictionary_molecule_topology_value :: ByteString
-                                                                                                                            }
-  deriving (Generic,Typeable)
+newtype SAM_V1_6_Reference_Sequence_Dictionary_Molecule_Topology = SAM_V1_6_Reference_Sequence_Dictionary_Molecule_Topology
+  { sam_v1_6_reference_sequence_dictionary_molecule_topology_value :: ByteString
+  } deriving (Generic,Typeable)
 
 instance Eq SAM_V1_6_Reference_Sequence_Dictionary_Molecule_Topology where
-  SAM_V1_6_Reference_Sequence_Dictionary_Molecule_Topology sam_v1_6_reference_sequence_dictionary_molecule_topology_value1 == SAM_V1_6_Reference_Sequence_Dictionary_Molecule_Topology sam_v1_6_reference_sequence_dictionary_molecule_topology_value2 = sam_v1_6_reference_sequence_dictionary_molecule_topology_value1 == sam_v1_6_reference_sequence_dictionary_molecule_topology_value2
+  SAM_V1_6_Reference_Sequence_Dictionary_Molecule_Topology sam_v1_6_reference_sequence_dictionary_molecule_topology_value1 ==
+    SAM_V1_6_Reference_Sequence_Dictionary_Molecule_Topology sam_v1_6_reference_sequence_dictionary_molecule_topology_value2 =
+      sam_v1_6_reference_sequence_dictionary_molecule_topology_value1 == sam_v1_6_reference_sequence_dictionary_molecule_topology_value2
 
 instance Show SAM_V1_6_Reference_Sequence_Dictionary_Molecule_Topology where
   show (SAM_V1_6_Reference_Sequence_Dictionary_Molecule_Topology value) =
@@ -253,12 +274,14 @@
     " }"
 
 -- | UR tag for @"SAM_V1_6_Reference_Sequence_Dictionary"@.
-newtype SAM_V1_6_Reference_Sequence_Dictionary_URI = SAM_V1_6_Reference_Sequence_Dictionary_URI { sam_v1_6_reference_sequence_dictionary_uri_value :: ByteString
-                                                                                                }
-  deriving (Generic,Typeable)
+newtype SAM_V1_6_Reference_Sequence_Dictionary_URI = SAM_V1_6_Reference_Sequence_Dictionary_URI
+  { sam_v1_6_reference_sequence_dictionary_uri_value :: ByteString
+  } deriving (Generic,Typeable)
 
 instance Eq SAM_V1_6_Reference_Sequence_Dictionary_URI where
-  SAM_V1_6_Reference_Sequence_Dictionary_URI sam_v1_6_reference_sequence_dictionary_uri_value1 == SAM_V1_6_Reference_Sequence_Dictionary_URI sam_v1_6_reference_sequence_dictionary_uri_value2 = sam_v1_6_reference_sequence_dictionary_uri_value1 == sam_v1_6_reference_sequence_dictionary_uri_value2
+  SAM_V1_6_Reference_Sequence_Dictionary_URI sam_v1_6_reference_sequence_dictionary_uri_value1 ==
+    SAM_V1_6_Reference_Sequence_Dictionary_URI sam_v1_6_reference_sequence_dictionary_uri_value2 =
+      sam_v1_6_reference_sequence_dictionary_uri_value1 == sam_v1_6_reference_sequence_dictionary_uri_value2
 
 instance Show SAM_V1_6_Reference_Sequence_Dictionary_URI where
   show (SAM_V1_6_Reference_Sequence_Dictionary_URI value) =
diff --git a/src/Data/SAM/Version1_6/Internal.hs b/src/Data/SAM/Version1_6/Internal.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/SAM/Version1_6/Internal.hs
@@ -0,0 +1,27 @@
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE TypeFamilies          #-}
+
+-- |
+-- Module      :  Data.SAM.Version1_6.Internal
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.SAM.Version1_6.Internal ( -- * Parsing
+                                      maybeOption
+                                    ) where
+
+import Data.Attoparsec.ByteString.Lazy   as DABL
+
+-- | Make a parser optional, return Nothing if there is no match.
+maybeOption :: Parser a
+            -> Parser (Maybe a)
+maybeOption p = option Nothing
+                       (Just <$> p)
diff --git a/src/Data/SAM/Version1_6/Read/Base.hs b/src/Data/SAM/Version1_6/Read/Base.hs
--- a/src/Data/SAM/Version1_6/Read/Base.hs
+++ b/src/Data/SAM/Version1_6/Read/Base.hs
@@ -5,7 +5,7 @@
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Read.Base
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -19,6 +19,7 @@
                                      ) where
 
 import Data.SAM.Version1_6.Base
+import Data.SAM.Version1_6.Internal
 import Data.SAM.Version1_6.Read.Parser.Header.HD.Base
 import Data.SAM.Version1_6.Read.Parser.Header.SQ.Base
 import Data.SAM.Version1_6.Read.Parser.Header.RG.Base
@@ -26,87 +27,115 @@
 import Data.SAM.Version1_6.Read.Parser.Header.CO.Base
 import Data.SAM.Version1_6.Read.Parser.Alignment.Base
 
-import Control.Applicative.Permutations                          (intercalateEffect,toPermutationWithDefault)
-import Data.Attoparsec.ByteString.Char8  as DABC8                (endOfLine)
-import Data.Attoparsec.ByteString.Lazy   as DABL
-import Data.ByteString.Lazy              as DBL
-import Data.Sequence                     as DSeq
-import qualified Streamly.Data.Stream    as S
-import Streamly.External.ByteString.Lazy as StreamlyLByteString  (fromChunksIO)
-import Streamly.Internal.FileSystem.File as StreamlyInternalFile (chunkReader)
-
--- | Make a parser optional, return Nothing if there is no match.
-maybeOption :: Parser a
-            -> Parser (Maybe a)
-maybeOption p = option Nothing (Just <$> p)
+import            Control.Applicative.Permutations                          (intercalateEffect,toPermutationWithDefault)
+import            Data.Attoparsec.ByteString.Char8  as DABC8                (endOfLine)
+import            Data.Attoparsec.ByteString.Lazy   as DABL
+import            Data.ByteString.Lazy              as DBL
+import            Data.Sequence                     as DSeq
+import qualified  Streamly.Data.Stream    as S
+import            Streamly.External.ByteString.Lazy as StreamlyLByteString  (fromChunksIO)
+import            Streamly.Internal.FileSystem.File as StreamlyInternalFile (chunkReader)
 
 -- | Define the @"SAM_V1_6"@ parser.
 parse_SAM_V1_6 :: Parser SAM_V1_6
 parse_SAM_V1_6 = do
-  filelevelmetadata <- maybeOption parse_SAM_V1_6_File_Level_Metadata
+  filelevelmetadata <-
+    maybeOption parse_SAM_V1_6_File_Level_Metadata
   case filelevelmetadata of
-    Nothing  -> do samwoalignment <- intercalateEffect endOfLine $
-                                       (,,,)
-                                         <$> toPermutationWithDefault Nothing
-                                                                      (Just <$> DABL.many1' parse_SAM_V1_6_Reference_Sequence_Dictionary)
-                                         <*> toPermutationWithDefault Nothing
-                                                                      (Just <$> DABL.many1' parse_SAM_V1_6_Read_Group)
-                                         <*> toPermutationWithDefault Nothing
-                                                                      (Just <$> parse_SAM_V1_6_Program)
-                                         <*> toPermutationWithDefault Nothing
-                                                                      (Just <$> DABL.many1' parse_SAM_V1_6_One_Line_Comment)
-                   alignment <- DABL.many1' parse_SAM_V1_6_Alignment
-                   return SAM_V1_6 { sam_v1_6_file_level_metadata           = Nothing
-                                   , sam_v1_6_reference_sequence_dictionary = (\(a,_,_,_) -> case a of
-                                                                                               Nothing      -> Nothing
-                                                                                               Just finala  -> Just $ DSeq.fromList finala
-                                                                              ) samwoalignment
-                                   , sam_v1_6_read_group                    = (\(_,b,_,_) -> case b of
-                                                                                               Nothing      -> Nothing
-                                                                                               Just finalb  -> Just $ DSeq.fromList finalb
-                                                                              ) samwoalignment
-                                   , sam_v1_6_program                       = (\(_,_,c,_) -> c) samwoalignment
-                                   , sam_v1_6_one_line_comment              = (\(_,_,_,d) -> case d of
-                                                                                               Nothing      -> Nothing
-                                                                                               Just finald  -> Just $ DSeq.fromList finald
-                                                                              ) samwoalignment
-                                   , sam_v1_6_alignment                     = DSeq.fromList alignment
-                                   }
-    Just flm -> do samwoalignment <- intercalateEffect endOfLine $
-                                       (,,,)
-                                         <$> toPermutationWithDefault Nothing
-                                                                      (Just <$> DABL.many1' parse_SAM_V1_6_Reference_Sequence_Dictionary)
-                                         <*> toPermutationWithDefault Nothing
-                                                                      (Just <$> DABL.many1' parse_SAM_V1_6_Read_Group)
-                                         <*> toPermutationWithDefault Nothing
-                                                                      (Just <$> parse_SAM_V1_6_Program)
-                                         <*> toPermutationWithDefault Nothing
-                                                                      (Just <$> DABL.many1' parse_SAM_V1_6_One_Line_Comment)
-                   alignment <- DABL.many1' parse_SAM_V1_6_Alignment
-                   return SAM_V1_6 { sam_v1_6_file_level_metadata           = Just flm
-                                   , sam_v1_6_reference_sequence_dictionary = (\(a,_,_,_) -> case a of
-                                                                                               Nothing      -> Nothing
-                                                                                               Just finala  -> Just $ DSeq.fromList finala
-                                                                              ) samwoalignment
-                                   , sam_v1_6_read_group                    = (\(_,b,_,_) -> case b of
-                                                                                               Nothing      -> Nothing
-                                                                                               Just finalb  -> Just $ DSeq.fromList finalb
-                                                                              ) samwoalignment
-                                   , sam_v1_6_program                       = (\(_,_,c,_) -> c) samwoalignment
-                                   , sam_v1_6_one_line_comment              = (\(_,_,_,d) -> case d of
-                                                                                               Nothing      -> Nothing
-                                                                                               Just finald  -> Just $ DSeq.fromList finald
-                                                                              ) samwoalignment
-                                   , sam_v1_6_alignment                     = DSeq.fromList alignment
-                                   }
+    Nothing  -> do
+      samwoalignment <-
+        intercalateEffect endOfLine $
+          (,,,)
+            <$> toPermutationWithDefault Nothing
+                                         (Just <$> DABL.many1' parse_SAM_V1_6_Reference_Sequence_Dictionary)
+            <*> toPermutationWithDefault Nothing
+                                         (Just <$> DABL.many1' parse_SAM_V1_6_Read_Group)
+            <*> toPermutationWithDefault Nothing
+                                         (Just <$> parse_SAM_V1_6_Program)
+            <*> toPermutationWithDefault Nothing
+                                         (Just <$> DABL.many1' parse_SAM_V1_6_One_Line_Comment)
+      alignment <-
+        DABL.many1' parse_SAM_V1_6_Alignment
+      return SAM_V1_6 { sam_v1_6_file_level_metadata           = Nothing
+                      , sam_v1_6_reference_sequence_dictionary = (\(a,_,_,_) ->
+                                                                   case a of
+                                                                     Nothing     ->
+                                                                       Nothing
+                                                                     Just finala ->
+                                                                       Just $
+                                                                         DSeq.fromList finala
+                                                                 ) samwoalignment
+                      , sam_v1_6_read_group                    = (\(_,b,_,_) ->
+                                                                   case b of
+                                                                     Nothing     ->
+                                                                       Nothing
+                                                                     Just finalb ->
+                                                                       Just $
+                                                                         DSeq.fromList finalb
+                                                                 ) samwoalignment
+                      , sam_v1_6_program                       = (\(_,_,c,_) -> c) samwoalignment
+                      , sam_v1_6_one_line_comment              = (\(_,_,_,d) ->
+                                                                   case d of
+                                                                     Nothing     ->
+                                                                       Nothing
+                                                                     Just finald ->
+                                                                       Just $
+                                                                         DSeq.fromList finald
+                                                                 ) samwoalignment
+                      , sam_v1_6_alignment                     = DSeq.fromList alignment
+                      }
+    Just flm -> do
+      samwoalignment <-
+        intercalateEffect endOfLine $
+          (,,,)
+            <$> toPermutationWithDefault Nothing
+                                         (Just <$> DABL.many1' parse_SAM_V1_6_Reference_Sequence_Dictionary)
+            <*> toPermutationWithDefault Nothing
+                                         (Just <$> DABL.many1' parse_SAM_V1_6_Read_Group)
+            <*> toPermutationWithDefault Nothing
+                                         (Just <$> parse_SAM_V1_6_Program)
+            <*> toPermutationWithDefault Nothing
+                                         (Just <$> DABL.many1' parse_SAM_V1_6_One_Line_Comment)
+      alignment <-
+        DABL.many1' parse_SAM_V1_6_Alignment
+      return SAM_V1_6 { sam_v1_6_file_level_metadata           = Just flm
+                      , sam_v1_6_reference_sequence_dictionary = (\(a,_,_,_) ->
+                                                                   case a of
+                                                                     Nothing     ->
+                                                                       Nothing
+                                                                     Just finala ->
+                                                                       Just $
+                                                                         DSeq.fromList finala
+                                                                 ) samwoalignment
+                      , sam_v1_6_read_group                    = (\(_,b,_,_) ->
+                                                                   case b of
+                                                                     Nothing     ->
+                                                                       Nothing
+                                                                     Just finalb ->
+                                                                       Just $
+                                                                         DSeq.fromList finalb
+                                                                 ) samwoalignment
+                      , sam_v1_6_program                       = (\(_,_,c,_) -> c) samwoalignment
+                      , sam_v1_6_one_line_comment              = (\(_,_,_,d) ->
+                                                                   case d of
+                                                                     Nothing     ->
+                                                                       Nothing
+                                                                     Just finald ->
+                                                                       Just $
+                                                                         DSeq.fromList finald
+                                                                 ) samwoalignment
+                      , sam_v1_6_alignment                     = DSeq.fromList alignment
+                      }
 
 -- | Run the @"SAM_V1_6"@ parser.
 readSAM_V1_6_LBS :: DBL.ByteString
                  -> IO SAM_V1_6
 readSAM_V1_6_LBS lbs =
   case (DABL.parseOnly parse_SAM_V1_6 lbs) of 
-    Left  samparseerror -> error samparseerror
-    Right sam           -> return sam
+    Left  samparseerror ->
+      error samparseerror
+    Right sam           ->
+      return sam
 
 -- | Read a @"SAM_V1_6"@ from a file.
 --
@@ -117,5 +146,6 @@
              -> IO SAM_V1_6
 readSAM_V1_6 fp = do
   let lazysamfile = S.unfold StreamlyInternalFile.chunkReader fp
-  lazysamfilef    <- StreamlyLByteString.fromChunksIO lazysamfile
+  lazysamfilef    <-
+    StreamlyLByteString.fromChunksIO lazysamfile
   readSAM_V1_6_LBS lazysamfilef
diff --git a/src/Data/SAM/Version1_6/Read/Error.hs b/src/Data/SAM/Version1_6/Read/Error.hs
--- a/src/Data/SAM/Version1_6/Read/Error.hs
+++ b/src/Data/SAM/Version1_6/Read/Error.hs
@@ -7,7 +7,7 @@
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Read.Error
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -232,4 +232,12 @@
                     | SAM_V1_6_Error_Alignment_BOPT_Value_Type_Incorrect_Format
                       -- | BOPT value data of the alignment section not in accepted format.
                     | SAM_V1_6_Error_Alignment_BOPT_Value_Data_Incorrect_Format
+                      -- | Remaining bytes leftover from running a parser on optional fields.
+                    | SAM_V1_6_Read_Error_Alignment_OptionalFields_Remaining_Bytes
+                      -- | Optional field is missing a type.
+                    | SAM_V1_6_Read_Error_Alignment_OptionalFields_Missing_Type
+                      -- | Optional field BOPT is missing a type.
+                    | SAM_V1_6_Read_Error_Alignment_OptionalFields_BOPT_Missing_Type
+                      -- | Optional field doesn't have a type.
+                    | SAM_V1_6_Read_Error_Alignment_OptionalFields_Index_Missing
   deriving (Eq,Generic,Show,Typeable)
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Alignment/AOPT.hs b/src/Data/SAM/Version1_6/Read/Parser/Alignment/AOPT.hs
deleted file mode 100644
--- a/src/Data/SAM/Version1_6/Read/Parser/Alignment/AOPT.hs
+++ /dev/null
@@ -1,80 +0,0 @@
-{-# LANGUAGE DeriveDataTypeable    #-}
-{-# LANGUAGE DeriveGeneric         #-}
-{-# LANGUAGE FlexibleContexts      #-}
-{-# LANGUAGE FlexibleInstances     #-}
-{-# LANGUAGE MultiParamTypeClasses #-}
-{-# LANGUAGE OverloadedLists       #-}
-{-# LANGUAGE OverloadedStrings     #-}
-{-# LANGUAGE MultiWayIf            #-}
-{-# LANGUAGE PackageImports        #-}
-{-# LANGUAGE RecordWildCards       #-}
-{-# LANGUAGE ScopedTypeVariables   #-}
-{-# LANGUAGE TypeFamilies          #-}
-{-# Language QuasiQuotes           #-}
-
--- |
--- Module      :  Data.SAM.Version1_6.Read.Parser.Alignment.AOPT
--- Copyright   :  (c) Matthew Mosior 2023
--- License     :  BSD-style
--- Maintainer  :  mattm.github@gmail.com
--- Portability :  portable
---
--- = WARNING
---
--- This module is considered __internal__.
---
--- The Package Versioning Policy __does not apply__.
---
--- The contents of this module may change __in any way whatsoever__
--- and __without any warning__ between minor versions of this package.
---
--- Authors importing this library are expected to track development
--- closely.
---
--- All credit goes to the author(s)/maintainer(s) of the
--- [containers](https://hackage.haskell.org/package/containers) library
--- for the above warning text.
---
--- = Description
---
--- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
-
-module Data.SAM.Version1_6.Read.Parser.Alignment.AOPT ( -- * SAM_V1_6 parser - alignment section - aopt field 
-                                                        parse_SAM_V1_6_Alignment_AOPT
-                                                      ) where
-
-import Data.SAM.Version1_6.Alignment.AOPT
-import Data.SAM.Version1_6.Read.Error
-
-import           Data.Attoparsec.ByteString.Char8  as DABC8 (isEndOfLine)
-import           Data.Attoparsec.ByteString.Lazy   as DABL
-import           Text.Regex.PCRE.Heavy
-
--- | Defines a parser for the optional aopt field of alignment section of the SAM v1.6 file format.
---
--- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
-parse_SAM_V1_6_Alignment_AOPT :: Parser SAM_V1_6_Alignment_AOPT
-parse_SAM_V1_6_Alignment_AOPT = do
-  alignmentaoptfieldtag <- do alignmentaoptfieldtagp <- DABL.takeTill (== 58)
-                              -- Parse AOPT tag of the alignment section.
-                              case (alignmentaoptfieldtagp =~ [re|[A-Za-z][A-Za-z0-9]|]) of
-                                False -> fail $ show SAM_V1_6_Error_Alignment_AOPT_Tag_Incorrect_Format
-                                True  -> -- AOPT tag is in the accepted format. 
-                                         return alignmentaoptfieldtagp
-  _ <- word8 58
-  _ <- do alignmentaoptfieldtypep <- DABL.takeTill (== 58)
-          -- Parse AOPT type of the alignment section.
-          case (alignmentaoptfieldtypep =~ [re|[A]|]) of
-            False -> fail $ show SAM_V1_6_Error_Alignment_AOPT_Type_Incorrect_Format
-            True  -> -- AOPT type is in the accepted format.
-                     return ()
-  _ <- word8 58
-  alignmentaoptfieldvalue <- do alignmentaoptfieldvaluep <- DABL.takeTill (\x -> x == 09 || isEndOfLine x)
-                                -- Parse AOPT value of the alignment section.
-                                case (alignmentaoptfieldvaluep =~ [re|[!-~]|]) of
-                                  False -> fail $ show SAM_V1_6_Error_Alignment_AOPT_Value_Incorrect_Format
-                                  True  -> -- AOPT value is in the accepted format.
-                                           return alignmentaoptfieldvaluep
-  return SAM_V1_6_Alignment_AOPT { sam_v1_6_alignment_aopt_tag   = alignmentaoptfieldtag
-                                 , sam_v1_6_alignment_aopt_value = alignmentaoptfieldvalue
-                                 }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Alignment/BOPT.hs b/src/Data/SAM/Version1_6/Read/Parser/Alignment/BOPT.hs
deleted file mode 100644
--- a/src/Data/SAM/Version1_6/Read/Parser/Alignment/BOPT.hs
+++ /dev/null
@@ -1,173 +0,0 @@
-{-# LANGUAGE DeriveDataTypeable    #-}
-{-# LANGUAGE DeriveGeneric         #-}
-{-# LANGUAGE FlexibleContexts      #-}
-{-# LANGUAGE FlexibleInstances     #-}
-{-# LANGUAGE MultiParamTypeClasses #-}
-{-# LANGUAGE OverloadedLists       #-}
-{-# LANGUAGE OverloadedStrings     #-}
-{-# LANGUAGE MultiWayIf            #-}
-{-# LANGUAGE PackageImports        #-}
-{-# LANGUAGE RecordWildCards       #-}
-{-# LANGUAGE ScopedTypeVariables   #-}
-{-# LANGUAGE TypeFamilies          #-}
-{-# Language QuasiQuotes           #-}
-
--- |
--- Module      :  Data.SAM.Version1_6.Read.Parser.Alignment.BOPT
--- Copyright   :  (c) Matthew Mosior 2023
--- License     :  BSD-style
--- Maintainer  :  mattm.github@gmail.com
--- Portability :  portable
---
--- = WARNING
---
--- This module is considered __internal__.
---
--- The Package Versioning Policy __does not apply__.
---
--- The contents of this module may change __in any way whatsoever__
--- and __without any warning__ between minor versions of this package.
---
--- Authors importing this library are expected to track development
--- closely.
---
--- All credit goes to the author(s)/maintainer(s) of the
--- [containers](https://hackage.haskell.org/package/containers) library
--- for the above warning text.
---
--- = Description
---
--- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
-
-module Data.SAM.Version1_6.Read.Parser.Alignment.BOPT ( -- * SAM_V1_6 parser - alignment section - bopt field 
-                                                        parse_SAM_V1_6_Alignment_BOPT
-                                                      ) where
-
-import Data.SAM.Version1_6.Alignment.BOPT
-import Data.SAM.Version1_6.Read.Error
-
-import           Data.Attoparsec.ByteString.Char8  as DABC8 (isEndOfLine)
-import           Data.Attoparsec.ByteString.Lazy   as DABL
-import qualified Data.ByteString                   as DB (head,unpack)
-import qualified Data.ByteString.Char8             as DBC8
-import           Data.Sequence                     as DSeq
-import           Text.Regex.PCRE.Heavy
-
--- | Defines a parser for the optional bopt field of alignment section of the SAM v1.6 file format.
---
--- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
-parse_SAM_V1_6_Alignment_BOPT :: Parser SAM_V1_6_Alignment_BOPT
-parse_SAM_V1_6_Alignment_BOPT = do
-  alignmentboptfieldtag <- do alignmentboptfieldtagp <- DABL.takeTill (== 58)
-                              -- Parse BOPT tag of the alignment section.
-                              case (alignmentboptfieldtagp =~ [re|[A-Za-z][A-Za-z0-9]|]) of
-                                False -> fail $ show SAM_V1_6_Error_Alignment_BOPT_Tag_Incorrect_Format
-                                True  -> -- BOPT tag is in the accepted format. 
-                                         return alignmentboptfieldtagp
-  _ <- word8 58
-  _ <- do alignmentboptfieldtypep <- DABL.takeTill (== 58)
-          -- Parse BOPT type of the alignment section.
-          case (alignmentboptfieldtypep =~ [re|[B]|]) of
-            False -> fail $ show SAM_V1_6_Error_Alignment_BOPT_Type_Incorrect_Format
-            True  -> -- BOPT type is in the accepted format.
-                     return ()
-  _ <- word8 58
-  alignmentboptfieldvaluetype <- do alignmentboptfieldvaluetypep <- DABL.take 1
-                                    -- Parse BOPT value type of the alignment section.
-                                    case (alignmentboptfieldvaluetypep =~ [re|[cCsSiIf]|]) of
-                                      False -> fail $ show SAM_V1_6_Error_Alignment_BOPT_Value_Type_Incorrect_Format
-                                      True  -> -- BOPT value type is in the accepted format.
-                                               return alignmentboptfieldvaluetypep
-  _ <- word8 44
-  alignmentboptfieldvaluedata <- do alignmentboptfieldvaluedatap <- DABL.takeTill (\x -> x == 09 || isEndOfLine x)
-                                    -- Parse BOPT value data of the alignment section.
-                                    case (alignmentboptfieldvaluedatap =~ [re|([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)*|]) of
-                                      False -> fail $ show SAM_V1_6_Error_Alignment_BOPT_Value_Data_Incorrect_Format
-                                      True  -> -- BOPT value data is in the accepted format.
-                                               return alignmentboptfieldvaluedatap
-  case (DBC8.unpack alignmentboptfieldvaluetype) of
-    "c" -> return SAM_V1_6_Alignment_BOPT { sam_v1_6_alignment_bopt_int8   = Just SAM_V1_6_Alignment_BOPT_Int8 { sam_v1_6_alignment_bopt_int8_tag   = DSeq.fromList $ DB.unpack alignmentboptfieldtag
-                                                                                                               , sam_v1_6_alignment_bopt_int8_type  = DB.head alignmentboptfieldvaluetype
-                                                                                                               , sam_v1_6_alignment_bopt_int8_value = fmap fromIntegral (DSeq.fromList $ DB.unpack alignmentboptfieldvaluedata)
-                                                                                                               }
-                                          , sam_v1_6_alignment_bopt_word8  = Nothing
-                                          , sam_v1_6_alignment_bopt_int16  = Nothing
-                                          , sam_v1_6_alignment_bopt_word16 = Nothing
-                                          , sam_v1_6_alignment_bopt_int32  = Nothing
-                                          , sam_v1_6_alignment_bopt_word32 = Nothing
-                                          , sam_v1_6_alignment_bopt_float  = Nothing
-                                          }
-    "C" -> return SAM_V1_6_Alignment_BOPT { sam_v1_6_alignment_bopt_int8   = Nothing
-                                          , sam_v1_6_alignment_bopt_word8  = Just SAM_V1_6_Alignment_BOPT_Word8 { sam_v1_6_alignment_bopt_word8_tag   = DSeq.fromList $ DB.unpack alignmentboptfieldtag
-                                                                                                                , sam_v1_6_alignment_bopt_word8_type  = DB.head alignmentboptfieldvaluetype
-                                                                                                                , sam_v1_6_alignment_bopt_word8_value = DSeq.fromList $ DB.unpack alignmentboptfieldvaluedata
-                                                                                                                } 
-                                          , sam_v1_6_alignment_bopt_int16  = Nothing
-                                          , sam_v1_6_alignment_bopt_word16 = Nothing
-                                          , sam_v1_6_alignment_bopt_int32  = Nothing
-                                          , sam_v1_6_alignment_bopt_word32 = Nothing
-                                          , sam_v1_6_alignment_bopt_float  = Nothing
-                                          }
-    "s" -> return SAM_V1_6_Alignment_BOPT { sam_v1_6_alignment_bopt_int8   = Nothing
-                                          , sam_v1_6_alignment_bopt_word8  = Nothing
-                                          , sam_v1_6_alignment_bopt_int16  = Just SAM_V1_6_Alignment_BOPT_Int16 { sam_v1_6_alignment_bopt_int16_tag   = DSeq.fromList $ DB.unpack alignmentboptfieldtag
-                                                                                                                , sam_v1_6_alignment_bopt_int16_type  = DB.head alignmentboptfieldvaluetype
-                                                                                                                , sam_v1_6_alignment_bopt_int16_value = fmap fromIntegral (DSeq.fromList $ DB.unpack alignmentboptfieldvaluedata)
-                                                                                                                }
-                                          , sam_v1_6_alignment_bopt_word16 = Nothing
-                                          , sam_v1_6_alignment_bopt_int32  = Nothing
-                                          , sam_v1_6_alignment_bopt_word32 = Nothing
-                                          , sam_v1_6_alignment_bopt_float  = Nothing
-                                          }
-    "S" -> return SAM_V1_6_Alignment_BOPT { sam_v1_6_alignment_bopt_int8   = Nothing
-                                          , sam_v1_6_alignment_bopt_word8  = Nothing
-                                          , sam_v1_6_alignment_bopt_int16  = Nothing
-                                          , sam_v1_6_alignment_bopt_word16 = Just SAM_V1_6_Alignment_BOPT_Word16 { sam_v1_6_alignment_bopt_word16_tag   = DSeq.fromList $ DB.unpack alignmentboptfieldtag
-                                                                                                                 , sam_v1_6_alignment_bopt_word16_type  = DB.head alignmentboptfieldvaluetype
-                                                                                                                 , sam_v1_6_alignment_bopt_word16_value = fmap fromIntegral (DSeq.fromList $ DB.unpack alignmentboptfieldvaluedata)
-                                                                                                                 }
-                                          , sam_v1_6_alignment_bopt_int32  = Nothing
-                                          , sam_v1_6_alignment_bopt_word32 = Nothing
-                                          , sam_v1_6_alignment_bopt_float  = Nothing
-                                          }
-    "i" -> return SAM_V1_6_Alignment_BOPT { sam_v1_6_alignment_bopt_int8   = Nothing
-                                          , sam_v1_6_alignment_bopt_word8  = Nothing
-                                          , sam_v1_6_alignment_bopt_int16  = Nothing
-                                          , sam_v1_6_alignment_bopt_word16 = Nothing
-                                          , sam_v1_6_alignment_bopt_int32  = Just SAM_V1_6_Alignment_BOPT_Int32 { sam_v1_6_alignment_bopt_int32_tag   = DSeq.fromList $ DB.unpack alignmentboptfieldtag
-                                                                                                                , sam_v1_6_alignment_bopt_int32_type  = DB.head alignmentboptfieldvaluetype
-                                                                                                                , sam_v1_6_alignment_bopt_int32_value = fmap fromIntegral (DSeq.fromList $ DB.unpack alignmentboptfieldvaluedata)
-                                                                                                                }
-                                          , sam_v1_6_alignment_bopt_word32 = Nothing
-                                          , sam_v1_6_alignment_bopt_float  = Nothing
-                                          }
-    "I" -> return SAM_V1_6_Alignment_BOPT { sam_v1_6_alignment_bopt_int8   = Nothing
-                                          , sam_v1_6_alignment_bopt_word8  = Nothing
-                                          , sam_v1_6_alignment_bopt_int16  = Nothing
-                                          , sam_v1_6_alignment_bopt_word16 = Nothing
-                                          , sam_v1_6_alignment_bopt_int32  = Nothing
-                                          , sam_v1_6_alignment_bopt_word32 = Just SAM_V1_6_Alignment_BOPT_Word32 { sam_v1_6_alignment_bopt_word32_tag   = DSeq.fromList $ DB.unpack alignmentboptfieldtag
-                                                                                                                 , sam_v1_6_alignment_bopt_word32_type  = DB.head alignmentboptfieldvaluetype
-                                                                                                                 , sam_v1_6_alignment_bopt_word32_value = fmap fromIntegral (DSeq.fromList $ DB.unpack alignmentboptfieldvaluedata)
-                                                                                                                 }
-                                          , sam_v1_6_alignment_bopt_float  = Nothing
-                                          }
-    "f" -> return SAM_V1_6_Alignment_BOPT { sam_v1_6_alignment_bopt_int8   = Nothing
-                                          , sam_v1_6_alignment_bopt_word8  = Nothing
-                                          , sam_v1_6_alignment_bopt_int16  = Nothing
-                                          , sam_v1_6_alignment_bopt_word16 = Nothing
-                                          , sam_v1_6_alignment_bopt_int32  = Nothing
-                                          , sam_v1_6_alignment_bopt_word32 = Nothing
-                                          , sam_v1_6_alignment_bopt_float  = Just SAM_V1_6_Alignment_BOPT_Float { sam_v1_6_alignment_bopt_float_tag   = DSeq.fromList $ DB.unpack alignmentboptfieldtag
-                                                                                                                , sam_v1_6_alignment_bopt_float_type  = DB.head alignmentboptfieldvaluetype
-                                                                                                                , sam_v1_6_alignment_bopt_float_value = fmap fromIntegral (DSeq.fromList $ DB.unpack alignmentboptfieldvaluedata)
-                                                                                                                }
-                                          }
-    _   -> return SAM_V1_6_Alignment_BOPT { sam_v1_6_alignment_bopt_int8   = Nothing
-                                          , sam_v1_6_alignment_bopt_word8  = Nothing
-                                          , sam_v1_6_alignment_bopt_int16  = Nothing
-                                          , sam_v1_6_alignment_bopt_word16 = Nothing
-                                          , sam_v1_6_alignment_bopt_int32  = Nothing
-                                          , sam_v1_6_alignment_bopt_word32 = Nothing
-                                          , sam_v1_6_alignment_bopt_float  = Nothing
-                                          }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Alignment/Base.hs b/src/Data/SAM/Version1_6/Read/Parser/Alignment/Base.hs
--- a/src/Data/SAM/Version1_6/Read/Parser/Alignment/Base.hs
+++ b/src/Data/SAM/Version1_6/Read/Parser/Alignment/Base.hs
@@ -6,7 +6,6 @@
 {-# LANGUAGE OverloadedLists             #-}
 {-# LANGUAGE OverloadedStrings           #-}
 {-# LANGUAGE MultiWayIf                  #-}
-{-# LANGUAGE PackageImports              #-}
 {-# LANGUAGE RecordWildCards             #-}
 {-# LANGUAGE TypeFamilies                #-}
 {-# Language QuasiQuotes                 #-}
@@ -14,7 +13,7 @@
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Read.Parser.Alignment.Base
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -45,17 +44,20 @@
 
 import Data.SAM.Version1_6.Alignment
 import Data.SAM.Version1_6.Read.Error
-import Data.SAM.Version1_6.Read.Parser.Alignment.AOPT
-import Data.SAM.Version1_6.Read.Parser.Alignment.IOPT
-import Data.SAM.Version1_6.Read.Parser.Alignment.FOPT
-import Data.SAM.Version1_6.Read.Parser.Alignment.ZOPT
-import Data.SAM.Version1_6.Read.Parser.Alignment.HOPT
-import Data.SAM.Version1_6.Read.Parser.Alignment.BOPT
+import Data.SAM.Version1_6.Alignment.OptionalFields.Base
+import Data.SAM.Version1_6.Read.Parser.Alignment.OptionalFields.AOPT
+import Data.SAM.Version1_6.Read.Parser.Alignment.OptionalFields.IOPT
+import Data.SAM.Version1_6.Read.Parser.Alignment.OptionalFields.FOPT
+import Data.SAM.Version1_6.Read.Parser.Alignment.OptionalFields.ZOPT
+import Data.SAM.Version1_6.Read.Parser.Alignment.OptionalFields.HOPT
+import Data.SAM.Version1_6.Read.Parser.Alignment.OptionalFields.BOPT
 
-import           Control.Applicative.Permutations           (intercalateEffect,toPermutationWithDefault)
 import           Data.Attoparsec.ByteString.Char8  as DABC8 (endOfLine,isEndOfLine)
 import           Data.Attoparsec.ByteString.Lazy   as DABL
+import qualified Data.ByteString                   as DB
 import qualified Data.ByteString.Char8             as DBC8
+import           Data.List                         as DL    (intercalate)
+import           Data.Sequence                     as DSeq  (empty,Seq(..))
 import           Text.Regex.PCRE.Heavy
 
 -- | @"SAM_V1_6_Alignment"@ parser.
@@ -65,159 +67,486 @@
 -- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
 parse_SAM_V1_6_Alignment :: Parser SAM_V1_6_Alignment
 parse_SAM_V1_6_Alignment = do
-  qname <- do qnamep <- DABL.takeTill (== 09)
-              -- Parse QNAME field of alignment section.
-              case (qnamep =~ [re|[!-?A-~]{1,254}|\*|]) of
-                False -> fail $ show SAM_V1_6_Error_Alignment_QNAME_Incorrect_Format
-                True  -> -- QNAME is in the accepted format.
-                         return qnamep
-  _ <- word8 09
-  flag <- do flagp <- DABL.takeTill (== 09)
-             -- Parse FLAG field of alignment section.
-             case (flagp =~ [re|[0-9]+|]) of
-               False -> fail $ show SAM_V1_6_Error_Alignment_FLAG_Incorrect_Format
-               True  -> -- FLAG is in the accepted format.
-                        return flagp
-  _ <- word8 09
-  rname <- do rnamep <- DABL.takeTill (== 09)
-              -- Parse RNAME field of alignment section.
-              case (rnamep =~ [re|\*|[0-9A-Za-z!#$%&+.:;?@^_|~-][0-9A-Za-z!#$%&*+.:;=?@^_|~-]*|]) of
-                False -> fail $ show SAM_V1_6_Error_Alignment_RNAME_Incorrect_Format 
-                True  -> -- RNAME is in the accepted format.
-                         return rnamep
-  _ <- word8 09
-  pos <- do posp <- DABL.takeTill (== 09)
-            -- Parse POS field of the alignment section.
-            case (posp =~ [re|[0-9]+|]) of
-              False -> fail $ show SAM_V1_6_Error_Alignment_POS_Incorrect_Format
-              True  -> -- POS is in the accepted format.
-                       return posp
-  _ <- word8 09
-  mapq <- do mapqp <- DABL.takeTill (== 09)
-             -- Parse MAPQ field of the alignment section.
-             case (mapqp =~ [re|[0-9]+|]) of
-               False -> fail $ show SAM_V1_6_Error_Alignment_MAPQ_Incorrect_Format
-               True  -> -- MAPQ is in the accepted format.
-                        return mapqp
-  _ <- word8 09
-  cigar <- do cigarp <- DABL.takeTill (== 09)
-              -- Parse CIGAR field of alignment section.
-              case (cigarp =~ [re|\*|([0-9]+[MIDNSHPX=])+|]) of
-                False -> fail $ show SAM_V1_6_Error_Alignment_CIGAR_Incorrect_Format
-                True  -> -- CIGAR is in the accepted format.
-                         return cigarp
-  _ <- word8 09
-  rnext <- do rnextp <- DABL.takeTill (== 09)
-              -- Parse RNEXT field of the alignment section.
-              case (rnextp =~ [re|\*|=|[0-9A-Za-z!#$%&+.:;?@^_|~-][0-9A-Za-z!#$%&*+.:;=?@^_|~-]*|]) of
-                False -> fail $ show SAM_V1_6_Error_Alignment_RNEXT_Incorrect_Format
-                True  -> -- RNEXT is in the accepted format.
-                         return rnextp
-  _ <- word8 09
-  pnext <- do pnextp <- DABL.takeTill (== 09)
-              -- Parse PNEXT field of the alignment section.
-              case (pnextp =~ [re|[0-9]+|]) of
-                False -> fail $ show SAM_V1_6_Error_Alignment_PNEXT_Incorrect_Format
-                True  -> -- PNEXT is in the accepted format.
-                         return pnextp
-  _ <- word8 09
-  tlen <- do tlenp <- DABL.takeTill (== 09)
-             -- Parse TLEN field of the alignment section.
-             case (tlenp =~ [re|[-]?[0-9]+|]) of
-               False -> fail $ show SAM_V1_6_Error_Alignment_TLEN_Incorrect_Format 
-               True  -> -- TLEN is in the accepted format.
-                        return tlenp
-  _ <- word8 09
-  seq <- do seqp <- DABL.takeTill (== 09)
-            -- Parse SEQ field of the alignment section.
-            case (seqp =~ [re|\*|[A-Za-z=.]+|]) of
-              False -> fail $ show SAM_V1_6_Error_Alignment_SEQ_Incorrect_Format 
-              True  -> -- SEQ is in the accepted format.
-                       return seqp
-  _ <- word8 09
-  qual <- do qualp <- DABL.takeTill (\x -> x == 09 || isEndOfLine x)
-             -- Parse QUAL field of the alignment section.
-             case (qualp =~ [re|[!-~?]+|\*|]) of
-               False -> fail $ show SAM_V1_6_Error_Alignment_QUAL_Incorrect_Format
-               True  -> -- QUAL is in the accepted format.
-                        return qualp 
-  optfields <- peekWord8
+  qname <- do
+    qnamep <-
+      DABL.takeTill (== 09)
+    -- Parse QNAME field of alignment section.
+    case (qnamep =~ [re|[!-?A-~]{1,254}|\*|]) of
+      False ->
+        fail $
+          show SAM_V1_6_Error_Alignment_QNAME_Incorrect_Format
+      True  ->
+        -- QNAME is in the accepted format.
+        return qnamep
+  _ <-
+    word8 09
+  flag <- do
+    flagp <-
+      DABL.takeTill (== 09)
+    -- Parse FLAG field of alignment section.
+    case (flagp =~ [re|[0-9]+|]) of
+      False ->
+        fail $
+          show SAM_V1_6_Error_Alignment_FLAG_Incorrect_Format
+      True  ->
+        -- FLAG is in the accepted format.
+        return flagp
+  _ <-
+    word8 09
+  rname <- do
+    rnamep <-
+      DABL.takeTill (== 09)
+    -- Parse RNAME field of alignment section.
+    case (rnamep =~ [re|\*|[0-9A-Za-z!#$%&+.:;?@^_|~-][0-9A-Za-z!#$%&*+.:;=?@^_|~-]*|]) of
+      False ->
+        fail $
+          show SAM_V1_6_Error_Alignment_RNAME_Incorrect_Format 
+      True  ->
+        -- RNAME is in the accepted format.
+        return rnamep
+  _ <-
+    word8 09
+  pos <- do
+    posp <-
+      DABL.takeTill (== 09)
+    -- Parse POS field of the alignment section.
+    case (posp =~ [re|[0-9]+|]) of
+      False ->
+        fail $
+          show SAM_V1_6_Error_Alignment_POS_Incorrect_Format
+      True  ->
+        -- POS is in the accepted format.
+        return posp
+  _ <-
+    word8 09
+  mapq <- do
+    mapqp <-
+      DABL.takeTill (== 09)
+    -- Parse MAPQ field of the alignment section.
+    case (mapqp =~ [re|[0-9]+|]) of
+      False ->
+        fail $
+          show SAM_V1_6_Error_Alignment_MAPQ_Incorrect_Format
+      True  ->
+        -- MAPQ is in the accepted format.
+        return mapqp
+  _ <-
+    word8 09
+  cigar <- do
+    cigarp <-
+      DABL.takeTill (== 09)
+    -- Parse CIGAR field of alignment section.
+    case (cigarp =~ [re|\*|([0-9]+[MIDNSHPX=])+|]) of
+      False ->
+        fail $
+          show SAM_V1_6_Error_Alignment_CIGAR_Incorrect_Format
+      True  ->
+        -- CIGAR is in the accepted format.
+        return cigarp
+  _ <-
+    word8 09
+  rnext <- do
+    rnextp <-
+      DABL.takeTill (== 09)
+    -- Parse RNEXT field of the alignment section.
+    case (rnextp =~ [re|\*|=|[0-9A-Za-z!#$%&+.:;?@^_|~-][0-9A-Za-z!#$%&*+.:;=?@^_|~-]*|]) of
+      False ->
+        fail $
+          show SAM_V1_6_Error_Alignment_RNEXT_Incorrect_Format
+      True  ->
+        -- RNEXT is in the accepted format.
+        return rnextp
+  _ <-
+    word8 09
+  pnext <- do
+    pnextp <-
+      DABL.takeTill (== 09)
+    -- Parse PNEXT field of the alignment section.
+    case (pnextp =~ [re|[0-9]+|]) of
+      False ->
+        fail $
+          show SAM_V1_6_Error_Alignment_PNEXT_Incorrect_Format
+      True  ->
+        -- PNEXT is in the accepted format.
+        return pnextp
+  _ <-
+    word8 09
+  tlen <- do
+    tlenp <-
+      DABL.takeTill (== 09)
+    -- Parse TLEN field of the alignment section.
+    case (tlenp =~ [re|[-]?[0-9]+|]) of
+      False ->
+        fail $
+          show SAM_V1_6_Error_Alignment_TLEN_Incorrect_Format 
+      True  ->
+        -- TLEN is in the accepted format.
+        return tlenp
+  _ <-
+    word8 09
+  seq <- do
+    seqp <-
+      DABL.takeTill (== 09)
+    -- Parse SEQ field of the alignment section.
+    case (seqp =~ [re|\*|[A-Za-z=.]+|]) of
+      False ->
+        fail $
+          show SAM_V1_6_Error_Alignment_SEQ_Incorrect_Format 
+      True  ->
+        -- SEQ is in the accepted format.
+        return seqp
+  _ <-
+    word8 09
+  qual <- do
+    qualp <-
+      DABL.takeTill (\x -> x == 09 || isEndOfLine x)
+    -- Parse QUAL field of the alignment section.
+    case (qualp =~ [re|[!-~?]+|\*|]) of
+      False ->
+        fail $
+          show SAM_V1_6_Error_Alignment_QUAL_Incorrect_Format
+      True  ->
+        -- QUAL is in the accepted format.
+        return qualp 
+  optfields <-
+    peekWord8
   case optfields of
-    Just 10 -> do -- Return the parsed SAM_V1_6.
-                  _ <- endOfLine
-                  return SAM_V1_6_Alignment { sam_v1_6_alignment_qname  = qname
-                                            , sam_v1_6_alignment_flag   = case (DBC8.readInt flag) of
-                                                                            Nothing          -> (-1)
-                                                                            Just (flagint,_) -> flagint
-                                            , sam_v1_6_alignment_rname = rname
-                                            , sam_v1_6_alignment_pos   = case (DBC8.readInteger pos) of
-                                                                           Nothing             -> 0
-                                                                           Just (posinteger,_) -> posinteger
-                                            , sam_v1_6_alignment_mapq  = case (DBC8.readInt mapq) of
-                                                                           Nothing          -> 255
-                                                                           Just (mapqint,_) -> mapqint
-                                            , sam_v1_6_alignment_cigar = cigar
-                                            , sam_v1_6_alignment_rnext = rnext
-                                            , sam_v1_6_alignment_pnext = case (DBC8.readInteger pnext) of
-                                                                           Nothing               -> 0
-                                                                           Just (pnextinteger,_) -> pnextinteger
-                                            , sam_v1_6_alignment_tlen  = case (DBC8.readInteger tlen) of
-                                                                           Nothing              -> 0
-                                                                           Just (tleninteger,_) -> tleninteger
-                                            , sam_v1_6_alignment_seq   = seq
-                                            , sam_v1_6_alignment_qual  = qual
-                                            , sam_v1_6_alignment_aopt  = Nothing
-                                            , sam_v1_6_alignment_iopt  = Nothing
-                                            , sam_v1_6_alignment_fopt  = Nothing
-                                            , sam_v1_6_alignment_zopt  = Nothing
-                                            , sam_v1_6_alignment_hopt  = Nothing
-                                            , sam_v1_6_alignment_bopt  = Nothing
-                                            }
-    _       -> do -- This parser assumes that
-                  -- the AOPT, IOPT, FOPT, ZOPT, HOPT, and BOPT
-                  -- tags can appear in any order.
-                  _ <- word8 09
-                  optionalfields <- intercalateEffect (word8 09) $
-                                      (,,,,,)
-                                        <$> toPermutationWithDefault Nothing
-                                                                     (Just <$> parse_SAM_V1_6_Alignment_AOPT)
-                                        <*> toPermutationWithDefault Nothing
-                                                                     (Just <$> parse_SAM_V1_6_Alignment_IOPT)
-                                        <*> toPermutationWithDefault Nothing
-                                                                     (Just <$> parse_SAM_V1_6_Alignment_FOPT)
-                                        <*> toPermutationWithDefault Nothing
-                                                                     (Just <$> parse_SAM_V1_6_Alignment_ZOPT)
-                                        <*> toPermutationWithDefault Nothing
-                                                                     (Just <$> parse_SAM_V1_6_Alignment_HOPT)
-                                        <*> toPermutationWithDefault Nothing
-                                                                     (Just <$> parse_SAM_V1_6_Alignment_BOPT)
-                  _ <- endOfLine 
-                  -- Return the parsed SAM_V1_6.
-                  return SAM_V1_6_Alignment { sam_v1_6_alignment_qname  = qname
-                                            , sam_v1_6_alignment_flag   = case (DBC8.readInt flag) of
-                                                                            Nothing          -> (-1)
-                                                                            Just (flagint,_) -> flagint
-                                            , sam_v1_6_alignment_rname = rname
-                                            , sam_v1_6_alignment_pos   = case (DBC8.readInteger pos) of
-                                                                           Nothing             -> 0
-                                                                           Just (posinteger,_) -> posinteger
-                                            , sam_v1_6_alignment_mapq  = case (DBC8.readInt mapq) of
-                                                                           Nothing          -> 255
-                                                                           Just (mapqint,_) -> mapqint
-                                            , sam_v1_6_alignment_cigar = cigar
-                                            , sam_v1_6_alignment_rnext = rnext
-                                            , sam_v1_6_alignment_pnext = case (DBC8.readInteger pnext) of
-                                                                           Nothing               -> 0
-                                                                           Just (pnextinteger,_) -> pnextinteger
-                                            , sam_v1_6_alignment_tlen  = case (DBC8.readInteger tlen) of
-                                                                           Nothing              -> 0
-                                                                           Just (tleninteger,_) -> tleninteger
-                                            , sam_v1_6_alignment_seq   = seq
-                                            , sam_v1_6_alignment_qual  = qual
-                                            , sam_v1_6_alignment_aopt  = (\(a,_,_,_,_,_) -> a) optionalfields
-                                            , sam_v1_6_alignment_iopt  = (\(_,i,_,_,_,_) -> i) optionalfields
-                                            , sam_v1_6_alignment_fopt  = (\(_,_,f,_,_,_) -> f) optionalfields
-                                            , sam_v1_6_alignment_zopt  = (\(_,_,_,z,_,_) -> z) optionalfields
-                                            , sam_v1_6_alignment_hopt  = (\(_,_,_,_,h,_) -> h) optionalfields
-                                            , sam_v1_6_alignment_bopt  = (\(_,_,_,_,_,b) -> b) optionalfields
-                                            }
+    Just 10 -> do
+      -- Return the parsed SAM_V1_6.
+      _ <-
+        endOfLine
+      return SAM_V1_6_Alignment { sam_v1_6_alignment_qname          = qname
+                                , sam_v1_6_alignment_flag           = case (DBC8.readInt flag) of
+                                                                        Nothing          ->
+                                                                          (-1)
+                                                                        Just (flagint,_) ->
+                                                                          flagint
+                                , sam_v1_6_alignment_rname          = rname
+                                , sam_v1_6_alignment_pos            = case (DBC8.readInteger pos) of
+                                                                        Nothing             ->
+                                                                          0
+                                                                        Just (posinteger,_) ->
+                                                                          posinteger
+                                , sam_v1_6_alignment_mapq           = case (DBC8.readInt mapq) of
+                                                                        Nothing          ->
+                                                                          255
+                                                                        Just (mapqint,_) ->
+                                                                          mapqint
+                                , sam_v1_6_alignment_cigar          = cigar
+                                , sam_v1_6_alignment_rnext          = rnext
+                                , sam_v1_6_alignment_pnext          = case (DBC8.readInteger pnext) of
+                                                                        Nothing               ->
+                                                                          0
+                                                                        Just (pnextinteger,_) ->
+                                                                          pnextinteger
+                                , sam_v1_6_alignment_tlen           = case (DBC8.readInteger tlen) of
+                                                                        Nothing              ->
+                                                                          0
+                                                                        Just (tleninteger,_) ->
+                                                                          tleninteger
+                                , sam_v1_6_alignment_seq            = seq
+                                , sam_v1_6_alignment_qual           = qual
+                                , sam_v1_6_alignment_optionalfields = Nothing
+                                }
+    _       -> do
+      -- This parser assumes that
+      -- the AOPT, IOPT, FOPT, ZOPT, HOPT, and BOPT
+      -- tags can appear in any order.
+      _                   <-
+        word8 09
+      optionalfieldsbytes <-
+        DABL.takeTill isEndOfLine
+      optionalfields      <-
+        return $
+          parse_OptionalFields optionalfieldsbytes
+      _                   <-
+        endOfLine
+      -- Return the parsed SAM_V1_6.
+      return SAM_V1_6_Alignment { sam_v1_6_alignment_qname          = qname
+                                , sam_v1_6_alignment_flag           = case (DBC8.readInt flag) of
+                                                                        Nothing          ->
+                                                                          (-1)
+                                                                        Just (flagint,_) ->
+                                                                          flagint
+                                , sam_v1_6_alignment_rname          = rname
+                                , sam_v1_6_alignment_pos            = case (DBC8.readInteger pos) of
+                                                                        Nothing             ->
+                                                                          0
+                                                                        Just (posinteger,_) ->
+                                                                          posinteger
+                                , sam_v1_6_alignment_mapq           = case (DBC8.readInt mapq) of
+                                                                        Nothing          ->
+                                                                          255
+                                                                        Just (mapqint,_) ->
+                                                                          mapqint
+                                , sam_v1_6_alignment_cigar          = cigar
+                                , sam_v1_6_alignment_rnext          = rnext
+                                , sam_v1_6_alignment_pnext          = case (DBC8.readInteger pnext) of
+                                                                        Nothing               ->
+                                                                          0
+                                                                        Just (pnextinteger,_) ->
+                                                                          pnextinteger
+                                , sam_v1_6_alignment_tlen           = case (DBC8.readInteger tlen) of
+                                                                        Nothing              ->
+                                                                          0
+                                                                        Just (tleninteger,_) ->
+                                                                          tleninteger
+                                , sam_v1_6_alignment_seq            = seq
+                                , sam_v1_6_alignment_qual           = qual
+                                , sam_v1_6_alignment_optionalfields = Just optionalfields
+                                }
+  where
+    parse_OptionalFields :: DB.ByteString
+                         -> Seq SAM_V1_6_Alignment_OptionalFields
+    parse_OptionalFields bs = do
+      case DB.null bs of
+        True  ->
+          DSeq.empty
+        False ->
+          case DB.indexMaybe bs 3 of
+            Nothing   ->
+              error $
+                show SAM_V1_6_Read_Error_Alignment_OptionalFields_Index_Missing
+            -- AOPT <-> 'A'
+            Just 0x41 ->
+              case ( DABL.parse parse_SAM_V1_6_Alignment_OptionalFields_AOPT
+                                ( DB.fromStrict $
+                                    DB.takeWhile (/= 0x09)
+                                                 bs
+                                )
+                   ) of
+                Fail _
+                     ctxs
+                     err ->
+                  error  $
+                    show $ "Error while parsing AOPT field." ++
+                           "\n"                              ++
+                           "Parsing contexts: "              ++
+                           (intercalate ", " ctxs)           ++
+                           "\n"                              ++
+                           "Error message: "                 ++
+                           err
+                Done remainingbytes
+                     parsedbs -> do
+                  let strictremainingbytes = DB.toStrict remainingbytes
+                  case DB.null strictremainingbytes of
+                    True  ->
+                      SAM_V1_6_Alignment_OptionalFields
+                        { sam_v1_6_alignment_optionalfields_aopt  = Just parsedbs
+                        , sam_v1_6_alignment_optionalfields_iopt  = Nothing
+                        , sam_v1_6_alignment_optionalfields_fopt  = Nothing
+                        , sam_v1_6_alignment_optionalfields_zopt  = Nothing
+                        , sam_v1_6_alignment_optionalfields_hopt  = Nothing
+                        , sam_v1_6_alignment_optionalfields_bopt  = Nothing
+                        }
+                      DSeq.:<|
+                        parse_OptionalFields ( DB.drop 1 $
+                                                       DB.dropWhile (/= 0x09)
+                                                                    bs
+                                             )
+                    False ->
+                      error $
+                        show SAM_V1_6_Read_Error_Alignment_OptionalFields_Remaining_Bytes
+            -- IOPT <-> 'i'
+            Just 0x69 ->
+              case ( DABL.parse parse_SAM_V1_6_Alignment_OptionalFields_IOPT
+                                ( DB.fromStrict $
+                                    DB.takeWhile (/= 0x09)
+                                                 bs
+                                )
+                   ) of
+                Fail _
+                     ctxs
+                     err ->
+                  error  $
+                    show $ "Error while parsing IOPT field." ++
+                           "\n"                              ++
+                           "Parsing contexts: "              ++
+                           (intercalate ", " ctxs)           ++
+                           "\n"                              ++
+                           "Error message: "                 ++
+                           err
+                Done remainingbytes
+                     parsedbs -> do
+                  let strictremainingbytes = DB.toStrict remainingbytes
+                  case DB.null strictremainingbytes of
+                    True  ->
+                      SAM_V1_6_Alignment_OptionalFields
+                        { sam_v1_6_alignment_optionalfields_aopt  = Nothing
+                        , sam_v1_6_alignment_optionalfields_iopt  = Just parsedbs
+                        , sam_v1_6_alignment_optionalfields_fopt  = Nothing
+                        , sam_v1_6_alignment_optionalfields_zopt  = Nothing
+                        , sam_v1_6_alignment_optionalfields_hopt  = Nothing
+                        , sam_v1_6_alignment_optionalfields_bopt  = Nothing
+                        }
+                      DSeq.:<|
+                      parse_OptionalFields ( DB.drop 1 $
+                                               DB.dropWhile (/= 0x09)
+                                                            bs
+                                           )
+                    False ->
+                      error $
+                        show SAM_V1_6_Read_Error_Alignment_OptionalFields_Remaining_Bytes
+            -- FOPT <-> 'f'
+            Just 0x66 ->
+              case ( DABL.parse parse_SAM_V1_6_Alignment_OptionalFields_FOPT
+                                ( DB.fromStrict $
+                                    DB.takeWhile (/= 0x09)
+                                                 bs
+                                )
+                   ) of
+                Fail _
+                     ctxs
+                     err ->
+                  error  $
+                    show $ "Error while parsing FOPT field." ++
+                           "\n"                              ++
+                           "Parsing contexts: "              ++
+                           (intercalate ", " ctxs)           ++
+                           "\n"                              ++
+                           "Error message: "                 ++
+                           err
+                Done remainingbytes
+                     parsedbs -> do
+                  let strictremainingbytes = DB.toStrict remainingbytes
+                  case DB.null strictremainingbytes of
+                    True  ->
+                      SAM_V1_6_Alignment_OptionalFields
+                        { sam_v1_6_alignment_optionalfields_aopt  = Nothing
+                        , sam_v1_6_alignment_optionalfields_iopt  = Nothing
+                        , sam_v1_6_alignment_optionalfields_fopt  = Just parsedbs
+                        , sam_v1_6_alignment_optionalfields_zopt  = Nothing
+                        , sam_v1_6_alignment_optionalfields_hopt  = Nothing
+                        , sam_v1_6_alignment_optionalfields_bopt  = Nothing
+                        }                      
+                      DSeq.:<|
+                      parse_OptionalFields ( DB.drop 1 $
+                                               DB.dropWhile (/= 0x09)
+                                                            bs
+                                           )
+                    False ->
+                      error $
+                        show SAM_V1_6_Read_Error_Alignment_OptionalFields_Remaining_Bytes
+            -- ZOPT <-> 'Z'
+            Just 0x5A ->
+              case ( DABL.parse parse_SAM_V1_6_Alignment_OptionalFields_ZOPT
+                                ( DB.fromStrict $
+                                    DB.takeWhile (/= 0x09)
+                                                 bs
+                                )
+                   ) of
+                Fail _
+                     ctxs
+                     err ->
+                  error  $
+                    show $ "Error while parsing ZOPT field." ++
+                           "\n"                              ++
+                           "Parsing contexts: "              ++
+                           (intercalate ", " ctxs)           ++
+                           "\n"                              ++
+                           "Error message: "                 ++
+                           err
+                Done remainingbytes
+                     parsedbs -> do
+                  let strictremainingbytes = DB.toStrict remainingbytes
+                  case DB.null strictremainingbytes of
+                    True  ->
+                      SAM_V1_6_Alignment_OptionalFields
+                        { sam_v1_6_alignment_optionalfields_aopt  = Nothing
+                        , sam_v1_6_alignment_optionalfields_iopt  = Nothing
+                        , sam_v1_6_alignment_optionalfields_fopt  = Nothing
+                        , sam_v1_6_alignment_optionalfields_zopt  = Just parsedbs
+                        , sam_v1_6_alignment_optionalfields_hopt  = Nothing
+                        , sam_v1_6_alignment_optionalfields_bopt  = Nothing
+                        }
+                      DSeq.:<|
+                      parse_OptionalFields ( DB.drop 1 $
+                                               DB.dropWhile (/= 0x09)
+                                                            bs
+                                           )
+                    False ->
+                      error $
+                        show SAM_V1_6_Read_Error_Alignment_OptionalFields_Remaining_Bytes
+            -- HOPT <-> 'H'
+            Just 0x48 ->
+              case ( DABL.parse parse_SAM_V1_6_Alignment_OptionalFields_HOPT
+                                ( DB.fromStrict $
+                                    DB.takeWhile (/= 0x09)
+                                                 bs
+                                )
+                   ) of
+                Fail _
+                     ctxs
+                     err ->
+                  error  $
+                    show $ "Error while parsing HOPT field." ++
+                           "\n"                              ++
+                           "Parsing contexts: "              ++
+                           (intercalate ", " ctxs)           ++
+                           "\n"                              ++
+                           "Error message: "                 ++
+                           err
+                Done remainingbytes
+                     parsedbs -> do
+                  let strictremainingbytes = DB.toStrict remainingbytes
+                  case DB.null strictremainingbytes of
+                    True  ->
+                      SAM_V1_6_Alignment_OptionalFields
+                        { sam_v1_6_alignment_optionalfields_aopt  = Nothing
+                        , sam_v1_6_alignment_optionalfields_iopt  = Nothing
+                        , sam_v1_6_alignment_optionalfields_fopt  = Nothing
+                        , sam_v1_6_alignment_optionalfields_zopt  = Nothing
+                        , sam_v1_6_alignment_optionalfields_hopt  = Just parsedbs
+                        , sam_v1_6_alignment_optionalfields_bopt  = Nothing
+                        }
+                      DSeq.:<|
+                      parse_OptionalFields ( DB.drop 1 $
+                                               DB.dropWhile (/= 0x09)
+                                                            bs
+                                           )
+                    False ->
+                      error $
+                        show SAM_V1_6_Read_Error_Alignment_OptionalFields_Remaining_Bytes
+            -- BOPT <-> 'B'
+            Just 0x42 ->
+              case ( DABL.parse parse_SAM_V1_6_Alignment_OptionalFields_BOPT
+                                ( DB.fromStrict $
+                                    DB.takeWhile (/= 0x09)
+                                                 bs
+                                )
+                   ) of
+                Fail _
+                     ctxs
+                     err ->
+                  error  $
+                    show $ "Error while parsing BOPT field." ++
+                           "\n"                              ++
+                           "Parsing contexts: "              ++
+                           (intercalate ", " ctxs)           ++
+                           "\n"                              ++
+                           "Error message: "                 ++
+                           err
+                Done remainingbytes
+                     parsedbs -> do
+                  let strictremainingbytes = DB.toStrict remainingbytes
+                  case DB.null strictremainingbytes of
+                    True  ->
+                      SAM_V1_6_Alignment_OptionalFields
+                        { sam_v1_6_alignment_optionalfields_aopt  = Nothing
+                        , sam_v1_6_alignment_optionalfields_iopt  = Nothing
+                        , sam_v1_6_alignment_optionalfields_fopt  = Nothing
+                        , sam_v1_6_alignment_optionalfields_zopt  = Nothing
+                        , sam_v1_6_alignment_optionalfields_hopt  = Nothing
+                        , sam_v1_6_alignment_optionalfields_bopt  = Just parsedbs
+                        }
+                      DSeq.:<|
+                      parse_OptionalFields ( DB.drop 1 $
+                                               DB.dropWhile (/= 0x09)
+                                                            bs
+                                           )
+                    False ->
+                      error $
+                        show SAM_V1_6_Read_Error_Alignment_OptionalFields_Remaining_Bytes
+            _    ->
+              error $
+                show SAM_V1_6_Read_Error_Alignment_OptionalFields_BOPT_Missing_Type
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Alignment/FOPT.hs b/src/Data/SAM/Version1_6/Read/Parser/Alignment/FOPT.hs
deleted file mode 100644
--- a/src/Data/SAM/Version1_6/Read/Parser/Alignment/FOPT.hs
+++ /dev/null
@@ -1,83 +0,0 @@
-{-# LANGUAGE DeriveDataTypeable    #-}
-{-# LANGUAGE DeriveGeneric         #-}
-{-# LANGUAGE FlexibleContexts      #-}
-{-# LANGUAGE FlexibleInstances     #-}
-{-# LANGUAGE MultiParamTypeClasses #-}
-{-# LANGUAGE OverloadedLists       #-}
-{-# LANGUAGE OverloadedStrings     #-}
-{-# LANGUAGE MultiWayIf            #-}
-{-# LANGUAGE PackageImports        #-}
-{-# LANGUAGE RecordWildCards       #-}
-{-# LANGUAGE ScopedTypeVariables   #-}
-{-# LANGUAGE TypeFamilies          #-}
-{-# Language QuasiQuotes           #-}
-
--- |
--- Module      :  Data.SAM.Version1_6.Read.Parser.Alignment.FOPT
--- Copyright   :  (c) Matthew Mosior 2023
--- License     :  BSD-style
--- Maintainer  :  mattm.github@gmail.com
--- Portability :  portable
---
--- = WARNING
---
--- This module is considered __internal__.
---
--- The Package Versioning Policy __does not apply__.
---
--- The contents of this module may change __in any way whatsoever__
--- and __without any warning__ between minor versions of this package.
---
--- Authors importing this library are expected to track development
--- closely.
---
--- All credit goes to the author(s)/maintainer(s) of the
--- [containers](https://hackage.haskell.org/package/containers) library
--- for the above warning text.
---
--- = Description
---
--- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
-
-module Data.SAM.Version1_6.Read.Parser.Alignment.FOPT ( -- * SAM_V1_6 parser - alignment section - fopt field 
-                                                        parse_SAM_V1_6_Alignment_FOPT
-                                                      ) where
-
-import Data.SAM.Version1_6.Alignment.FOPT
-import Data.SAM.Version1_6.Read.Error
-
-import           Data.Attoparsec.ByteString.Char8  as DABC8 (isEndOfLine)
-import           Data.Attoparsec.ByteString.Lazy   as DABL
-import qualified Data.ByteString.Char8             as DBC8
-import           Text.Regex.PCRE.Heavy
-
--- | Defines a parser for the optional fopt field of alignment section of the SAM v1.6 file format.
---
--- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
-parse_SAM_V1_6_Alignment_FOPT :: Parser SAM_V1_6_Alignment_FOPT
-parse_SAM_V1_6_Alignment_FOPT = do
-  alignmentfoptfieldtag <- do alignmentfoptfieldtagp <- DABL.takeTill (== 58)
-                              -- Parse FOPT tag of the alignment section.
-                              case (alignmentfoptfieldtagp =~ [re|[A-Za-z][A-Za-z0-9]|]) of
-                                False -> fail $ show SAM_V1_6_Error_Alignment_FOPT_Tag_Incorrect_Format
-                                True  -> -- FOPT tag is in the accepted format. 
-                                         return alignmentfoptfieldtagp
-  _ <- word8 58
-  _ <- do alignmentfoptfieldtypep <- DABL.takeTill (== 58)
-          -- Parse FOPT type of the alignment section.
-          case (alignmentfoptfieldtypep =~ [re|[f]|]) of
-            False -> fail $ show SAM_V1_6_Error_Alignment_FOPT_Type_Incorrect_Format
-            True  -> -- FOPT type is in the accepted format.
-                     return ()
-  _ <- word8 58
-  alignmentfoptfieldvalue <- do alignmentfoptfieldvaluep <- DABL.takeTill (\x -> x == 09 || isEndOfLine x)
-                                -- Parse FOPT value of the alignment section.
-                                case (alignmentfoptfieldvaluep =~ [re|[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?|]) of
-                                  False -> fail $ show SAM_V1_6_Error_Alignment_FOPT_Value_Incorrect_Format
-                                  True  -> -- FOPT value is in the accepted format.
-                                           case (DBC8.readInteger alignmentfoptfieldvaluep) of
-                                             Nothing                                 -> return (-1)
-                                             Just (alignmentfoptfieldvalueinteger,_) -> return $ (fromInteger alignmentfoptfieldvalueinteger :: Float)
-  return SAM_V1_6_Alignment_FOPT { sam_v1_6_alignment_fopt_tag   = alignmentfoptfieldtag
-                                 , sam_v1_6_alignment_fopt_value = alignmentfoptfieldvalue
-                                 } 
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Alignment/HOPT.hs b/src/Data/SAM/Version1_6/Read/Parser/Alignment/HOPT.hs
deleted file mode 100644
--- a/src/Data/SAM/Version1_6/Read/Parser/Alignment/HOPT.hs
+++ /dev/null
@@ -1,80 +0,0 @@
-{-# LANGUAGE DeriveDataTypeable    #-}
-{-# LANGUAGE DeriveGeneric         #-}
-{-# LANGUAGE FlexibleContexts      #-}
-{-# LANGUAGE FlexibleInstances     #-}
-{-# LANGUAGE MultiParamTypeClasses #-}
-{-# LANGUAGE OverloadedLists       #-}
-{-# LANGUAGE OverloadedStrings     #-}
-{-# LANGUAGE MultiWayIf            #-}
-{-# LANGUAGE PackageImports        #-}
-{-# LANGUAGE RecordWildCards       #-}
-{-# LANGUAGE ScopedTypeVariables   #-}
-{-# LANGUAGE TypeFamilies          #-}
-{-# Language QuasiQuotes           #-}
-
--- |
--- Module      :  Data.SAM.Version1_6.Read.Parser.Alignment.HOPT
--- Copyright   :  (c) Matthew Mosior 2023
--- License     :  BSD-style
--- Maintainer  :  mattm.github@gmail.com
--- Portability :  portable
---
--- = WARNING
---
--- This module is considered __internal__.
---
--- The Package Versioning Policy __does not apply__.
---
--- The contents of this module may change __in any way whatsoever__
--- and __without any warning__ between minor versions of this package.
---
--- Authors importing this library are expected to track development
--- closely.
---
--- All credit goes to the author(s)/maintainer(s) of the
--- [containers](https://hackage.haskell.org/package/containers) library
--- for the above warning text.
---
--- = Description
---
--- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
-
-module Data.SAM.Version1_6.Read.Parser.Alignment.HOPT ( -- * SAM_V1_6 parser - alignment section - hopt field 
-                                                        parse_SAM_V1_6_Alignment_HOPT
-                                                      ) where
-
-import Data.SAM.Version1_6.Alignment.HOPT
-import Data.SAM.Version1_6.Read.Error
-
-import           Data.Attoparsec.ByteString.Char8  as DABC8 (isEndOfLine)
-import           Data.Attoparsec.ByteString.Lazy   as DABL
-import           Text.Regex.PCRE.Heavy
-
--- | Defines a parser for the optional hopt field of alignment section of the SAM v1.6 file format.
---
--- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
-parse_SAM_V1_6_Alignment_HOPT :: Parser SAM_V1_6_Alignment_HOPT
-parse_SAM_V1_6_Alignment_HOPT = do
-  alignmenthoptfieldtag <- do alignmenthoptfieldtagp <- DABL.takeTill (== 58)
-                              -- Parse HOPT tag of the alignment section.
-                              case (alignmenthoptfieldtagp =~ [re|[A-Za-z][A-Za-z0-9]|]) of
-                                False -> fail $ show SAM_V1_6_Error_Alignment_HOPT_Tag_Incorrect_Format
-                                True  -> -- HOPT tag is in the accepted format. 
-                                         return alignmenthoptfieldtagp
-  _ <- word8 58
-  _ <- do alignmenthoptfieldtypep <- DABL.takeTill (== 58)
-          -- Parse HOPT type of the alignment section.
-          case (alignmenthoptfieldtypep =~ [re|[H]|]) of
-            False -> fail $ show SAM_V1_6_Error_Alignment_HOPT_Type_Incorrect_Format
-            True  -> -- HOPT type is in the accepted format.
-                     return ()
-  _ <- word8 58
-  alignmenthoptfieldvalue <- do alignmenthoptfieldvaluep <- DABL.takeTill (\x -> x == 09 || isEndOfLine x)
-                                -- Parse HOPT value of the alignment section.
-                                case (alignmenthoptfieldvaluep =~ [re|([0-9A-F][0-9A-F])*|]) of
-                                  False -> fail $ show SAM_V1_6_Error_Alignment_HOPT_Value_Incorrect_Format
-                                  True  -> -- HOPT value is in the accepted format.
-                                           return alignmenthoptfieldvaluep
-  return SAM_V1_6_Alignment_HOPT { sam_v1_6_alignment_hopt_tag   = alignmenthoptfieldtag
-                                 , sam_v1_6_alignment_hopt_value = alignmenthoptfieldvalue
-                                 }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Alignment/IOPT.hs b/src/Data/SAM/Version1_6/Read/Parser/Alignment/IOPT.hs
deleted file mode 100644
--- a/src/Data/SAM/Version1_6/Read/Parser/Alignment/IOPT.hs
+++ /dev/null
@@ -1,83 +0,0 @@
-{-# LANGUAGE DeriveDataTypeable    #-}
-{-# LANGUAGE DeriveGeneric         #-}
-{-# LANGUAGE FlexibleContexts      #-}
-{-# LANGUAGE FlexibleInstances     #-}
-{-# LANGUAGE MultiParamTypeClasses #-}
-{-# LANGUAGE OverloadedLists       #-}
-{-# LANGUAGE OverloadedStrings     #-}
-{-# LANGUAGE MultiWayIf            #-}
-{-# LANGUAGE PackageImports        #-}
-{-# LANGUAGE RecordWildCards       #-}
-{-# LANGUAGE ScopedTypeVariables   #-}
-{-# LANGUAGE TypeFamilies          #-}
-{-# Language QuasiQuotes           #-}
-
--- |
--- Module      :  Data.SAM.Version1_6.Read.Parser.Alignment.IOPT
--- Copyright   :  (c) Matthew Mosior 2023
--- License     :  BSD-style
--- Maintainer  :  mattm.github@gmail.com
--- Portability :  portable
---
--- = WARNING
---
--- This module is considered __internal__.
---
--- The Package Versioning Policy __does not apply__.
---
--- The contents of this module may change __in any way whatsoever__
--- and __without any warning__ between minor versions of this package.
---
--- Authors importing this library are expected to track development
--- closely.
---
--- All credit goes to the author(s)/maintainer(s) of the
--- [containers](https://hackage.haskell.org/package/containers) library
--- for the above warning text.
---
--- = Description
---
--- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
-
-module Data.SAM.Version1_6.Read.Parser.Alignment.IOPT ( -- * SAM_V1_6 parser - alignment section - iopt field 
-                                                        parse_SAM_V1_6_Alignment_IOPT
-                                                      ) where
-
-import Data.SAM.Version1_6.Alignment.IOPT
-import Data.SAM.Version1_6.Read.Error
-
-import           Data.Attoparsec.ByteString.Char8  as DABC8 (isEndOfLine)
-import           Data.Attoparsec.ByteString.Lazy   as DABL
-import qualified Data.ByteString.Char8             as DBC8
-import           Text.Regex.PCRE.Heavy
-
--- | Defines a parser for the optional iopt field of alignment section of the SAM v1.6 file format.
---
--- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
-parse_SAM_V1_6_Alignment_IOPT :: Parser SAM_V1_6_Alignment_IOPT
-parse_SAM_V1_6_Alignment_IOPT = do
-  alignmentioptfieldtag <- do alignmentioptfieldtagp <- DABL.takeTill (== 58)
-                              -- Parse IOPT tag of the alignment section.
-                              case (alignmentioptfieldtagp =~ [re|[A-Za-z][A-Za-z0-9]|]) of
-                                False -> fail $ show SAM_V1_6_Error_Alignment_IOPT_Tag_Incorrect_Format
-                                True  -> -- IOPT tag is in the accepted format. 
-                                         return alignmentioptfieldtagp
-  _ <- word8 58
-  _ <- do alignmentioptfieldtypep <- DABL.takeTill (== 58)
-          -- Parse IOPT type of the alignment section.
-          case (alignmentioptfieldtypep =~ [re|[i]|]) of
-            False -> fail $ show SAM_V1_6_Error_Alignment_IOPT_Type_Incorrect_Format
-            True  -> -- IOPT type is in the accepted format.
-                     return ()
-  _ <- word8 58
-  alignmentioptfieldvalue <- do alignmentioptfieldvaluep <- DABL.takeTill (\x -> x == 09 || isEndOfLine x)
-                                -- Parse IOPT value of the alignment section.
-                                case (alignmentioptfieldvaluep =~ [re|[-+]?[0-9]+|]) of
-                                  False -> fail $ show SAM_V1_6_Error_Alignment_IOPT_Value_Incorrect_Format
-                                  True  -> -- IOPT value is in the accepted format.
-                                           case (DBC8.readInteger alignmentioptfieldvaluep) of
-                                             Nothing                                 -> return (-1)
-                                             Just (alignmentioptfieldvalueinteger,_) -> return alignmentioptfieldvalueinteger
-  return SAM_V1_6_Alignment_IOPT { sam_v1_6_alignment_iopt_tag   = alignmentioptfieldtag
-                                 , sam_v1_6_alignment_iopt_value = alignmentioptfieldvalue
-                                 }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Alignment/OptionalFields/AOPT.hs b/src/Data/SAM/Version1_6/Read/Parser/Alignment/OptionalFields/AOPT.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/SAM/Version1_6/Read/Parser/Alignment/OptionalFields/AOPT.hs
@@ -0,0 +1,94 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedLists       #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE MultiWayIf            #-}
+{-# LANGUAGE RecordWildCards       #-}
+{-# LANGUAGE ScopedTypeVariables   #-}
+{-# LANGUAGE TypeFamilies          #-}
+{-# Language QuasiQuotes           #-}
+
+-- |
+-- Module      :  Data.SAM.Version1_6.Read.Parser.Alignment.OptionalFields.AOPT
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = WARNING
+--
+-- This module is considered __internal__.
+--
+-- The Package Versioning Policy __does not apply__.
+--
+-- The contents of this module may change __in any way whatsoever__
+-- and __without any warning__ between minor versions of this package.
+--
+-- Authors importing this library are expected to track development
+-- closely.
+--
+-- All credit goes to the author(s)/maintainer(s) of the
+-- [containers](https://hackage.haskell.org/package/containers) library
+-- for the above warning text.
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.SAM.Version1_6.Read.Parser.Alignment.OptionalFields.AOPT ( -- * SAM_V1_6 parser - alignment section - aopt field 
+                                                                       parse_SAM_V1_6_Alignment_OptionalFields_AOPT
+                                                                     ) where
+
+import Data.SAM.Version1_6.Alignment.OptionalFields.AOPT
+import Data.SAM.Version1_6.Read.Error
+
+import           Data.Attoparsec.ByteString.Char8  as DABC8 (isEndOfLine)
+import           Data.Attoparsec.ByteString.Lazy   as DABL
+import           Text.Regex.PCRE.Heavy
+
+-- | Defines a parser for the optional aopt field of alignment section of the SAM v1.6 file format.
+--
+-- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+parse_SAM_V1_6_Alignment_OptionalFields_AOPT :: Parser SAM_V1_6_Alignment_OptionalFields_AOPT
+parse_SAM_V1_6_Alignment_OptionalFields_AOPT = do
+  alignmentaoptfieldtag <- do
+    alignmentaoptfieldtagp <-
+      DABL.takeTill (== 58)
+    -- Parse AOPT tag of the alignment section.
+    case (alignmentaoptfieldtagp =~ [re|[A-Za-z][A-Za-z0-9]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Alignment_AOPT_Tag_Incorrect_Format
+      True  ->
+        -- AOPT tag is in the accepted format. 
+        return alignmentaoptfieldtagp
+  _ <-
+    word8 58
+  _ <- do
+    alignmentaoptfieldtypep <-
+      DABL.takeTill (== 58)
+    -- Parse AOPT type of the alignment section.
+    case (alignmentaoptfieldtypep =~ [re|[A]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Alignment_AOPT_Type_Incorrect_Format
+      True  ->
+        -- AOPT type is in the accepted format.
+        return ()
+  _ <-
+    word8 58
+  alignmentaoptfieldvalue <- do
+    alignmentaoptfieldvaluep <-
+      DABL.takeTill (\x -> x == 09 || isEndOfLine x)
+    -- Parse AOPT value of the alignment section.
+    case (alignmentaoptfieldvaluep =~ [re|[!-~]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Alignment_AOPT_Value_Incorrect_Format
+      True  ->
+        -- AOPT value is in the accepted format.
+        return alignmentaoptfieldvaluep
+  return SAM_V1_6_Alignment_OptionalFields_AOPT
+           { sam_v1_6_alignment_optionalfields_aopt_tag   = alignmentaoptfieldtag
+           , sam_v1_6_alignment_optionalfields_aopt_value = alignmentaoptfieldvalue
+           }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Alignment/OptionalFields/BOPT.hs b/src/Data/SAM/Version1_6/Read/Parser/Alignment/OptionalFields/BOPT.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/SAM/Version1_6/Read/Parser/Alignment/OptionalFields/BOPT.hs
@@ -0,0 +1,216 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedLists       #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE MultiWayIf            #-}
+{-# LANGUAGE RecordWildCards       #-}
+{-# LANGUAGE ScopedTypeVariables   #-}
+{-# LANGUAGE TypeFamilies          #-}
+{-# Language QuasiQuotes           #-}
+
+-- |
+-- Module      :  Data.SAM.Version1_6.Read.Parser.Alignment.OptionalFields.BOPT
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = WARNING
+--
+-- This module is considered __internal__.
+--
+-- The Package Versioning Policy __does not apply__.
+--
+-- The contents of this module may change __in any way whatsoever__
+-- and __without any warning__ between minor versions of this package.
+--
+-- Authors importing this library are expected to track development
+-- closely.
+--
+-- All credit goes to the author(s)/maintainer(s) of the
+-- [containers](https://hackage.haskell.org/package/containers) library
+-- for the above warning text.
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.SAM.Version1_6.Read.Parser.Alignment.OptionalFields.BOPT ( -- * SAM_V1_6 parser - alignment section - bopt field 
+                                                                       parse_SAM_V1_6_Alignment_OptionalFields_BOPT
+                                                                     ) where
+
+import Data.SAM.Version1_6.Alignment.OptionalFields.BOPT
+import Data.SAM.Version1_6.Read.Error
+
+import           Data.Attoparsec.ByteString.Char8  as DABC8 (isEndOfLine)
+import           Data.Attoparsec.ByteString.Lazy   as DABL
+import qualified Data.ByteString                   as DB (head,unpack)
+import qualified Data.ByteString.Char8             as DBC8
+import           Data.Sequence                     as DSeq
+import           Text.Regex.PCRE.Heavy
+
+-- | Defines a parser for the optional bopt field of alignment section of the SAM v1.6 file format.
+--
+-- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+parse_SAM_V1_6_Alignment_OptionalFields_BOPT :: Parser SAM_V1_6_Alignment_OptionalFields_BOPT
+parse_SAM_V1_6_Alignment_OptionalFields_BOPT = do
+  alignmentboptfieldtag <- do
+    alignmentboptfieldtagp <-
+      DABL.takeTill (== 58)
+    -- Parse BOPT tag of the alignment section.
+    case (alignmentboptfieldtagp =~ [re|[A-Za-z][A-Za-z0-9]|]) of
+      False ->
+        fail $
+          show SAM_V1_6_Error_Alignment_BOPT_Tag_Incorrect_Format
+      True  ->
+        -- BOPT tag is in the accepted format. 
+        return alignmentboptfieldtagp
+  _ <-
+    word8 58
+  _ <- do
+    alignmentboptfieldtypep <-
+      DABL.takeTill (== 58)
+    -- Parse BOPT type of the alignment section.
+    case (alignmentboptfieldtypep =~ [re|[B]|]) of
+      False ->
+        fail $
+          show SAM_V1_6_Error_Alignment_BOPT_Type_Incorrect_Format
+      True  ->
+        -- BOPT type is in the accepted format.
+        return ()
+  _ <-
+    word8 58
+  alignmentboptfieldvaluetype <- do
+    alignmentboptfieldvaluetypep <-
+      DABL.take 1
+    -- Parse BOPT value type of the alignment section.
+    case (alignmentboptfieldvaluetypep =~ [re|[cCsSiIf]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Alignment_BOPT_Value_Type_Incorrect_Format
+      True  ->
+        -- BOPT value type is in the accepted format.
+        return alignmentboptfieldvaluetypep
+  _ <-
+    word8 44
+  alignmentboptfieldvaluedata <- do
+    alignmentboptfieldvaluedatap <-
+      DABL.takeTill (\x -> x == 09 || isEndOfLine x)
+    -- Parse BOPT value data of the alignment section.
+    case (alignmentboptfieldvaluedatap =~ [re|([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)*|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Alignment_BOPT_Value_Data_Incorrect_Format
+      True  ->
+        -- BOPT value data is in the accepted format.
+        return alignmentboptfieldvaluedatap
+  case (DBC8.unpack alignmentboptfieldvaluetype) of
+    "c" ->
+      return SAM_V1_6_Alignment_OptionalFields_BOPT
+               { sam_v1_6_alignment_optionalfields_bopt_int8   = Just SAM_V1_6_Alignment_OptionalFields_BOPT_Int8
+                                                                        { sam_v1_6_alignment_optionalfields_bopt_int8_tag   = DSeq.fromList $ DB.unpack alignmentboptfieldtag
+                                                                        , sam_v1_6_alignment_optionalfields_bopt_int8_type  = DB.head alignmentboptfieldvaluetype
+                                                                        , sam_v1_6_alignment_optionalfields_bopt_int8_value = fmap fromIntegral (DSeq.fromList $ DB.unpack alignmentboptfieldvaluedata)
+                                                                        }
+               , sam_v1_6_alignment_optionalfields_bopt_word8  = Nothing
+               , sam_v1_6_alignment_optionalfields_bopt_int16  = Nothing
+               , sam_v1_6_alignment_optionalfields_bopt_word16 = Nothing
+               , sam_v1_6_alignment_optionalfields_bopt_int32  = Nothing
+               , sam_v1_6_alignment_optionalfields_bopt_word32 = Nothing
+               , sam_v1_6_alignment_optionalfields_bopt_float  = Nothing
+               }
+    "C" ->
+      return SAM_V1_6_Alignment_OptionalFields_BOPT
+               { sam_v1_6_alignment_optionalfields_bopt_int8   = Nothing
+               , sam_v1_6_alignment_optionalfields_bopt_word8  = Just SAM_V1_6_Alignment_OptionalFields_BOPT_Word8
+                                                                        { sam_v1_6_alignment_optionalfields_bopt_word8_tag   = DSeq.fromList $ DB.unpack alignmentboptfieldtag
+                                                                        , sam_v1_6_alignment_optionalfields_bopt_word8_type  = DB.head alignmentboptfieldvaluetype
+                                                                        , sam_v1_6_alignment_optionalfields_bopt_word8_value = DSeq.fromList $ DB.unpack alignmentboptfieldvaluedata
+                                                                        }
+               , sam_v1_6_alignment_optionalfields_bopt_int16  = Nothing
+               , sam_v1_6_alignment_optionalfields_bopt_word16 = Nothing
+               , sam_v1_6_alignment_optionalfields_bopt_int32  = Nothing
+               , sam_v1_6_alignment_optionalfields_bopt_word32 = Nothing
+               , sam_v1_6_alignment_optionalfields_bopt_float  = Nothing
+               }
+    "s" ->
+      return SAM_V1_6_Alignment_OptionalFields_BOPT
+               { sam_v1_6_alignment_optionalfields_bopt_int8   = Nothing
+               , sam_v1_6_alignment_optionalfields_bopt_word8  = Nothing
+               , sam_v1_6_alignment_optionalfields_bopt_int16  = Just SAM_V1_6_Alignment_OptionalFields_BOPT_Int16
+                                                                        { sam_v1_6_alignment_optionalfields_bopt_int16_tag   = DSeq.fromList $ DB.unpack alignmentboptfieldtag
+                                                                        , sam_v1_6_alignment_optionalfields_bopt_int16_type  = DB.head alignmentboptfieldvaluetype
+                                                                        , sam_v1_6_alignment_optionalfields_bopt_int16_value = fmap fromIntegral (DSeq.fromList $ DB.unpack alignmentboptfieldvaluedata)
+                                                                        }
+               , sam_v1_6_alignment_optionalfields_bopt_word16 = Nothing
+               , sam_v1_6_alignment_optionalfields_bopt_int32  = Nothing
+               , sam_v1_6_alignment_optionalfields_bopt_word32 = Nothing
+               , sam_v1_6_alignment_optionalfields_bopt_float  = Nothing
+               }
+    "S" ->
+      return SAM_V1_6_Alignment_OptionalFields_BOPT
+               { sam_v1_6_alignment_optionalfields_bopt_int8   = Nothing
+               , sam_v1_6_alignment_optionalfields_bopt_word8  = Nothing
+               , sam_v1_6_alignment_optionalfields_bopt_int16  = Nothing
+               , sam_v1_6_alignment_optionalfields_bopt_word16 = Just SAM_V1_6_Alignment_OptionalFields_BOPT_Word16
+                                                                        { sam_v1_6_alignment_optionalfields_bopt_word16_tag   = DSeq.fromList $ DB.unpack alignmentboptfieldtag
+                                                                        , sam_v1_6_alignment_optionalfields_bopt_word16_type  = DB.head alignmentboptfieldvaluetype
+                                                                        , sam_v1_6_alignment_optionalfields_bopt_word16_value = fmap fromIntegral (DSeq.fromList $ DB.unpack alignmentboptfieldvaluedata)
+                                                                        }
+               , sam_v1_6_alignment_optionalfields_bopt_int32  = Nothing
+               , sam_v1_6_alignment_optionalfields_bopt_word32 = Nothing
+               , sam_v1_6_alignment_optionalfields_bopt_float  = Nothing
+               }
+    "i" ->
+      return SAM_V1_6_Alignment_OptionalFields_BOPT
+               { sam_v1_6_alignment_optionalfields_bopt_int8   = Nothing
+               , sam_v1_6_alignment_optionalfields_bopt_word8  = Nothing
+               , sam_v1_6_alignment_optionalfields_bopt_int16  = Nothing
+               , sam_v1_6_alignment_optionalfields_bopt_word16 = Nothing
+               , sam_v1_6_alignment_optionalfields_bopt_int32  = Just SAM_V1_6_Alignment_OptionalFields_BOPT_Int32
+                                                                        { sam_v1_6_alignment_optionalfields_bopt_int32_tag   = DSeq.fromList $ DB.unpack alignmentboptfieldtag
+                                                                        , sam_v1_6_alignment_optionalfields_bopt_int32_type  = DB.head alignmentboptfieldvaluetype
+                                                                        , sam_v1_6_alignment_optionalfields_bopt_int32_value = fmap fromIntegral (DSeq.fromList $ DB.unpack alignmentboptfieldvaluedata)
+                                                                        }
+               , sam_v1_6_alignment_optionalfields_bopt_word32 = Nothing
+               , sam_v1_6_alignment_optionalfields_bopt_float  = Nothing
+               }
+    "I" ->
+      return SAM_V1_6_Alignment_OptionalFields_BOPT
+               { sam_v1_6_alignment_optionalfields_bopt_int8   = Nothing
+               , sam_v1_6_alignment_optionalfields_bopt_word8  = Nothing
+               , sam_v1_6_alignment_optionalfields_bopt_int16  = Nothing
+               , sam_v1_6_alignment_optionalfields_bopt_word16 = Nothing
+               , sam_v1_6_alignment_optionalfields_bopt_int32  = Nothing
+               , sam_v1_6_alignment_optionalfields_bopt_word32 = Just SAM_V1_6_Alignment_OptionalFields_BOPT_Word32
+                                                                        { sam_v1_6_alignment_optionalfields_bopt_word32_tag   = DSeq.fromList $ DB.unpack alignmentboptfieldtag
+                                                                        , sam_v1_6_alignment_optionalfields_bopt_word32_type  = DB.head alignmentboptfieldvaluetype
+                                                                        , sam_v1_6_alignment_optionalfields_bopt_word32_value = fmap fromIntegral (DSeq.fromList $ DB.unpack alignmentboptfieldvaluedata)
+                                                                        }
+               , sam_v1_6_alignment_optionalfields_bopt_float  = Nothing
+               }
+    "f" ->
+      return SAM_V1_6_Alignment_OptionalFields_BOPT
+               { sam_v1_6_alignment_optionalfields_bopt_int8   = Nothing
+               , sam_v1_6_alignment_optionalfields_bopt_word8  = Nothing
+               , sam_v1_6_alignment_optionalfields_bopt_int16  = Nothing
+               , sam_v1_6_alignment_optionalfields_bopt_word16 = Nothing
+               , sam_v1_6_alignment_optionalfields_bopt_int32  = Nothing
+               , sam_v1_6_alignment_optionalfields_bopt_word32 = Nothing
+               , sam_v1_6_alignment_optionalfields_bopt_float  = Just SAM_V1_6_Alignment_OptionalFields_BOPT_Float
+                                                                        { sam_v1_6_alignment_optionalfields_bopt_float_tag   = DSeq.fromList $ DB.unpack alignmentboptfieldtag
+                                                                        , sam_v1_6_alignment_optionalfields_bopt_float_type  = DB.head alignmentboptfieldvaluetype
+                                                                        , sam_v1_6_alignment_optionalfields_bopt_float_value = fmap fromIntegral (DSeq.fromList $ DB.unpack alignmentboptfieldvaluedata)
+                                                                        }
+               }
+    _   ->
+      return SAM_V1_6_Alignment_OptionalFields_BOPT
+               { sam_v1_6_alignment_optionalfields_bopt_int8   = Nothing
+               , sam_v1_6_alignment_optionalfields_bopt_word8  = Nothing
+               , sam_v1_6_alignment_optionalfields_bopt_int16  = Nothing
+               , sam_v1_6_alignment_optionalfields_bopt_word16 = Nothing
+               , sam_v1_6_alignment_optionalfields_bopt_int32  = Nothing
+               , sam_v1_6_alignment_optionalfields_bopt_word32 = Nothing
+               , sam_v1_6_alignment_optionalfields_bopt_float  = Nothing
+               }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Alignment/OptionalFields/FOPT.hs b/src/Data/SAM/Version1_6/Read/Parser/Alignment/OptionalFields/FOPT.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/SAM/Version1_6/Read/Parser/Alignment/OptionalFields/FOPT.hs
@@ -0,0 +1,97 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedLists       #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE MultiWayIf            #-}
+{-# LANGUAGE RecordWildCards       #-}
+{-# LANGUAGE ScopedTypeVariables   #-}
+{-# LANGUAGE TypeFamilies          #-}
+{-# Language QuasiQuotes           #-}
+
+-- |
+-- Module      :  Data.SAM.Version1_6.Read.Parser.Alignment.OptionalFields.FOPT
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = WARNING
+--
+-- This module is considered __internal__.
+--
+-- The Package Versioning Policy __does not apply__.
+--
+-- The contents of this module may change __in any way whatsoever__
+-- and __without any warning__ between minor versions of this package.
+--
+-- Authors importing this library are expected to track development
+-- closely.
+--
+-- All credit goes to the author(s)/maintainer(s) of the
+-- [containers](https://hackage.haskell.org/package/containers) library
+-- for the above warning text.
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.SAM.Version1_6.Read.Parser.Alignment.OptionalFields.FOPT ( -- * SAM_V1_6 parser - alignment section - fopt field 
+                                                                       parse_SAM_V1_6_Alignment_OptionalFields_FOPT
+                                                                     ) where
+
+import Data.SAM.Version1_6.Alignment.OptionalFields.FOPT
+import Data.SAM.Version1_6.Read.Error
+
+import           Data.Attoparsec.ByteString.Char8  as DABC8 (isEndOfLine)
+import           Data.Attoparsec.ByteString.Lazy   as DABL
+import qualified Data.ByteString.Char8             as DBC8
+import           Text.Regex.PCRE.Heavy
+
+-- | Defines a parser for the optional fopt field of alignment section of the SAM v1.6 file format.
+--
+-- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+parse_SAM_V1_6_Alignment_OptionalFields_FOPT :: Parser SAM_V1_6_Alignment_OptionalFields_FOPT
+parse_SAM_V1_6_Alignment_OptionalFields_FOPT = do
+  alignmentfoptfieldtag <- do
+    alignmentfoptfieldtagp <-
+      DABL.takeTill (== 58)
+    -- Parse FOPT tag of the alignment section.
+    case (alignmentfoptfieldtagp =~ [re|[A-Za-z][A-Za-z0-9]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Alignment_FOPT_Tag_Incorrect_Format
+      True  ->
+        -- FOPT tag is in the accepted format. 
+        return alignmentfoptfieldtagp
+  _ <-
+    word8 58
+  _ <- do
+    alignmentfoptfieldtypep <-
+      DABL.takeTill (== 58)
+    -- Parse FOPT type of the alignment section.
+    case (alignmentfoptfieldtypep =~ [re|[f]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Alignment_FOPT_Type_Incorrect_Format
+      True  ->
+        -- FOPT type is in the accepted format.
+        return ()
+  _ <-
+    word8 58
+  alignmentfoptfieldvalue <- do
+    alignmentfoptfieldvaluep <-
+      DABL.takeTill (\x -> x == 09 || isEndOfLine x)
+    -- Parse FOPT value of the alignment section.
+    case (alignmentfoptfieldvaluep =~ [re|[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Alignment_FOPT_Value_Incorrect_Format
+      True  ->
+        -- FOPT value is in the accepted format.
+        case (DBC8.readInteger alignmentfoptfieldvaluep) of
+          Nothing                                 -> return (-1)
+          Just (alignmentfoptfieldvalueinteger,_) -> return $ (fromInteger alignmentfoptfieldvalueinteger :: Float)
+  return SAM_V1_6_Alignment_OptionalFields_FOPT
+           { sam_v1_6_alignment_optionalfields_fopt_tag   = alignmentfoptfieldtag
+           , sam_v1_6_alignment_optionalfields_fopt_value = alignmentfoptfieldvalue
+           }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Alignment/OptionalFields/HOPT.hs b/src/Data/SAM/Version1_6/Read/Parser/Alignment/OptionalFields/HOPT.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/SAM/Version1_6/Read/Parser/Alignment/OptionalFields/HOPT.hs
@@ -0,0 +1,94 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedLists       #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE MultiWayIf            #-}
+{-# LANGUAGE RecordWildCards       #-}
+{-# LANGUAGE ScopedTypeVariables   #-}
+{-# LANGUAGE TypeFamilies          #-}
+{-# Language QuasiQuotes           #-}
+
+-- |
+-- Module      :  Data.SAM.Version1_6.Read.Parser.Alignment.OptionalFields.HOPT
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = WARNING
+--
+-- This module is considered __internal__.
+--
+-- The Package Versioning Policy __does not apply__.
+--
+-- The contents of this module may change __in any way whatsoever__
+-- and __without any warning__ between minor versions of this package.
+--
+-- Authors importing this library are expected to track development
+-- closely.
+--
+-- All credit goes to the author(s)/maintainer(s) of the
+-- [containers](https://hackage.haskell.org/package/containers) library
+-- for the above warning text.
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.SAM.Version1_6.Read.Parser.Alignment.OptionalFields.HOPT ( -- * SAM_V1_6 parser - alignment section - hopt field 
+                                                                       parse_SAM_V1_6_Alignment_OptionalFields_HOPT
+                                                                     ) where
+
+import Data.SAM.Version1_6.Alignment.OptionalFields.HOPT
+import Data.SAM.Version1_6.Read.Error
+
+import           Data.Attoparsec.ByteString.Char8  as DABC8 (isEndOfLine)
+import           Data.Attoparsec.ByteString.Lazy   as DABL
+import           Text.Regex.PCRE.Heavy
+
+-- | Defines a parser for the optional hopt field of alignment section of the SAM v1.6 file format.
+--
+-- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+parse_SAM_V1_6_Alignment_OptionalFields_HOPT :: Parser SAM_V1_6_Alignment_OptionalFields_HOPT
+parse_SAM_V1_6_Alignment_OptionalFields_HOPT = do
+  alignmenthoptfieldtag <- do
+    alignmenthoptfieldtagp <-
+      DABL.takeTill (== 58)
+    -- Parse HOPT tag of the alignment section.
+    case (alignmenthoptfieldtagp =~ [re|[A-Za-z][A-Za-z0-9]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Alignment_HOPT_Tag_Incorrect_Format
+      True  ->
+        -- HOPT tag is in the accepted format. 
+        return alignmenthoptfieldtagp
+  _ <-
+    word8 58
+  _ <- do
+    alignmenthoptfieldtypep <-
+      DABL.takeTill (== 58)
+    -- Parse HOPT type of the alignment section.
+    case (alignmenthoptfieldtypep =~ [re|[H]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Alignment_HOPT_Type_Incorrect_Format
+      True  ->
+        -- HOPT type is in the accepted format.
+        return ()
+  _ <-
+    word8 58
+  alignmenthoptfieldvalue <- do
+    alignmenthoptfieldvaluep <-
+      DABL.takeTill (\x -> x == 09 || isEndOfLine x)
+    -- Parse HOPT value of the alignment section.
+    case (alignmenthoptfieldvaluep =~ [re|([0-9A-F][0-9A-F])*|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Alignment_HOPT_Value_Incorrect_Format
+      True  ->
+        -- HOPT value is in the accepted format.
+        return alignmenthoptfieldvaluep
+  return SAM_V1_6_Alignment_OptionalFields_HOPT
+           { sam_v1_6_alignment_optionalfields_hopt_tag   = alignmenthoptfieldtag
+           , sam_v1_6_alignment_optionalfields_hopt_value = alignmenthoptfieldvalue
+           }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Alignment/OptionalFields/IOPT.hs b/src/Data/SAM/Version1_6/Read/Parser/Alignment/OptionalFields/IOPT.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/SAM/Version1_6/Read/Parser/Alignment/OptionalFields/IOPT.hs
@@ -0,0 +1,97 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedLists       #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE MultiWayIf            #-}
+{-# LANGUAGE RecordWildCards       #-}
+{-# LANGUAGE ScopedTypeVariables   #-}
+{-# LANGUAGE TypeFamilies          #-}
+{-# Language QuasiQuotes           #-}
+
+-- |
+-- Module      :  Data.SAM.Version1_6.Read.Parser.Alignment.OptionalFields.IOPT
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = WARNING
+--
+-- This module is considered __internal__.
+--
+-- The Package Versioning Policy __does not apply__.
+--
+-- The contents of this module may change __in any way whatsoever__
+-- and __without any warning__ between minor versions of this package.
+--
+-- Authors importing this library are expected to track development
+-- closely.
+--
+-- All credit goes to the author(s)/maintainer(s) of the
+-- [containers](https://hackage.haskell.org/package/containers) library
+-- for the above warning text.
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.SAM.Version1_6.Read.Parser.Alignment.OptionalFields.IOPT ( -- * SAM_V1_6 parser - alignment section - iopt field 
+                                                                       parse_SAM_V1_6_Alignment_OptionalFields_IOPT
+                                                                     ) where
+
+import Data.SAM.Version1_6.Alignment.OptionalFields.IOPT
+import Data.SAM.Version1_6.Read.Error
+
+import           Data.Attoparsec.ByteString.Char8  as DABC8 (isEndOfLine)
+import           Data.Attoparsec.ByteString.Lazy   as DABL
+import qualified Data.ByteString.Char8             as DBC8
+import           Text.Regex.PCRE.Heavy
+
+-- | Defines a parser for the optional iopt field of alignment section of the SAM v1.6 file format.
+--
+-- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+parse_SAM_V1_6_Alignment_OptionalFields_IOPT :: Parser SAM_V1_6_Alignment_OptionalFields_IOPT
+parse_SAM_V1_6_Alignment_OptionalFields_IOPT = do
+  alignmentioptfieldtag <- do
+    alignmentioptfieldtagp <-
+      DABL.takeTill (== 58)
+    -- Parse IOPT tag of the alignment section.
+    case (alignmentioptfieldtagp =~ [re|[A-Za-z][A-Za-z0-9]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Alignment_IOPT_Tag_Incorrect_Format
+      True  ->
+        -- IOPT tag is in the accepted format. 
+        return alignmentioptfieldtagp
+  _ <-
+    word8 58
+  _ <- do
+    alignmentioptfieldtypep <-
+      DABL.takeTill (== 58)
+    -- Parse IOPT type of the alignment section.
+    case (alignmentioptfieldtypep =~ [re|[i]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Alignment_IOPT_Type_Incorrect_Format
+      True  ->
+        -- IOPT type is in the accepted format.
+        return ()
+  _ <-
+    word8 58
+  alignmentioptfieldvalue <- do
+    alignmentioptfieldvaluep <-
+      DABL.takeTill (\x -> x == 09 || isEndOfLine x)
+    -- Parse IOPT value of the alignment section.
+    case (alignmentioptfieldvaluep =~ [re|[-+]?[0-9]+|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Alignment_IOPT_Value_Incorrect_Format
+      True  ->
+        -- IOPT value is in the accepted format.
+        case (DBC8.readInteger alignmentioptfieldvaluep) of
+          Nothing                                 -> return (-1)
+          Just (alignmentioptfieldvalueinteger,_) -> return alignmentioptfieldvalueinteger
+  return SAM_V1_6_Alignment_OptionalFields_IOPT
+           { sam_v1_6_alignment_optionalfields_iopt_tag   = alignmentioptfieldtag
+           , sam_v1_6_alignment_optionalfields_iopt_value = alignmentioptfieldvalue
+           }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Alignment/OptionalFields/ZOPT.hs b/src/Data/SAM/Version1_6/Read/Parser/Alignment/OptionalFields/ZOPT.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/SAM/Version1_6/Read/Parser/Alignment/OptionalFields/ZOPT.hs
@@ -0,0 +1,94 @@
+{-# LANGUAGE DeriveDataTypeable    #-}
+{-# LANGUAGE DeriveGeneric         #-}
+{-# LANGUAGE FlexibleContexts      #-}
+{-# LANGUAGE FlexibleInstances     #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE OverloadedLists       #-}
+{-# LANGUAGE OverloadedStrings     #-}
+{-# LANGUAGE MultiWayIf            #-}
+{-# LANGUAGE RecordWildCards       #-}
+{-# LANGUAGE ScopedTypeVariables   #-}
+{-# LANGUAGE TypeFamilies          #-}
+{-# Language QuasiQuotes           #-}
+
+-- |
+-- Module      :  Data.SAM.Version1_6.Read.Parser.Alignment.OptionalFields.ZOPT
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = WARNING
+--
+-- This module is considered __internal__.
+--
+-- The Package Versioning Policy __does not apply__.
+--
+-- The contents of this module may change __in any way whatsoever__
+-- and __without any warning__ between minor versions of this package.
+--
+-- Authors importing this library are expected to track development
+-- closely.
+--
+-- All credit goes to the author(s)/maintainer(s) of the
+-- [containers](https://hackage.haskell.org/package/containers) library
+-- for the above warning text.
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.SAM.Version1_6.Read.Parser.Alignment.OptionalFields.ZOPT ( -- * SAM_V1_6 parser - alignment section - zopt field 
+                                                                       parse_SAM_V1_6_Alignment_OptionalFields_ZOPT
+                                                                     ) where
+
+import Data.SAM.Version1_6.Alignment.OptionalFields.ZOPT
+import Data.SAM.Version1_6.Read.Error
+
+import           Data.Attoparsec.ByteString.Char8  as DABC8 (isEndOfLine)
+import           Data.Attoparsec.ByteString.Lazy   as DABL
+import           Text.Regex.PCRE.Heavy
+
+-- | Defines a parser for the optional zopt field of alignment section of the SAM v1.6 file format.
+--
+-- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
+parse_SAM_V1_6_Alignment_OptionalFields_ZOPT :: Parser SAM_V1_6_Alignment_OptionalFields_ZOPT
+parse_SAM_V1_6_Alignment_OptionalFields_ZOPT = do
+  alignmentzoptfieldtag <- do
+    alignmentzoptfieldtagp <-
+      DABL.takeTill (== 58)
+    -- Parse ZOPT tag of the alignment section.
+    case (alignmentzoptfieldtagp =~ [re|[A-Za-z][A-Za-z0-9]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Alignment_ZOPT_Tag_Incorrect_Format
+      True  ->
+        -- ZOPT tag is in the accepted format. 
+        return alignmentzoptfieldtagp
+  _ <-
+    word8 58
+  _ <- do
+    alignmentzoptfieldtypep <-
+      DABL.takeTill (== 58)
+    -- Parse ZOPT type of the alignment section.
+    case (alignmentzoptfieldtypep =~ [re|[Z]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Alignment_ZOPT_Type_Incorrect_Format
+      True  ->
+        -- ZOPT type is in the accepted format.
+        return ()
+  _ <-
+    word8 58
+  alignmentzoptfieldvalue <- do
+    alignmentzoptfieldvaluep <-
+      DABL.takeTill (\x -> x == 09 || isEndOfLine x)
+    -- Parse ZOPT value of the alignment section.
+    case (alignmentzoptfieldvaluep =~ [re|[ !-~]*|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Alignment_ZOPT_Value_Incorrect_Format
+      True  ->
+        -- ZOPT value is in the accepted format.
+        return alignmentzoptfieldvaluep
+  return SAM_V1_6_Alignment_OptionalFields_ZOPT
+           { sam_v1_6_alignment_optionalfields_zopt_tag   = alignmentzoptfieldtag
+           , sam_v1_6_alignment_optionalfields_zopt_value = alignmentzoptfieldvalue
+           }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Alignment/ZOPT.hs b/src/Data/SAM/Version1_6/Read/Parser/Alignment/ZOPT.hs
deleted file mode 100644
--- a/src/Data/SAM/Version1_6/Read/Parser/Alignment/ZOPT.hs
+++ /dev/null
@@ -1,80 +0,0 @@
-{-# LANGUAGE DeriveDataTypeable    #-}
-{-# LANGUAGE DeriveGeneric         #-}
-{-# LANGUAGE FlexibleContexts      #-}
-{-# LANGUAGE FlexibleInstances     #-}
-{-# LANGUAGE MultiParamTypeClasses #-}
-{-# LANGUAGE OverloadedLists       #-}
-{-# LANGUAGE OverloadedStrings     #-}
-{-# LANGUAGE MultiWayIf            #-}
-{-# LANGUAGE PackageImports        #-}
-{-# LANGUAGE RecordWildCards       #-}
-{-# LANGUAGE ScopedTypeVariables   #-}
-{-# LANGUAGE TypeFamilies          #-}
-{-# Language QuasiQuotes           #-}
-
--- |
--- Module      :  Data.SAM.Version1_6.Read.Parser.Alignment.ZOPT
--- Copyright   :  (c) Matthew Mosior 2023
--- License     :  BSD-style
--- Maintainer  :  mattm.github@gmail.com
--- Portability :  portable
---
--- = WARNING
---
--- This module is considered __internal__.
---
--- The Package Versioning Policy __does not apply__.
---
--- The contents of this module may change __in any way whatsoever__
--- and __without any warning__ between minor versions of this package.
---
--- Authors importing this library are expected to track development
--- closely.
---
--- All credit goes to the author(s)/maintainer(s) of the
--- [containers](https://hackage.haskell.org/package/containers) library
--- for the above warning text.
---
--- = Description
---
--- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
-
-module Data.SAM.Version1_6.Read.Parser.Alignment.ZOPT ( -- * SAM_V1_6 parser - alignment section - zopt field 
-                                                        parse_SAM_V1_6_Alignment_ZOPT
-                                                      ) where
-
-import Data.SAM.Version1_6.Alignment.ZOPT
-import Data.SAM.Version1_6.Read.Error
-
-import           Data.Attoparsec.ByteString.Char8  as DABC8 (isEndOfLine)
-import           Data.Attoparsec.ByteString.Lazy   as DABL
-import           Text.Regex.PCRE.Heavy
-
--- | Defines a parser for the optional zopt field of alignment section of the SAM v1.6 file format.
---
--- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
-parse_SAM_V1_6_Alignment_ZOPT :: Parser SAM_V1_6_Alignment_ZOPT
-parse_SAM_V1_6_Alignment_ZOPT = do
-  alignmentzoptfieldtag <- do alignmentzoptfieldtagp <- DABL.takeTill (== 58)
-                              -- Parse ZOPT tag of the alignment section.
-                              case (alignmentzoptfieldtagp =~ [re|[A-Za-z][A-Za-z0-9]|]) of
-                                False -> fail $ show SAM_V1_6_Error_Alignment_ZOPT_Tag_Incorrect_Format
-                                True  -> -- ZOPT tag is in the accepted format. 
-                                         return alignmentzoptfieldtagp
-  _ <- word8 58
-  _ <- do alignmentzoptfieldtypep <- DABL.takeTill (== 58)
-          -- Parse ZOPT type of the alignment section.
-          case (alignmentzoptfieldtypep =~ [re|[Z]|]) of
-            False -> fail $ show SAM_V1_6_Error_Alignment_ZOPT_Type_Incorrect_Format
-            True  -> -- ZOPT type is in the accepted format.
-                     return ()
-  _ <- word8 58
-  alignmentzoptfieldvalue <- do alignmentzoptfieldvaluep <- DABL.takeTill (\x -> x == 09 || isEndOfLine x)
-                                -- Parse ZOPT value of the alignment section.
-                                case (alignmentzoptfieldvaluep =~ [re|[ !-~]*|]) of
-                                  False -> fail $ show SAM_V1_6_Error_Alignment_ZOPT_Value_Incorrect_Format
-                                  True  -> -- ZOPT value is in the accepted format.
-                                           return alignmentzoptfieldvaluep
-  return SAM_V1_6_Alignment_ZOPT { sam_v1_6_alignment_zopt_tag   = alignmentzoptfieldtag
-                                 , sam_v1_6_alignment_zopt_value = alignmentzoptfieldvalue
-                                 }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Header/CO/Base.hs b/src/Data/SAM/Version1_6/Read/Parser/Header/CO/Base.hs
--- a/src/Data/SAM/Version1_6/Read/Parser/Header/CO/Base.hs
+++ b/src/Data/SAM/Version1_6/Read/Parser/Header/CO/Base.hs
@@ -15,7 +15,7 @@
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Read.Parser.Header.CO.Base
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -58,14 +58,21 @@
 -- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
 parse_SAM_V1_6_One_Line_Comment :: Parser SAM_V1_6_One_Line_Comment
 parse_SAM_V1_6_One_Line_Comment = do
-  _         <- do coheaderp <- DABL.takeTill (== 09)
-                  -- Parse @PG tag of the header section.
-                  case (coheaderp =~ [re|[@][C][O]|]) of
-                    False -> fail $ show SAM_V1_6_Error_One_Line_Comment_Tag_Incorrect_Format
-                    True  -> -- @CO tag is in the accepted format.
-                             return ()
-  _         <- word8 09
-  value     <- DABL.takeTill isEndOfLine
-  _         <- endOfLine
+  _     <- do
+    coheaderp <-
+      DABL.takeTill (== 09)
+    -- Parse @PG tag of the header section.
+    case (coheaderp =~ [re|[@][C][O]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_One_Line_Comment_Tag_Incorrect_Format
+      True  ->
+        -- @CO tag is in the accepted format.
+        return ()
+  _     <-
+    word8 09
+  value <-
+    DABL.takeTill isEndOfLine
+  _     <-
+    endOfLine
   return SAM_V1_6_One_Line_Comment { sam_v1_6_one_line_comment_value = value
                                    }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Header/HD/Base.hs b/src/Data/SAM/Version1_6/Read/Parser/Header/HD/Base.hs
--- a/src/Data/SAM/Version1_6/Read/Parser/Header/HD/Base.hs
+++ b/src/Data/SAM/Version1_6/Read/Parser/Header/HD/Base.hs
@@ -14,7 +14,7 @@
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Read.Parser.Header.HD.Base
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -62,23 +62,30 @@
 -- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
 parse_SAM_V1_6_File_Level_Metadata :: Parser SAM_V1_6_File_Level_Metadata
 parse_SAM_V1_6_File_Level_Metadata = do
-  _         <- do hdheaderp <- DABL.takeTill (== 09)
-                  -- Parse @HD tag of the header section.
-                  case (hdheaderp =~ [re|[@][H][D]|]) of
-                    False -> fail $ show SAM_V1_6_Error_File_Level_Metadata_Tag_Incorrect_Format
-                    True  -> -- @HD tag is in the accepted format.
-                             return () 
-  _         <- word8 09
+  _  <- do
+    hdheaderp <-
+      DABL.takeTill (== 09)
+    -- Parse @HD tag of the header section.
+    case (hdheaderp =~ [re|[@][H][D]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_File_Level_Metadata_Tag_Incorrect_Format
+      True  ->
+        -- @HD tag is in the accepted format.
+        return () 
+  _  <-
+    word8 09
   -- This parser assumes that the
   -- VN, SO, GO and SS tags can appear in any order.
-  hd <- intercalateEffect (word8 09) $
-          SAM_V1_6_File_Level_Metadata
-            <$> toPermutation parse_SAM_V1_6_File_Level_Metadata_VN
-            <*> toPermutationWithDefault Nothing 
-                                         (Just <$> parse_SAM_V1_6_File_Level_Metadata_SO)
-            <*> toPermutationWithDefault Nothing
-                                         (Just <$> parse_SAM_V1_6_File_Level_Metadata_GO)
-            <*> toPermutationWithDefault Nothing
-                                         (Just <$> parse_SAM_V1_6_File_Level_Metadata_SS)
-  _ <- endOfLine
+  hd <-
+    intercalateEffect (word8 09) $
+      SAM_V1_6_File_Level_Metadata
+        <$> toPermutation parse_SAM_V1_6_File_Level_Metadata_VN
+        <*> toPermutationWithDefault Nothing 
+                                     (Just <$> parse_SAM_V1_6_File_Level_Metadata_SO)
+        <*> toPermutationWithDefault Nothing
+                                     (Just <$> parse_SAM_V1_6_File_Level_Metadata_GO)
+        <*> toPermutationWithDefault Nothing
+                                     (Just <$> parse_SAM_V1_6_File_Level_Metadata_SS)
+  _  <-
+    endOfLine
   return hd 
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Header/HD/GO.hs b/src/Data/SAM/Version1_6/Read/Parser/Header/HD/GO.hs
--- a/src/Data/SAM/Version1_6/Read/Parser/Header/HD/GO.hs
+++ b/src/Data/SAM/Version1_6/Read/Parser/Header/HD/GO.hs
@@ -15,7 +15,7 @@
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Read.Parser.Header.HD.GO
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -56,18 +56,26 @@
 -- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
 parse_SAM_V1_6_File_Level_Metadata_GO :: Parser SAM_V1_6_File_Level_Metadata_Alignment_Grouping
 parse_SAM_V1_6_File_Level_Metadata_GO = do
-  _ <- do hdheaderalignmentgroupingtagp <- DABL.takeTill (== 58)
-          -- Parse GO tag of the header section.
-          case (hdheaderalignmentgroupingtagp =~ [re|[G][O]|]) of
-            False -> fail $ show SAM_V1_6_Error_File_Level_Metadata_Grouping_Of_Alignments_Tag_Incorrect_Format
-            True  -> -- GO tag is in the accepted format.
-                     return ()
-  _ <- word8 58
-  hdheaderalignmentgroupingvalue <- do hdheaderalignmentgroupingvaluep <- DABL.takeTill (\x -> x == 09 || isEndOfLine x)
-                                       -- Parse GO value of the header section.
-                                       case (hdheaderalignmentgroupingvaluep =~ [re|[n][o][n][e]|[q][u][e][r][y]|[r][e][f][e][r][e][n][c][e]|]) of
-                                         False -> fail $ show SAM_V1_6_Error_File_Level_Metadata_Grouping_Of_Alignments_Invalid_Value
-                                         True  -> -- GO value is in the accepted format.
-                                                  return hdheaderalignmentgroupingvaluep
+  _                              <- do
+    hdheaderalignmentgroupingtagp <-
+      DABL.takeTill (== 58)
+    -- Parse GO tag of the header section.
+    case (hdheaderalignmentgroupingtagp =~ [re|[G][O]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_File_Level_Metadata_Grouping_Of_Alignments_Tag_Incorrect_Format
+      True  ->
+        -- GO tag is in the accepted format.
+        return ()
+  _                              <-
+    word8 58
+  hdheaderalignmentgroupingvalue <- do
+    hdheaderalignmentgroupingvaluep <- DABL.takeTill (\x -> x == 09 || isEndOfLine x)
+    -- Parse GO value of the header section.
+    case (hdheaderalignmentgroupingvaluep =~ [re|[n][o][n][e]|[q][u][e][r][y]|[r][e][f][e][r][e][n][c][e]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_File_Level_Metadata_Grouping_Of_Alignments_Invalid_Value
+      True  ->
+        -- GO value is in the accepted format.
+        return hdheaderalignmentgroupingvaluep
   return SAM_V1_6_File_Level_Metadata_Alignment_Grouping { sam_v1_6_file_level_metadata_alignment_grouping_value = hdheaderalignmentgroupingvalue
                                                          }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Header/HD/SO.hs b/src/Data/SAM/Version1_6/Read/Parser/Header/HD/SO.hs
--- a/src/Data/SAM/Version1_6/Read/Parser/Header/HD/SO.hs
+++ b/src/Data/SAM/Version1_6/Read/Parser/Header/HD/SO.hs
@@ -15,7 +15,7 @@
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Read.Parser.Header.HD.SO
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -56,18 +56,26 @@
 -- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
 parse_SAM_V1_6_File_Level_Metadata_SO :: Parser SAM_V1_6_File_Level_Metadata_Sorting_Order
 parse_SAM_V1_6_File_Level_Metadata_SO = do
-  _ <- do hdheadersortingordertagp <- DABL.takeTill (== 58)
-          -- Parse SO tag of the header section.
-          case (hdheadersortingordertagp =~ [re|[S][O]|]) of
-            False -> fail $ show SAM_V1_6_Error_File_Level_Metadata_Sorting_Order_Tag_Incorrect_Format
-            True  -> -- SO tag is in the accepted format.
-                     return ()
-  _ <- word8 58
-  hdheadersortingordervalue <- do hdheadersortingordervaluep <- DABL.takeTill (\x -> x == 09 || isEndOfLine x)
-                                  -- Parse SO value of the header section.
-                                  case (hdheadersortingordervaluep =~ [re|[u][n][k][n][o][w][n]|[u][n][s][o][r][t][e][d]|[q][u][e][r][y][n][a][m][e]|[c][o][o][r][d][i][n][a][t][e]|]) of
-                                    False -> fail $ show SAM_V1_6_Error_File_Level_Metadata_Sorting_Order_Invalid_Value
-                                    True  -> -- SO value is in the accepted format.
-                                             return hdheadersortingordervaluep  
+  _                            <- do
+    hdheadersortingordertagp <-
+      DABL.takeTill (== 58)
+    -- Parse SO tag of the header section.
+    case (hdheadersortingordertagp =~ [re|[S][O]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_File_Level_Metadata_Sorting_Order_Tag_Incorrect_Format
+      True  ->
+        -- SO tag is in the accepted format.
+        return ()
+  _                            <-
+    word8 58
+  hdheadersortingordervalue <- do
+    hdheadersortingordervaluep <- DABL.takeTill (\x -> x == 09 || isEndOfLine x)
+    -- Parse SO value of the header section.
+    case (hdheadersortingordervaluep =~ [re|[u][n][k][n][o][w][n]|[u][n][s][o][r][t][e][d]|[q][u][e][r][y][n][a][m][e]|[c][o][o][r][d][i][n][a][t][e]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_File_Level_Metadata_Sorting_Order_Invalid_Value
+      True  ->
+        -- SO value is in the accepted format.
+        return hdheadersortingordervaluep  
   return SAM_V1_6_File_Level_Metadata_Sorting_Order { sam_v1_6_file_level_metadata_sorting_order_value = hdheadersortingordervalue
                                                     }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Header/HD/SS.hs b/src/Data/SAM/Version1_6/Read/Parser/Header/HD/SS.hs
--- a/src/Data/SAM/Version1_6/Read/Parser/Header/HD/SS.hs
+++ b/src/Data/SAM/Version1_6/Read/Parser/Header/HD/SS.hs
@@ -15,7 +15,7 @@
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Read.Parser.Header.HD.SS
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -56,18 +56,27 @@
 -- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
 parse_SAM_V1_6_File_Level_Metadata_SS :: Parser SAM_V1_6_File_Level_Metadata_SubSorting_Order
 parse_SAM_V1_6_File_Level_Metadata_SS = do
-  _ <- do hdheadersubsortingordertagp <- DABL.takeTill (== 58)
-          -- Parse SS tag of the header section.
-          case (hdheadersubsortingordertagp =~ [re|[S][S]|]) of
-            False -> fail $ show SAM_V1_6_Error_File_Level_Metadata_Subsorting_Order_Tag_Incorrect_Format
-            True  -> -- SS tag is in the accepted format.
-                     return ()
-  _ <- word8 58
-  hdheadersubsortingordervalue <- do hdheadersubsortingordervaluep <- DABL.takeTill (\x -> x == 09 || isEndOfLine x)
-                                     -- Parse SS value of the header section.
-                                     case (hdheadersubsortingordervaluep =~ [re|(coordinate|queryname|unsorted)(:[A-Za-z0-9_-]+)+|]) of
-                                       False -> fail $ show SAM_V1_6_Error_File_Level_Metadata_Subsorting_Order_Incorrect_Format 
-                                       True  -> -- SS value is in the accepted format.
-                                                return hdheadersubsortingordervaluep 
+  _                            <- do
+    hdheadersubsortingordertagp <-
+      DABL.takeTill (== 58)
+    -- Parse SS tag of the header section.
+    case (hdheadersubsortingordertagp =~ [re|[S][S]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_File_Level_Metadata_Subsorting_Order_Tag_Incorrect_Format
+      True  ->
+        -- SS tag is in the accepted format.
+        return ()
+  _                            <-
+    word8 58
+  hdheadersubsortingordervalue <- do
+    hdheadersubsortingordervaluep <-
+      DABL.takeTill (\x -> x == 09 || isEndOfLine x)
+    -- Parse SS value of the header section.
+    case (hdheadersubsortingordervaluep =~ [re|(coordinate|queryname|unsorted)(:[A-Za-z0-9_-]+)+|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_File_Level_Metadata_Subsorting_Order_Incorrect_Format 
+      True  ->
+        -- SS value is in the accepted format.
+        return hdheadersubsortingordervaluep 
   return SAM_V1_6_File_Level_Metadata_SubSorting_Order { sam_v1_6_file_level_metadata_subsorting_order_value = hdheadersubsortingordervalue
                                                        }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Header/HD/VN.hs b/src/Data/SAM/Version1_6/Read/Parser/Header/HD/VN.hs
--- a/src/Data/SAM/Version1_6/Read/Parser/Header/HD/VN.hs
+++ b/src/Data/SAM/Version1_6/Read/Parser/Header/HD/VN.hs
@@ -15,7 +15,7 @@
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Read.Parser.Header.HD.VN
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -56,18 +56,27 @@
 -- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
 parse_SAM_V1_6_File_Level_Metadata_VN :: Parser SAM_V1_6_File_Level_Metadata_Format_Version
 parse_SAM_V1_6_File_Level_Metadata_VN = do
-  _ <- do hdheaderversiontagp <- DABL.takeTill (== 58)
-          -- Parse VN tag of the header section.
-          case (hdheaderversiontagp =~ [re|[V][N]|]) of
-            False -> fail $ show SAM_V1_6_Error_File_Level_Metadata_Format_Version_Tag_Incorrect_Format
-            True  -> -- VN tag is in the accepted format. 
-                     return ()
-  _ <- word8 58
-  hdheaderversionvalue <- do hdheaderversionvaluep <- DABL.takeTill (\x -> x == 09 || isEndOfLine x)
-                             -- Parse VN value of the header section.
-                             case (hdheaderversionvaluep =~ [re|^[0-9]+\.[0-9]+$|]) of
-                               False -> fail $ show SAM_V1_6_Error_File_Level_Metadata_Format_Version_Value_Incorrect_Format
-                               True  -> -- VN value is in the accepted format.
-                                        return hdheaderversionvaluep  
+  _                       <- do
+    hdheaderversiontagp <-
+      DABL.takeTill (== 58)
+    -- Parse VN tag of the header section.
+    case (hdheaderversiontagp =~ [re|[V][N]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_File_Level_Metadata_Format_Version_Tag_Incorrect_Format
+      True  ->
+        -- VN tag is in the accepted format. 
+        return ()
+  _                       <-
+    word8 58
+  hdheaderversionvalue <- do
+    hdheaderversionvaluep <-
+      DABL.takeTill (\x -> x == 09 || isEndOfLine x)
+    -- Parse VN value of the header section.
+    case (hdheaderversionvaluep =~ [re|^[0-9]+\.[0-9]+$|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_File_Level_Metadata_Format_Version_Value_Incorrect_Format
+      True  ->
+        -- VN value is in the accepted format.
+        return hdheaderversionvaluep  
   return SAM_V1_6_File_Level_Metadata_Format_Version { sam_v1_6_file_level_metadata_format_version_value = hdheaderversionvalue
                                                      }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Header/PG/Base.hs b/src/Data/SAM/Version1_6/Read/Parser/Header/PG/Base.hs
--- a/src/Data/SAM/Version1_6/Read/Parser/Header/PG/Base.hs
+++ b/src/Data/SAM/Version1_6/Read/Parser/Header/PG/Base.hs
@@ -15,7 +15,7 @@
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Read.Parser.Header.PG.Base
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -65,27 +65,34 @@
 -- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
 parse_SAM_V1_6_Program :: Parser SAM_V1_6_Program
 parse_SAM_V1_6_Program = do
-  _         <- do pgheaderp <- DABL.takeTill (== 09)
-                  -- Parse @PG tag of the header section.
-                  case (pgheaderp =~ [re|[@][P][G]|]) of
-                    False -> fail $ show SAM_V1_6_Error_Program_Tag_Incorrect_Format 
-                    True  -> -- @PG tag is in the accepted format.
-                             return ()
-  _         <- word8 09
+  _  <- do
+    pgheaderp <-
+      DABL.takeTill (== 09)
+    -- Parse @PG tag of the header section.
+    case (pgheaderp =~ [re|[@][P][G]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Program_Tag_Incorrect_Format 
+      True  ->
+        -- @PG tag is in the accepted format.
+        return ()
+  _  <-
+    word8 09
   -- This parser assumes that the
   -- ID, PN, CL, PP, DS, and VN tags can appear in any order.
-  pg <- intercalateEffect (word8 09) $
-          SAM_V1_6_Program
-            <$> toPermutation parse_SAM_V1_6_Program_ID
-            <*> toPermutationWithDefault Nothing
-                                         (Just <$> parse_SAM_V1_6_Program_PN)
-            <*> toPermutationWithDefault Nothing
-                                         (Just <$> parse_SAM_V1_6_Program_CL)
-            <*> toPermutationWithDefault Nothing
-                                         (Just <$> parse_SAM_V1_6_Program_PP)
-            <*> toPermutationWithDefault Nothing
-                                         (Just <$> parse_SAM_V1_6_Program_DS)
-            <*> toPermutationWithDefault Nothing
-                                         (Just <$> parse_SAM_V1_6_Program_VN)
-  _ <- endOfLine
+  pg <-
+    intercalateEffect (word8 09) $
+      SAM_V1_6_Program
+        <$> toPermutation parse_SAM_V1_6_Program_ID
+        <*> toPermutationWithDefault Nothing
+                                     (Just <$> parse_SAM_V1_6_Program_PN)
+        <*> toPermutationWithDefault Nothing
+                                     (Just <$> parse_SAM_V1_6_Program_CL)
+        <*> toPermutationWithDefault Nothing
+                                     (Just <$> parse_SAM_V1_6_Program_PP)
+        <*> toPermutationWithDefault Nothing
+                                     (Just <$> parse_SAM_V1_6_Program_DS)
+        <*> toPermutationWithDefault Nothing
+                                     (Just <$> parse_SAM_V1_6_Program_VN)
+  _  <-
+    endOfLine
   return pg
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Header/PG/CL.hs b/src/Data/SAM/Version1_6/Read/Parser/Header/PG/CL.hs
--- a/src/Data/SAM/Version1_6/Read/Parser/Header/PG/CL.hs
+++ b/src/Data/SAM/Version1_6/Read/Parser/Header/PG/CL.hs
@@ -14,7 +14,7 @@
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Read.Parser.Header.PG.CL
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -55,13 +55,19 @@
 -- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
 parse_SAM_V1_6_Program_CL :: Parser SAM_V1_6_Program_Command_Line
 parse_SAM_V1_6_Program_CL = do
-  _ <- do pgheadercommandlinetagp <- DABL.takeTill (== 58)
-          -- Parse CL tag of the header section.
-          case (pgheadercommandlinetagp =~ [re|[C][L]|]) of
-            False -> fail $ show SAM_V1_6_Error_Program_Command_Line_Incorrect_Format 
-            True  -> -- CL tag is in the accepted format. 
-                     return ()
-  _ <- word8 58
-  pgheadercommandlinevalue <- DABL.takeTill (\x -> x == 09 || isEndOfLine x)
+  _                        <- do
+    pgheadercommandlinetagp <-
+      DABL.takeTill (== 58)
+    -- Parse CL tag of the header section.
+    case (pgheadercommandlinetagp =~ [re|[C][L]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Program_Command_Line_Incorrect_Format 
+      True  ->
+        -- CL tag is in the accepted format. 
+        return ()
+  _                        <-
+    word8 58
+  pgheadercommandlinevalue <-
+    DABL.takeTill (\x -> x == 09 || isEndOfLine x)
   return SAM_V1_6_Program_Command_Line { sam_v1_6_program_command_line_value = pgheadercommandlinevalue
                                        }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Header/PG/DS.hs b/src/Data/SAM/Version1_6/Read/Parser/Header/PG/DS.hs
--- a/src/Data/SAM/Version1_6/Read/Parser/Header/PG/DS.hs
+++ b/src/Data/SAM/Version1_6/Read/Parser/Header/PG/DS.hs
@@ -14,7 +14,7 @@
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Read.Parser.Header.PG.DS
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -55,13 +55,19 @@
 -- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
 parse_SAM_V1_6_Program_DS :: Parser SAM_V1_6_Program_Description
 parse_SAM_V1_6_Program_DS = do
-  _ <- do pgheaderdescriptiontagp <- DABL.takeTill (== 58)
-          -- Parse DS tag of the header section.
-          case (pgheaderdescriptiontagp =~ [re|[D][S]|]) of
-            False -> fail $ show SAM_V1_6_Error_Program_Description_Incorrect_Format 
-            True  -> -- DS tag is in the accepted format. 
-                     return ()
-  _ <- word8 58
-  pgheaderdescriptionvalue <- DABL.takeTill (\x -> x == 09 || isEndOfLine x)
+  _                        <- do
+    pgheaderdescriptiontagp <-
+      DABL.takeTill (== 58)
+    -- Parse DS tag of the header section.
+    case (pgheaderdescriptiontagp =~ [re|[D][S]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Program_Description_Incorrect_Format 
+      True  ->
+        -- DS tag is in the accepted format. 
+        return ()
+  _                        <-
+    word8 58
+  pgheaderdescriptionvalue <-
+    DABL.takeTill (\x -> x == 09 || isEndOfLine x)
   return SAM_V1_6_Program_Description { sam_v1_6_program_description_value = pgheaderdescriptionvalue
                                       }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Header/PG/ID.hs b/src/Data/SAM/Version1_6/Read/Parser/Header/PG/ID.hs
--- a/src/Data/SAM/Version1_6/Read/Parser/Header/PG/ID.hs
+++ b/src/Data/SAM/Version1_6/Read/Parser/Header/PG/ID.hs
@@ -14,7 +14,7 @@
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Read.Parser.Header.PG.ID
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -55,13 +55,19 @@
 -- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
 parse_SAM_V1_6_Program_ID :: Parser SAM_V1_6_Program_Record_Identifier
 parse_SAM_V1_6_Program_ID = do
-  _ <- do pgheaderidentifiertagp <- DABL.takeTill (== 58)
-          -- Parse ID tag of the header section.
-          case (pgheaderidentifiertagp =~ [re|[I][D]|]) of
-            False -> fail $ show SAM_V1_6_Error_Program_Identifier_Incorrect_Format 
-            True  -> -- ID tag is in the accepted format. 
-                     return ()
-  _ <- word8 58
-  pgheaderidentifiervalue <- DABL.takeTill (\x -> x == 09 || isEndOfLine x)
+  _                       <- do
+    pgheaderidentifiertagp <-
+      DABL.takeTill (== 58)
+    -- Parse ID tag of the header section.
+    case (pgheaderidentifiertagp =~ [re|[I][D]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Program_Identifier_Incorrect_Format 
+      True  ->
+        -- ID tag is in the accepted format. 
+        return ()
+  _                       <-
+    word8 58
+  pgheaderidentifiervalue <-
+    DABL.takeTill (\x -> x == 09 || isEndOfLine x)
   return SAM_V1_6_Program_Record_Identifier { sam_v1_6_program_record_identifier_value = pgheaderidentifiervalue
                                             }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Header/PG/PN.hs b/src/Data/SAM/Version1_6/Read/Parser/Header/PG/PN.hs
--- a/src/Data/SAM/Version1_6/Read/Parser/Header/PG/PN.hs
+++ b/src/Data/SAM/Version1_6/Read/Parser/Header/PG/PN.hs
@@ -14,7 +14,7 @@
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Read.Parser.Header.PG.PN
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -55,13 +55,19 @@
 -- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
 parse_SAM_V1_6_Program_PN :: Parser SAM_V1_6_Program_Name
 parse_SAM_V1_6_Program_PN = do
-  _ <- do pgheadernametagp <- DABL.takeTill (== 58)
-          -- Parse PN tag of the header section.
-          case (pgheadernametagp =~ [re|[P][N]|]) of
-            False -> fail $ show SAM_V1_6_Error_Program_Name_Incorrect_Format 
-            True  -> -- PN tag is in the accepted format. 
-                     return ()
-  _ <- word8 58
-  pgheadernamevalue <- DABL.takeTill (\x -> x == 09 || isEndOfLine x)
+  _                 <- do
+    pgheadernametagp <-
+      DABL.takeTill (== 58)
+    -- Parse PN tag of the header section.
+    case (pgheadernametagp =~ [re|[P][N]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Program_Name_Incorrect_Format 
+      True  ->
+        -- PN tag is in the accepted format. 
+        return ()
+  _                 <-
+    word8 58
+  pgheadernamevalue <-
+    DABL.takeTill (\x -> x == 09 || isEndOfLine x)
   return SAM_V1_6_Program_Name { sam_v1_6_program_name_value = pgheadernamevalue
                                }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Header/PG/PP.hs b/src/Data/SAM/Version1_6/Read/Parser/Header/PG/PP.hs
--- a/src/Data/SAM/Version1_6/Read/Parser/Header/PG/PP.hs
+++ b/src/Data/SAM/Version1_6/Read/Parser/Header/PG/PP.hs
@@ -14,7 +14,7 @@
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Read.Parser.Header.PG.PP
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -55,13 +55,19 @@
 -- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
 parse_SAM_V1_6_Program_PP :: Parser SAM_V1_6_Program_Previous_PG_ID
 parse_SAM_V1_6_Program_PP = do
-  _ <- do pgheaderpreviouspgidtagp <- DABL.takeTill (== 58)
-          -- Parse PP tag of the header section.
-          case (pgheaderpreviouspgidtagp =~ [re|[P][P]|]) of
-            False -> fail $ show SAM_V1_6_Error_Program_Previous_PG_ID_Incorrect_Format 
-            True  -> -- PP tag is in the accepted format. 
-                     return ()
-  _ <- word8 58
-  pgheaderpreviouspgidvalue <- DABL.takeTill (\x -> x == 09 || isEndOfLine x)
+  _                         <- do
+    pgheaderpreviouspgidtagp <-
+      DABL.takeTill (== 58)
+    -- Parse PP tag of the header section.
+    case (pgheaderpreviouspgidtagp =~ [re|[P][P]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Program_Previous_PG_ID_Incorrect_Format 
+      True  ->
+        -- PP tag is in the accepted format. 
+        return ()
+  _                         <-
+    word8 58
+  pgheaderpreviouspgidvalue <-
+    DABL.takeTill (\x -> x == 09 || isEndOfLine x)
   return SAM_V1_6_Program_Previous_PG_ID { sam_v1_6_program_previous_pg_id_value = pgheaderpreviouspgidvalue
                                          }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Header/PG/VN.hs b/src/Data/SAM/Version1_6/Read/Parser/Header/PG/VN.hs
--- a/src/Data/SAM/Version1_6/Read/Parser/Header/PG/VN.hs
+++ b/src/Data/SAM/Version1_6/Read/Parser/Header/PG/VN.hs
@@ -14,7 +14,7 @@
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Read.Parser.Header.PG.VN
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -55,13 +55,19 @@
 -- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
 parse_SAM_V1_6_Program_VN :: Parser SAM_V1_6_Program_Version
 parse_SAM_V1_6_Program_VN = do
-  _ <- do pgheaderversiontagp <- DABL.takeTill (== 58)
-          -- Parse VN tag of the header section.
-          case (pgheaderversiontagp =~ [re|[V][N]|]) of
-            False -> fail $ show SAM_V1_6_Error_Program_Version_Incorrect_Format 
-            True  -> -- VN tag is in the accepted format. 
-                     return ()
-  _ <- word8 58
-  pgheaderversionvalue <- DABL.takeTill (\x -> x == 09 || isEndOfLine x)
+  _                    <- do
+    pgheaderversiontagp <-
+      DABL.takeTill (== 58)
+    -- Parse VN tag of the header section.
+    case (pgheaderversiontagp =~ [re|[V][N]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Program_Version_Incorrect_Format 
+      True  ->
+        -- VN tag is in the accepted format. 
+        return ()
+  _                    <-
+    word8 58
+  pgheaderversionvalue <-
+    DABL.takeTill (\x -> x == 09 || isEndOfLine x)
   return SAM_V1_6_Program_Version { sam_v1_6_program_version_value = pgheaderversionvalue
                                   }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Header/RG/BC.hs b/src/Data/SAM/Version1_6/Read/Parser/Header/RG/BC.hs
--- a/src/Data/SAM/Version1_6/Read/Parser/Header/RG/BC.hs
+++ b/src/Data/SAM/Version1_6/Read/Parser/Header/RG/BC.hs
@@ -14,7 +14,7 @@
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Read.Parser.Header.RG.BC
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -55,13 +55,19 @@
 -- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
 parse_SAM_V1_6_Read_Group_BC :: Parser SAM_V1_6_Read_Group_Barcode_Sequence 
 parse_SAM_V1_6_Read_Group_BC = do
-  _ <- do rgheaderbarcodesequencetagp <- DABL.takeTill (== 58)
-          -- Parse BC tag of the header section.
-          case (rgheaderbarcodesequencetagp =~ [re|[B][C]|]) of
-            False -> fail $ show SAM_V1_6_Error_Read_Group_Barcode_Sequence_Incorrect_Format 
-            True  -> -- BC tag is in the accepted format. 
-                     return ()
-  _ <- word8 58
-  rgheaderbarcodesequencevalue <- DABL.takeTill (\x -> x == 09 || isEndOfLine x)
+  _                            <- do
+    rgheaderbarcodesequencetagp <-
+      DABL.takeTill (== 58)
+    -- Parse BC tag of the header section.
+    case (rgheaderbarcodesequencetagp =~ [re|[B][C]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Read_Group_Barcode_Sequence_Incorrect_Format 
+      True  ->
+        -- BC tag is in the accepted format. 
+        return ()
+  _                            <-
+    word8 58
+  rgheaderbarcodesequencevalue <-
+    DABL.takeTill (\x -> x == 09 || isEndOfLine x)
   return SAM_V1_6_Read_Group_Barcode_Sequence { sam_v1_6_read_group_barcode_sequence_value = rgheaderbarcodesequencevalue
                                               }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Header/RG/Base.hs b/src/Data/SAM/Version1_6/Read/Parser/Header/RG/Base.hs
--- a/src/Data/SAM/Version1_6/Read/Parser/Header/RG/Base.hs
+++ b/src/Data/SAM/Version1_6/Read/Parser/Header/RG/Base.hs
@@ -15,7 +15,7 @@
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Read.Parser.Header.RG.Base
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -73,44 +73,51 @@
 -- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
 parse_SAM_V1_6_Read_Group :: Parser SAM_V1_6_Read_Group
 parse_SAM_V1_6_Read_Group = do
-  _         <- do rgheaderp <- DABL.takeTill (== 09)
-                  -- Parse @RG tag of the header section.
-                  case (rgheaderp =~ [re|[@][R][G]|]) of
-                    False -> fail $ show SAM_V1_6_Error_Read_Group_Tag_Incorrect_Format
-                    True  -> -- @RG tag is in the accepted format.
-                             return ()
-  _         <- word8 09
+  _  <- do
+    rgheaderp <-
+      DABL.takeTill (== 09)
+    -- Parse @RG tag of the header section.
+    case (rgheaderp =~ [re|[@][R][G]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Read_Group_Tag_Incorrect_Format
+      True  ->
+        -- @RG tag is in the accepted format.
+        return ()
+  _  <-
+    word8 09
   -- This parser assumes that the
   -- ID, BC, CN, DS, DT, FO, KS, LB, PG, PI, PL,
   -- PM, PU and SM tags can appear in any order.
-  rg <- intercalateEffect (word8 09) $
-          SAM_V1_6_Read_Group
-            <$> toPermutation parse_SAM_V1_6_Read_Group_ID
-            <*> toPermutationWithDefault Nothing
-                                         (Just <$> parse_SAM_V1_6_Read_Group_BC)
-            <*> toPermutationWithDefault Nothing
-                                         (Just <$> parse_SAM_V1_6_Read_Group_CN)
-            <*> toPermutationWithDefault Nothing
-                                         (Just <$> parse_SAM_V1_6_Read_Group_DS)
-            <*> toPermutationWithDefault Nothing
-                                         (Just <$> parse_SAM_V1_6_Read_Group_DT)
-            <*> toPermutationWithDefault Nothing
-                                         (Just <$> parse_SAM_V1_6_Read_Group_FO)
-            <*> toPermutationWithDefault Nothing
-                                         (Just <$> parse_SAM_V1_6_Read_Group_KS)
-            <*> toPermutationWithDefault Nothing
-                                         (Just <$> parse_SAM_V1_6_Read_Group_LB)
-            <*> toPermutationWithDefault Nothing
-                                         (Just <$> parse_SAM_V1_6_Read_Group_PG)
-            <*> toPermutationWithDefault Nothing
-                                         (Just <$> parse_SAM_V1_6_Read_Group_PI)
-            <*> toPermutationWithDefault Nothing
-                                         (Just <$> parse_SAM_V1_6_Read_Group_PL)
-            <*> toPermutationWithDefault Nothing
-                                         (Just <$> parse_SAM_V1_6_Read_Group_PM)
-            <*> toPermutationWithDefault Nothing
-                                         (Just <$> parse_SAM_V1_6_Read_Group_PU)
-            <*> toPermutationWithDefault Nothing
-                                         (Just <$> parse_SAM_V1_6_Read_Group_SM)
-  _ <- endOfLine
+  rg <-
+    intercalateEffect (word8 09) $
+      SAM_V1_6_Read_Group
+        <$> toPermutation parse_SAM_V1_6_Read_Group_ID
+        <*> toPermutationWithDefault Nothing
+                                     (Just <$> parse_SAM_V1_6_Read_Group_BC)
+        <*> toPermutationWithDefault Nothing
+                                     (Just <$> parse_SAM_V1_6_Read_Group_CN)
+        <*> toPermutationWithDefault Nothing
+                                     (Just <$> parse_SAM_V1_6_Read_Group_DS)
+        <*> toPermutationWithDefault Nothing
+                                     (Just <$> parse_SAM_V1_6_Read_Group_DT)
+        <*> toPermutationWithDefault Nothing
+                                     (Just <$> parse_SAM_V1_6_Read_Group_FO)
+        <*> toPermutationWithDefault Nothing
+                                     (Just <$> parse_SAM_V1_6_Read_Group_KS)
+        <*> toPermutationWithDefault Nothing
+                                     (Just <$> parse_SAM_V1_6_Read_Group_LB)
+        <*> toPermutationWithDefault Nothing
+                                     (Just <$> parse_SAM_V1_6_Read_Group_PG)
+        <*> toPermutationWithDefault Nothing
+                                     (Just <$> parse_SAM_V1_6_Read_Group_PI)
+        <*> toPermutationWithDefault Nothing
+                                     (Just <$> parse_SAM_V1_6_Read_Group_PL)
+        <*> toPermutationWithDefault Nothing
+                                     (Just <$> parse_SAM_V1_6_Read_Group_PM)
+        <*> toPermutationWithDefault Nothing
+                                     (Just <$> parse_SAM_V1_6_Read_Group_PU)
+        <*> toPermutationWithDefault Nothing
+                                     (Just <$> parse_SAM_V1_6_Read_Group_SM)
+  _  <-
+    endOfLine
   return rg 
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Header/RG/CN.hs b/src/Data/SAM/Version1_6/Read/Parser/Header/RG/CN.hs
--- a/src/Data/SAM/Version1_6/Read/Parser/Header/RG/CN.hs
+++ b/src/Data/SAM/Version1_6/Read/Parser/Header/RG/CN.hs
@@ -14,7 +14,7 @@
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Read.Parser.Header.RG.CN
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -55,13 +55,19 @@
 -- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
 parse_SAM_V1_6_Read_Group_CN :: Parser SAM_V1_6_Read_Group_Sequencing_Center 
 parse_SAM_V1_6_Read_Group_CN = do
-  _ <- do rgheadersequencingcentertagp <- DABL.takeTill (== 58)
-          -- Parse CN tag of the header section.
-          case (rgheadersequencingcentertagp =~ [re|[C][N]|]) of
-            False -> fail $ show SAM_V1_6_Error_Read_Group_Sequencing_Center_Incorrect_Format 
-            True  -> -- CN tag is in the accepted format. 
-                     return ()
-  _ <- word8 58
-  rgheadersequencingcentervalue <- DABL.takeTill (\x -> x == 09 || isEndOfLine x)
+  _                             <- do
+    rgheadersequencingcentertagp <-
+      DABL.takeTill (== 58)
+    -- Parse CN tag of the header section.
+    case (rgheadersequencingcentertagp =~ [re|[C][N]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Read_Group_Sequencing_Center_Incorrect_Format 
+      True  ->
+        -- CN tag is in the accepted format. 
+        return ()
+  _                             <-
+    word8 58
+  rgheadersequencingcentervalue <-
+    DABL.takeTill (\x -> x == 09 || isEndOfLine x)
   return SAM_V1_6_Read_Group_Sequencing_Center { sam_v1_6_read_group_sequencing_center_value = rgheadersequencingcentervalue
                                                }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Header/RG/DS.hs b/src/Data/SAM/Version1_6/Read/Parser/Header/RG/DS.hs
--- a/src/Data/SAM/Version1_6/Read/Parser/Header/RG/DS.hs
+++ b/src/Data/SAM/Version1_6/Read/Parser/Header/RG/DS.hs
@@ -14,7 +14,7 @@
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Read.Parser.Header.RG.DS
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -55,13 +55,19 @@
 -- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
 parse_SAM_V1_6_Read_Group_DS :: Parser SAM_V1_6_Read_Group_Description 
 parse_SAM_V1_6_Read_Group_DS = do
-  _ <- do rgheaderdescriptiontagp <- DABL.takeTill (== 58)
-          -- Parse DS tag of the header section.
-          case (rgheaderdescriptiontagp =~ [re|[D][S]|]) of
-            False -> fail $ show SAM_V1_6_Error_Read_Group_Description_Incorrect_Format 
-            True  -> -- DS tag is in the accepted format. 
-                     return ()
-  _ <- word8 58
-  rgheaderdescriptionvalue <- DABL.takeTill (\x -> x == 09 || isEndOfLine x)
+  _                        <- do
+    rgheaderdescriptiontagp <-
+      DABL.takeTill (== 58)
+    -- Parse DS tag of the header section.
+    case (rgheaderdescriptiontagp =~ [re|[D][S]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Read_Group_Description_Incorrect_Format 
+      True  ->
+        -- DS tag is in the accepted format. 
+        return ()
+  _                        <-
+    word8 58
+  rgheaderdescriptionvalue <-
+    DABL.takeTill (\x -> x == 09 || isEndOfLine x)
   return SAM_V1_6_Read_Group_Description { sam_v1_6_read_group_description_value = rgheaderdescriptionvalue
                                          }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Header/RG/DT.hs b/src/Data/SAM/Version1_6/Read/Parser/Header/RG/DT.hs
--- a/src/Data/SAM/Version1_6/Read/Parser/Header/RG/DT.hs
+++ b/src/Data/SAM/Version1_6/Read/Parser/Header/RG/DT.hs
@@ -14,7 +14,7 @@
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Read.Parser.Header.RG.DT
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -55,13 +55,19 @@
 -- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
 parse_SAM_V1_6_Read_Group_DT :: Parser SAM_V1_6_Read_Group_Run_Date 
 parse_SAM_V1_6_Read_Group_DT = do
-  _ <- do rgheaderrundatetagp <- DABL.takeTill (== 58)
-          -- Parse DT tag of the header section.
-          case (rgheaderrundatetagp =~ [re|[D][T]|]) of
-            False -> fail $ show SAM_V1_6_Error_Read_Group_Date_Run_Produced_Incorrect_Format
-            True  -> -- DT tag is in the accepted format. 
-                     return ()
-  _ <- word8 58
-  rgheaderrundatevalue <- DABL.takeTill (\x -> x == 09 || isEndOfLine x)
+  _                    <- do
+    rgheaderrundatetagp <-
+      DABL.takeTill (== 58)
+    -- Parse DT tag of the header section.
+    case (rgheaderrundatetagp =~ [re|[D][T]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Read_Group_Date_Run_Produced_Incorrect_Format
+      True  ->
+        -- DT tag is in the accepted format. 
+        return ()
+  _                    <-
+    word8 58
+  rgheaderrundatevalue <-
+    DABL.takeTill (\x -> x == 09 || isEndOfLine x)
   return SAM_V1_6_Read_Group_Run_Date { sam_v1_6_read_group_run_date_value = rgheaderrundatevalue
                                       }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Header/RG/FO.hs b/src/Data/SAM/Version1_6/Read/Parser/Header/RG/FO.hs
--- a/src/Data/SAM/Version1_6/Read/Parser/Header/RG/FO.hs
+++ b/src/Data/SAM/Version1_6/Read/Parser/Header/RG/FO.hs
@@ -14,7 +14,7 @@
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Read.Parser.Header.RG.FO
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -55,18 +55,27 @@
 -- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
 parse_SAM_V1_6_Read_Group_FO :: Parser SAM_V1_6_Read_Group_Flow_Order 
 parse_SAM_V1_6_Read_Group_FO = do
-  _ <- do rgheaderflowordertagp <- DABL.takeTill (== 58)
-          -- Parse FO tag of the header section.
-          case (rgheaderflowordertagp =~ [re|[F][O]|]) of
-            False -> fail $ show SAM_V1_6_Error_Read_Group_Flow_Order_Incorrect_Format
-            True  -> -- FO tag is in the accepted format. 
-                     return ()
-  _ <- word8 58
-  rgheaderflowordervalue <- do rgheaderflowordervaluep <- DABL.takeTill (\x -> x == 09 || isEndOfLine x)
-                               -- Parse FO value of the header section.
-                               case (rgheaderflowordervaluep =~ [re|\*|[ACMGRSVTWYHKDBN]+|]) of
-                                 False -> fail $ show SAM_V1_6_Error_Read_Group_Flow_Order_Incorrect_Format
-                                 True  -> -- FO value is in the accepted format.
-                                          return rgheaderflowordervaluep
+  _                      <- do
+    rgheaderflowordertagp <-
+      DABL.takeTill (== 58)
+    -- Parse FO tag of the header section.
+    case (rgheaderflowordertagp =~ [re|[F][O]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Read_Group_Flow_Order_Incorrect_Format
+      True  ->
+        -- FO tag is in the accepted format. 
+        return ()
+  _                      <-
+    word8 58
+  rgheaderflowordervalue <- do
+    rgheaderflowordervaluep <-
+      DABL.takeTill (\x -> x == 09 || isEndOfLine x)
+    -- Parse FO value of the header section.
+    case (rgheaderflowordervaluep =~ [re|\*|[ACMGRSVTWYHKDBN]+|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Read_Group_Flow_Order_Incorrect_Format
+      True  ->
+        -- FO value is in the accepted format.
+        return rgheaderflowordervaluep
   return SAM_V1_6_Read_Group_Flow_Order { sam_v1_6_read_group_flow_order_value = rgheaderflowordervalue
                                         }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Header/RG/ID.hs b/src/Data/SAM/Version1_6/Read/Parser/Header/RG/ID.hs
--- a/src/Data/SAM/Version1_6/Read/Parser/Header/RG/ID.hs
+++ b/src/Data/SAM/Version1_6/Read/Parser/Header/RG/ID.hs
@@ -14,7 +14,7 @@
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Read.Parser.Header.RG.ID
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -55,13 +55,19 @@
 -- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
 parse_SAM_V1_6_Read_Group_ID :: Parser SAM_V1_6_Read_Group_Identifier 
 parse_SAM_V1_6_Read_Group_ID = do
-  _ <- do rgheaderreadgroupidentifiertagp <- DABL.takeTill (== 58)
-          -- Parse ID tag of the header section.
-          case (rgheaderreadgroupidentifiertagp =~ [re|[I][D]|]) of
-            False -> fail $ show SAM_V1_6_Error_Read_Group_Read_Group_Identifier_Incorrect_Format
-            True  -> -- ID tag is in the accepted format. 
-                     return ()
-  _ <- word8 58
-  rgheaderreadgroupidentifiervalue <- DABL.takeTill (\x -> x == 09 || isEndOfLine x)
+  _                                <- do
+    rgheaderreadgroupidentifiertagp <-
+      DABL.takeTill (== 58)
+    -- Parse ID tag of the header section.
+    case (rgheaderreadgroupidentifiertagp =~ [re|[I][D]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Read_Group_Read_Group_Identifier_Incorrect_Format
+      True  ->
+        -- ID tag is in the accepted format. 
+        return ()
+  _                                <-
+    word8 58
+  rgheaderreadgroupidentifiervalue <-
+    DABL.takeTill (\x -> x == 09 || isEndOfLine x)
   return SAM_V1_6_Read_Group_Identifier { sam_v1_6_read_group_identifier_value = rgheaderreadgroupidentifiervalue
                                         }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Header/RG/KS.hs b/src/Data/SAM/Version1_6/Read/Parser/Header/RG/KS.hs
--- a/src/Data/SAM/Version1_6/Read/Parser/Header/RG/KS.hs
+++ b/src/Data/SAM/Version1_6/Read/Parser/Header/RG/KS.hs
@@ -14,7 +14,7 @@
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Read.Parser.Header.RG.KS
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -55,13 +55,19 @@
 -- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
 parse_SAM_V1_6_Read_Group_KS :: Parser SAM_V1_6_Read_Group_Key_Sequence 
 parse_SAM_V1_6_Read_Group_KS = do
-  _ <- do rgheaderkeysequencetagp <- DABL.takeTill (== 58)
-          -- Parse KS tag of the header section.
-          case (rgheaderkeysequencetagp =~ [re|[K][S]|]) of
-            False -> fail $ show SAM_V1_6_Error_Read_Group_Key_Sequence_Incorrect_Format
-            True  -> -- KS tag is in the accepted format. 
-                     return ()
-  _ <- word8 58
-  rgheaderkeysequencevalue <- DABL.takeTill (\x -> x == 09 || isEndOfLine x)
+  _                        <- do
+    rgheaderkeysequencetagp <-
+      DABL.takeTill (== 58)
+    -- Parse KS tag of the header section.
+    case (rgheaderkeysequencetagp =~ [re|[K][S]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Read_Group_Key_Sequence_Incorrect_Format
+      True  ->
+        -- KS tag is in the accepted format. 
+        return ()
+  _                        <-
+    word8 58
+  rgheaderkeysequencevalue <-
+    DABL.takeTill (\x -> x == 09 || isEndOfLine x)
   return SAM_V1_6_Read_Group_Key_Sequence { sam_v1_6_read_group_key_sequence_value = rgheaderkeysequencevalue
                                           }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Header/RG/LB.hs b/src/Data/SAM/Version1_6/Read/Parser/Header/RG/LB.hs
--- a/src/Data/SAM/Version1_6/Read/Parser/Header/RG/LB.hs
+++ b/src/Data/SAM/Version1_6/Read/Parser/Header/RG/LB.hs
@@ -14,7 +14,7 @@
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Read.Parser.Header.RG.LB
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -55,13 +55,19 @@
 -- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
 parse_SAM_V1_6_Read_Group_LB :: Parser SAM_V1_6_Read_Group_Library 
 parse_SAM_V1_6_Read_Group_LB = do
-  _ <- do rgheaderlibrarytagp <- DABL.takeTill (== 58)
-          -- Parse LB tag of the header section.
-          case (rgheaderlibrarytagp =~ [re|[L][B]|]) of
-            False -> fail $ show SAM_V1_6_Error_Read_Group_Library_Incorrect_Format
-            True  -> -- LB tag is in the accepted format. 
-                     return ()
-  _ <- word8 58
-  rgheaderlibraryvalue <- DABL.takeTill (\x -> x == 09 || isEndOfLine x)
+  _                    <- do
+    rgheaderlibrarytagp <-
+      DABL.takeTill (== 58)
+    -- Parse LB tag of the header section.
+    case (rgheaderlibrarytagp =~ [re|[L][B]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Read_Group_Library_Incorrect_Format
+      True  ->
+        -- LB tag is in the accepted format. 
+        return ()
+  _                    <-
+    word8 58
+  rgheaderlibraryvalue <-
+    DABL.takeTill (\x -> x == 09 || isEndOfLine x)
   return SAM_V1_6_Read_Group_Library { sam_v1_6_read_group_library_value = rgheaderlibraryvalue
                                      }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Header/RG/PG.hs b/src/Data/SAM/Version1_6/Read/Parser/Header/RG/PG.hs
--- a/src/Data/SAM/Version1_6/Read/Parser/Header/RG/PG.hs
+++ b/src/Data/SAM/Version1_6/Read/Parser/Header/RG/PG.hs
@@ -14,7 +14,7 @@
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Read.Parser.Header.RG.PG
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -55,13 +55,19 @@
 -- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
 parse_SAM_V1_6_Read_Group_PG :: Parser SAM_V1_6_Read_Group_Programs 
 parse_SAM_V1_6_Read_Group_PG = do
-  _ <- do rgheaderprogramstagp <- DABL.takeTill (== 58)
-          -- Parse PG tag of the header section.
-          case (rgheaderprogramstagp =~ [re|[P][G]|]) of
-            False -> fail $ show SAM_V1_6_Error_Read_Group_Programs_Incorrect_Format
-            True  -> -- PG tag is in the accepted format. 
-                     return ()
-  _ <- word8 58
-  rgheaderprogramsvalue <- DABL.takeTill (\x -> x == 09 || isEndOfLine x)
+  _ <- do
+    rgheaderprogramstagp <-
+      DABL.takeTill (== 58)
+    -- Parse PG tag of the header section.
+    case (rgheaderprogramstagp =~ [re|[P][G]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Read_Group_Programs_Incorrect_Format
+      True  ->
+        -- PG tag is in the accepted format. 
+        return ()
+  _                     <-
+    word8 58
+  rgheaderprogramsvalue <-
+    DABL.takeTill (\x -> x == 09 || isEndOfLine x)
   return SAM_V1_6_Read_Group_Programs { sam_v1_6_read_group_programs_value = rgheaderprogramsvalue
                                       }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Header/RG/PI.hs b/src/Data/SAM/Version1_6/Read/Parser/Header/RG/PI.hs
--- a/src/Data/SAM/Version1_6/Read/Parser/Header/RG/PI.hs
+++ b/src/Data/SAM/Version1_6/Read/Parser/Header/RG/PI.hs
@@ -14,7 +14,7 @@
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Read.Parser.Header.RG.PI
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -55,13 +55,19 @@
 -- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
 parse_SAM_V1_6_Read_Group_PI :: Parser SAM_V1_6_Read_Group_Predicted_Median_Insert_Size 
 parse_SAM_V1_6_Read_Group_PI = do
-  _ <- do rgheaderpredictedmedianinsertsizetagp <- DABL.takeTill (== 58)
-          -- Parse PI tag of the header section.
-          case (rgheaderpredictedmedianinsertsizetagp =~ [re|[P][I]|]) of
-            False -> fail $ show SAM_V1_6_Error_Read_Group_Predicted_Median_Insert_Size_Incorrect_Format
-            True  -> -- PI tag is in the accepted format. 
-                     return ()
-  _ <- word8 58
-  rgheaderpredictedmedianinsertsizevalue <- DABL.takeTill (\x -> x == 09 || isEndOfLine x)
+  _                                      <- do
+    rgheaderpredictedmedianinsertsizetagp <-
+      DABL.takeTill (== 58)
+    -- Parse PI tag of the header section.
+    case (rgheaderpredictedmedianinsertsizetagp =~ [re|[P][I]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Read_Group_Predicted_Median_Insert_Size_Incorrect_Format
+      True  ->
+        -- PI tag is in the accepted format. 
+        return ()
+  _                                      <-
+    word8 58
+  rgheaderpredictedmedianinsertsizevalue <-
+    DABL.takeTill (\x -> x == 09 || isEndOfLine x)
   return SAM_V1_6_Read_Group_Predicted_Median_Insert_Size { sam_v1_6_read_group_predicted_median_insert_size_value = rgheaderpredictedmedianinsertsizevalue
                                                           }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Header/RG/PL.hs b/src/Data/SAM/Version1_6/Read/Parser/Header/RG/PL.hs
--- a/src/Data/SAM/Version1_6/Read/Parser/Header/RG/PL.hs
+++ b/src/Data/SAM/Version1_6/Read/Parser/Header/RG/PL.hs
@@ -14,7 +14,7 @@
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Read.Parser.Header.RG.PL
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -55,18 +55,27 @@
 -- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
 parse_SAM_V1_6_Read_Group_PL :: Parser SAM_V1_6_Read_Group_Platform 
 parse_SAM_V1_6_Read_Group_PL = do
-  _ <- do rgheaderplatformtagp <- DABL.takeTill (== 58)
-          -- Parse PL tag of the header section.
-          case (rgheaderplatformtagp =~ [re|[P][L]|]) of
-            False -> fail $ show SAM_V1_6_Error_Read_Group_Platform_Incorrect_Format
-            True  -> -- PL tag is in the accepted format. 
-                     return ()
-  _ <- word8 58
-  rgheaderplatformvalue <- do rgheaderplatformvaluep <- DABL.takeTill (\x -> x == 09 || isEndOfLine x)
-                              -- Parse PL value of the header section.
-                              case (rgheaderplatformvaluep =~ [re|[C][A][P][I][L][L][A][R][Y]|[D][N][B][S][E][Q]|[E][L][E][M][E][N][T]|[H][E][L][I][C][O][S]|[I][L][L][U][M][I][N][A]|[I][O][N][T][O][R][R][E][N][T]|[L][S][4][5][4]|[O][N][T]|[P][A][C][B][I][O]|[S][O][L][I][D]|[U][L][T][I][M][A]|]) of
-                                False -> fail $ show SAM_V1_6_Error_Read_Group_Platform_Incorrect_Format
-                                True  -> -- PL value is in the accepted format.
-                                         return rgheaderplatformvaluep
+  _                     <- do
+    rgheaderplatformtagp <-
+      DABL.takeTill (== 58)
+    -- Parse PL tag of the header section.
+    case (rgheaderplatformtagp =~ [re|[P][L]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Read_Group_Platform_Incorrect_Format
+      True  ->
+        -- PL tag is in the accepted format. 
+        return ()
+  _                     <-
+    word8 58
+  rgheaderplatformvalue <- do
+    rgheaderplatformvaluep <-
+      DABL.takeTill (\x -> x == 09 || isEndOfLine x)
+    -- Parse PL value of the header section.
+    case (rgheaderplatformvaluep =~ [re|[C][A][P][I][L][L][A][R][Y]|[D][N][B][S][E][Q]|[E][L][E][M][E][N][T]|[H][E][L][I][C][O][S]|[I][L][L][U][M][I][N][A]|[I][O][N][T][O][R][R][E][N][T]|[L][S][4][5][4]|[O][N][T]|[P][A][C][B][I][O]|[S][O][L][I][D]|[U][L][T][I][M][A]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Read_Group_Platform_Incorrect_Format
+      True  ->
+        -- PL value is in the accepted format.
+        return rgheaderplatformvaluep
   return SAM_V1_6_Read_Group_Platform { sam_v1_6_read_group_platform_value = rgheaderplatformvalue
                                       }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Header/RG/PM.hs b/src/Data/SAM/Version1_6/Read/Parser/Header/RG/PM.hs
--- a/src/Data/SAM/Version1_6/Read/Parser/Header/RG/PM.hs
+++ b/src/Data/SAM/Version1_6/Read/Parser/Header/RG/PM.hs
@@ -14,7 +14,7 @@
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Read.Parser.Header.RG.PM
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -55,13 +55,19 @@
 -- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
 parse_SAM_V1_6_Read_Group_PM :: Parser SAM_V1_6_Read_Group_Platform_Model 
 parse_SAM_V1_6_Read_Group_PM = do
-  _ <- do rgheaderplatformmodeltagp <- DABL.takeTill (== 58)
-          -- Parse PM tag of the header section.
-          case (rgheaderplatformmodeltagp =~ [re|[P][M]|]) of
-            False -> fail $ show SAM_V1_6_Error_Read_Group_Platform_Model_Incorrect_Format
-            True  -> -- PM tag is in the accepted format. 
-                     return ()
-  _ <- word8 58
-  rgheaderplatformmodelvalue <- DABL.takeTill (\x -> x == 09 || isEndOfLine x)
+  _                          <- do
+    rgheaderplatformmodeltagp <-
+      DABL.takeTill (== 58)
+    -- Parse PM tag of the header section.
+    case (rgheaderplatformmodeltagp =~ [re|[P][M]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Read_Group_Platform_Model_Incorrect_Format
+      True  ->
+        -- PM tag is in the accepted format. 
+        return ()
+  _                          <-
+    word8 58
+  rgheaderplatformmodelvalue <-
+    DABL.takeTill (\x -> x == 09 || isEndOfLine x)
   return SAM_V1_6_Read_Group_Platform_Model { sam_v1_6_read_group_platform_model_value = rgheaderplatformmodelvalue
                                             }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Header/RG/PU.hs b/src/Data/SAM/Version1_6/Read/Parser/Header/RG/PU.hs
--- a/src/Data/SAM/Version1_6/Read/Parser/Header/RG/PU.hs
+++ b/src/Data/SAM/Version1_6/Read/Parser/Header/RG/PU.hs
@@ -14,7 +14,7 @@
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Read.Parser.Header.RG.PU
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -55,13 +55,19 @@
 -- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
 parse_SAM_V1_6_Read_Group_PU :: Parser SAM_V1_6_Read_Group_Platform_Unit 
 parse_SAM_V1_6_Read_Group_PU = do
-  _ <- do rgheaderplatformunittagp <- DABL.takeTill (== 58)
-          -- Parse PU tag of the header section.
-          case (rgheaderplatformunittagp =~ [re|[P][U]|]) of
-            False -> fail $ show SAM_V1_6_Error_Read_Group_Platform_Unit_Incorrect_Format 
-            True  -> -- PU tag is in the accepted format. 
-                     return ()
-  _ <- word8 58
-  rgheaderplatformunitvalue <- DABL.takeTill (\x -> x == 09 || isEndOfLine x)
+  _                         <- do
+    rgheaderplatformunittagp <-
+      DABL.takeTill (== 58)
+    -- Parse PU tag of the header section.
+    case (rgheaderplatformunittagp =~ [re|[P][U]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Read_Group_Platform_Unit_Incorrect_Format 
+      True  ->
+        -- PU tag is in the accepted format. 
+        return ()
+  _                         <-
+    word8 58
+  rgheaderplatformunitvalue <-
+    DABL.takeTill (\x -> x == 09 || isEndOfLine x)
   return SAM_V1_6_Read_Group_Platform_Unit { sam_v1_6_read_group_platform_unit_value = rgheaderplatformunitvalue
                                            }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Header/RG/SM.hs b/src/Data/SAM/Version1_6/Read/Parser/Header/RG/SM.hs
--- a/src/Data/SAM/Version1_6/Read/Parser/Header/RG/SM.hs
+++ b/src/Data/SAM/Version1_6/Read/Parser/Header/RG/SM.hs
@@ -14,7 +14,7 @@
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Read.Parser.Header.RG.SM
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -55,13 +55,19 @@
 -- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
 parse_SAM_V1_6_Read_Group_SM :: Parser SAM_V1_6_Read_Group_Sample 
 parse_SAM_V1_6_Read_Group_SM = do
-  _ <- do rgheadersampletagp <- DABL.takeTill (== 58)
-          -- Parse SM tag of the header section.
-          case (rgheadersampletagp =~ [re|[S][M]|]) of
-            False -> fail $ show SAM_V1_6_Error_Read_Group_Sample_Incorrect_Format
-            True  -> -- SM tag is in the accepted format. 
-                     return ()
-  _ <- word8 58
-  rgheadersamplevalue <- DABL.takeTill (\x -> x == 09 || isEndOfLine x)
+  _                   <- do
+    rgheadersampletagp <-
+      DABL.takeTill (== 58)
+    -- Parse SM tag of the header section.
+    case (rgheadersampletagp =~ [re|[S][M]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Read_Group_Sample_Incorrect_Format
+      True  ->
+        -- SM tag is in the accepted format. 
+        return ()
+  _                   <-
+    word8 58
+  rgheadersamplevalue <-
+    DABL.takeTill (\x -> x == 09 || isEndOfLine x)
   return SAM_V1_6_Read_Group_Sample { sam_v1_6_read_group_sample_value = rgheadersamplevalue
                                     }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Header/SQ/AH.hs b/src/Data/SAM/Version1_6/Read/Parser/Header/SQ/AH.hs
--- a/src/Data/SAM/Version1_6/Read/Parser/Header/SQ/AH.hs
+++ b/src/Data/SAM/Version1_6/Read/Parser/Header/SQ/AH.hs
@@ -14,7 +14,7 @@
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Read.Parser.Header.SQ.AH
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -55,13 +55,19 @@
 -- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
 parse_SAM_V1_6_Reference_Sequence_Dictionary_AH :: Parser SAM_V1_6_Reference_Sequence_Dictionary_Alternative_Locus
 parse_SAM_V1_6_Reference_Sequence_Dictionary_AH = do
-  _ <- do sqheaderalternativelocustagp <- DABL.takeTill (== 58)
-          -- Parse AH tag of the header section.
-          case (sqheaderalternativelocustagp =~ [re|[A][H]|]) of
-            False -> fail $ show SAM_V1_6_Error_Reference_Sequence_Dictionary_Alternative_Locus_Incorrect_Format
-            True  -> -- AH tag is in the accepted format.
-                     return ()
-  _ <- word8 58
-  sqheaderalternativelocusvalue <- DABL.takeTill (\x -> x == 09 || isEndOfLine x)
+  _                             <- do
+    sqheaderalternativelocustagp <-
+      DABL.takeTill (== 58)
+    -- Parse AH tag of the header section.
+    case (sqheaderalternativelocustagp =~ [re|[A][H]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Reference_Sequence_Dictionary_Alternative_Locus_Incorrect_Format
+      True  ->
+        -- AH tag is in the accepted format.
+        return ()
+  _                             <-
+    word8 58
+  sqheaderalternativelocusvalue <-
+    DABL.takeTill (\x -> x == 09 || isEndOfLine x)
   return SAM_V1_6_Reference_Sequence_Dictionary_Alternative_Locus { sam_v1_6_reference_sequence_dictionary_alternative_locus_value = sqheaderalternativelocusvalue
                                                                   }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Header/SQ/AN.hs b/src/Data/SAM/Version1_6/Read/Parser/Header/SQ/AN.hs
--- a/src/Data/SAM/Version1_6/Read/Parser/Header/SQ/AN.hs
+++ b/src/Data/SAM/Version1_6/Read/Parser/Header/SQ/AN.hs
@@ -14,7 +14,7 @@
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Read.Parser.Header.SQ.AN
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -55,18 +55,27 @@
 -- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
 parse_SAM_V1_6_Reference_Sequence_Dictionary_AN :: Parser SAM_V1_6_Reference_Sequence_Dictionary_Alternative_Reference_Sequence_Names
 parse_SAM_V1_6_Reference_Sequence_Dictionary_AN = do
-  _ <- do sqheaderalternativereferencesequencenamestagp <- DABL.takeTill (== 58)
-          -- Parse AN tag of the header section.
-          case (sqheaderalternativereferencesequencenamestagp =~ [re|[A][N]|]) of
-            False -> fail $ show SAM_V1_6_Error_Reference_Sequence_Dictionary_Alternative_Reference_Sequence_Names_Incorrect_Format
-            True  -> -- AN tag is in the accepted format.
-                     return ()
-  _ <- word8 58
-  sqheaderalternativereferencesequencenamesvalue <- do sqheaderalternativereferencesequencenamesvaluep <- DABL.takeTill (\x -> x == 09 || isEndOfLine x)
-                                                       -- Parse AN value of the header section.
-                                                       case (sqheaderalternativereferencesequencenamesvaluep =~ [re|[0-9A-Za-z!#$%&+.:;?@^_|~-][0-9A-Za-z!#$%&*+.:;=?@^_|~-]*(,[0-9A-Za-z!#$%&+.:;?@^_|~-][0-9A-Za-z!#$%&*+.:;=?@^_|~-]*)*|]) of
-                                                         False -> fail $ show SAM_V1_6_Error_Reference_Sequence_Dictionary_Alternative_Reference_Sequence_Names_Invalid_Value
-                                                         True  -> -- AN value is in the accepted format.
-                                                                  return sqheaderalternativereferencesequencenamesvaluep
+  _                                              <- do
+    sqheaderalternativereferencesequencenamestagp <-
+      DABL.takeTill (== 58)
+    -- Parse AN tag of the header section.
+    case (sqheaderalternativereferencesequencenamestagp =~ [re|[A][N]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Reference_Sequence_Dictionary_Alternative_Reference_Sequence_Names_Incorrect_Format
+      True  ->
+        -- AN tag is in the accepted format.
+        return ()
+  _                                              <-
+    word8 58
+  sqheaderalternativereferencesequencenamesvalue <- do
+    sqheaderalternativereferencesequencenamesvaluep <-
+      DABL.takeTill (\x -> x == 09 || isEndOfLine x)
+    -- Parse AN value of the header section.
+    case (sqheaderalternativereferencesequencenamesvaluep =~ [re|[0-9A-Za-z!#$%&+.:;?@^_|~-][0-9A-Za-z!#$%&*+.:;=?@^_|~-]*(,[0-9A-Za-z!#$%&+.:;?@^_|~-][0-9A-Za-z!#$%&*+.:;=?@^_|~-]*)*|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Reference_Sequence_Dictionary_Alternative_Reference_Sequence_Names_Invalid_Value
+      True  ->
+        -- AN value is in the accepted format.
+        return sqheaderalternativereferencesequencenamesvaluep
   return SAM_V1_6_Reference_Sequence_Dictionary_Alternative_Reference_Sequence_Names { sam_v1_6_reference_sequence_dictionary_alternative_reference_sequence_names_value = sqheaderalternativereferencesequencenamesvalue
                                                                                      }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Header/SQ/AS.hs b/src/Data/SAM/Version1_6/Read/Parser/Header/SQ/AS.hs
--- a/src/Data/SAM/Version1_6/Read/Parser/Header/SQ/AS.hs
+++ b/src/Data/SAM/Version1_6/Read/Parser/Header/SQ/AS.hs
@@ -14,7 +14,7 @@
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Read.Parser.Header.SQ.AS
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -55,13 +55,19 @@
 -- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
 parse_SAM_V1_6_Reference_Sequence_Dictionary_AS :: Parser SAM_V1_6_Reference_Sequence_Dictionary_Genome_Assembly_Identifier
 parse_SAM_V1_6_Reference_Sequence_Dictionary_AS = do
-  _ <- do sqheadergenomeassemblyidentifiertagp <- DABL.takeTill (== 58)
-          -- Parse AS tag of the header section.
-          case (sqheadergenomeassemblyidentifiertagp =~ [re|[A][S]|]) of
-            False -> fail $ show SAM_V1_6_Error_Reference_Sequence_Dictionary_Genome_Assembly_Identifier_Incorrect_Format
-            True  -> -- AS tag is in the accepted format.
-                     return ()
-  _ <- word8 58
-  sqheadergenomeassemblyidentifiervalue <- DABL.takeTill (\x -> x == 09 || isEndOfLine x)
+  _                                     <- do
+    sqheadergenomeassemblyidentifiertagp <-
+      DABL.takeTill (== 58)
+    -- Parse AS tag of the header section.
+    case (sqheadergenomeassemblyidentifiertagp =~ [re|[A][S]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Reference_Sequence_Dictionary_Genome_Assembly_Identifier_Incorrect_Format
+      True  ->
+        -- AS tag is in the accepted format.
+        return ()
+  _                                     <-
+    word8 58
+  sqheadergenomeassemblyidentifiervalue <-
+    DABL.takeTill (\x -> x == 09 || isEndOfLine x)
   return SAM_V1_6_Reference_Sequence_Dictionary_Genome_Assembly_Identifier { sam_v1_6_reference_sequence_dictionary_genome_assembly_identifier_value = sqheadergenomeassemblyidentifiervalue
                                                                            }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Header/SQ/Base.hs b/src/Data/SAM/Version1_6/Read/Parser/Header/SQ/Base.hs
--- a/src/Data/SAM/Version1_6/Read/Parser/Header/SQ/Base.hs
+++ b/src/Data/SAM/Version1_6/Read/Parser/Header/SQ/Base.hs
@@ -14,7 +14,7 @@
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Read.Parser.Header.SQ.Base
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -68,35 +68,42 @@
 -- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
 parse_SAM_V1_6_Reference_Sequence_Dictionary :: Parser SAM_V1_6_Reference_Sequence_Dictionary
 parse_SAM_V1_6_Reference_Sequence_Dictionary = do
-  _         <- do sqheaderp <- DABL.takeTill (== 09)
-                  -- Parse @SQ tag of the header section.
-                  case (sqheaderp =~ [re|[@][S][Q]|]) of
-                    False -> fail $ show SAM_V1_6_Error_File_Level_Metadata_Tag_Incorrect_Format
-                    True  -> -- @SQ tag is in the accepted format.
-                             return ()
-  _         <- word8 09
+  _  <- do
+    sqheaderp <-
+      DABL.takeTill (== 09)
+    -- Parse @SQ tag of the header section.
+    case (sqheaderp =~ [re|[@][S][Q]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_File_Level_Metadata_Tag_Incorrect_Format
+      True  ->
+        -- @SQ tag is in the accepted format.
+        return ()
+  _  <-
+    word8 09
   -- This parser assumes that the
   -- SN, LN, AH, AN, AS, DS, M5,
   -- SP, TP and UR tags can appear in any order.
-  sq <- intercalateEffect (word8 09) $
-          SAM_V1_6_Reference_Sequence_Dictionary
-            <$> toPermutation parse_SAM_V1_6_Reference_Sequence_Dictionary_SN
-            <*> toPermutation parse_SAM_V1_6_Reference_Sequence_Dictionary_LN
-            <*> toPermutationWithDefault Nothing
-                                         (Just <$> parse_SAM_V1_6_Reference_Sequence_Dictionary_AH)
-            <*> toPermutationWithDefault Nothing
-                                         (Just <$> parse_SAM_V1_6_Reference_Sequence_Dictionary_AN)
-            <*> toPermutationWithDefault Nothing
-                                         (Just <$> parse_SAM_V1_6_Reference_Sequence_Dictionary_AS)
-            <*> toPermutationWithDefault Nothing
-                                         (Just <$> parse_SAM_V1_6_Reference_Sequence_Dictionary_DS)
-            <*> toPermutationWithDefault Nothing
-                                         (Just <$> parse_SAM_V1_6_Reference_Sequence_Dictionary_M5)
-            <*> toPermutationWithDefault Nothing
-                                         (Just <$> parse_SAM_V1_6_Reference_Sequence_Dictionary_SP) 
-            <*> toPermutationWithDefault Nothing
-                                         (Just <$> parse_SAM_V1_6_Reference_Sequence_Dictionary_TP)
-            <*> toPermutationWithDefault Nothing
-                                         (Just <$> parse_SAM_V1_6_Reference_Sequence_Dictionary_UR)
-  _ <- endOfLine
+  sq <-
+    intercalateEffect (word8 09) $
+      SAM_V1_6_Reference_Sequence_Dictionary
+        <$> toPermutation parse_SAM_V1_6_Reference_Sequence_Dictionary_SN
+        <*> toPermutation parse_SAM_V1_6_Reference_Sequence_Dictionary_LN
+        <*> toPermutationWithDefault Nothing
+                                     (Just <$> parse_SAM_V1_6_Reference_Sequence_Dictionary_AH)
+        <*> toPermutationWithDefault Nothing
+                                     (Just <$> parse_SAM_V1_6_Reference_Sequence_Dictionary_AN)
+        <*> toPermutationWithDefault Nothing
+                                     (Just <$> parse_SAM_V1_6_Reference_Sequence_Dictionary_AS)
+        <*> toPermutationWithDefault Nothing
+                                     (Just <$> parse_SAM_V1_6_Reference_Sequence_Dictionary_DS)
+        <*> toPermutationWithDefault Nothing
+                                     (Just <$> parse_SAM_V1_6_Reference_Sequence_Dictionary_M5)
+        <*> toPermutationWithDefault Nothing
+                                     (Just <$> parse_SAM_V1_6_Reference_Sequence_Dictionary_SP) 
+        <*> toPermutationWithDefault Nothing
+                                     (Just <$> parse_SAM_V1_6_Reference_Sequence_Dictionary_TP)
+        <*> toPermutationWithDefault Nothing
+                                     (Just <$> parse_SAM_V1_6_Reference_Sequence_Dictionary_UR)
+  _  <-
+    endOfLine
   return sq
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Header/SQ/DS.hs b/src/Data/SAM/Version1_6/Read/Parser/Header/SQ/DS.hs
--- a/src/Data/SAM/Version1_6/Read/Parser/Header/SQ/DS.hs
+++ b/src/Data/SAM/Version1_6/Read/Parser/Header/SQ/DS.hs
@@ -14,7 +14,7 @@
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Read.Parser.Header.SQ.DS
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -55,13 +55,19 @@
 -- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
 parse_SAM_V1_6_Reference_Sequence_Dictionary_DS :: Parser SAM_V1_6_Reference_Sequence_Dictionary_Description
 parse_SAM_V1_6_Reference_Sequence_Dictionary_DS = do
-  _ <- do sqheaderdescriptiontagp <- DABL.takeTill (== 58)
-          -- Parse DS tag of the header section.
-          case (sqheaderdescriptiontagp =~ [re|[D][S]|]) of
-            False -> fail $ show SAM_V1_6_Error_Reference_Sequence_Dictionary_Description_Incorrect_Format 
-            True  -> -- DS tag is in the accepted format.
-                     return ()
-  _ <- word8 58
-  sqheaderdescriptionvalue <- DABL.takeTill (\x -> x == 09 || isEndOfLine x)
+  _                        <- do
+    sqheaderdescriptiontagp <-
+      DABL.takeTill (== 58)
+    -- Parse DS tag of the header section.
+    case (sqheaderdescriptiontagp =~ [re|[D][S]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Reference_Sequence_Dictionary_Description_Incorrect_Format 
+      True  ->
+        -- DS tag is in the accepted format.
+        return ()
+  _                        <-
+    word8 58
+  sqheaderdescriptionvalue <-
+    DABL.takeTill (\x -> x == 09 || isEndOfLine x)
   return SAM_V1_6_Reference_Sequence_Dictionary_Description { sam_v1_6_reference_sequence_dictionary_description_value = sqheaderdescriptionvalue
                                                             }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Header/SQ/LN.hs b/src/Data/SAM/Version1_6/Read/Parser/Header/SQ/LN.hs
--- a/src/Data/SAM/Version1_6/Read/Parser/Header/SQ/LN.hs
+++ b/src/Data/SAM/Version1_6/Read/Parser/Header/SQ/LN.hs
@@ -14,7 +14,7 @@
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Read.Parser.Header.SQ.LN
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -55,18 +55,27 @@
 -- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
 parse_SAM_V1_6_Reference_Sequence_Dictionary_LN :: Parser SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Length
 parse_SAM_V1_6_Reference_Sequence_Dictionary_LN = do
-  _ <- do sqheadersequencelengthtagp <- DABL.takeTill (== 58)
-          -- Parse LN tag of the header section.
-          case (sqheadersequencelengthtagp =~ [re|[L][N]|]) of
-            False -> fail $ show SAM_V1_6_Error_Reference_Sequence_Dictionary_Reference_Sequence_Length_Incorrect_Format
-            True  -> -- LN tag is in the accepted format.
-                     return ()
-  _ <- word8 58
-  sqheadersequencelengthvalue <- do sqheadersequencelengthvaluep <- DABL.takeTill (\x -> x == 09 || isEndOfLine x)
-                                    -- Parse LN value of the header section.
-                                    case (sqheadersequencelengthvaluep =~ [re|[0-9]*|]) of -- Make this regex actually check the range of [1,2^31 - 1]?
-                                      False -> fail $ show SAM_V1_6_Error_Reference_Sequence_Dictionary_Reference_Sequence_Length_Invalid_Value
-                                      True  -> -- LN value is in the accepted format.
-                                               return sqheadersequencelengthvaluep
+  _                           <- do
+    sqheadersequencelengthtagp <-
+      DABL.takeTill (== 58)
+    -- Parse LN tag of the header section.
+    case (sqheadersequencelengthtagp =~ [re|[L][N]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Reference_Sequence_Dictionary_Reference_Sequence_Length_Incorrect_Format
+      True  ->
+        -- LN tag is in the accepted format.
+        return ()
+  _                           <-
+    word8 58
+  sqheadersequencelengthvalue <- do
+    sqheadersequencelengthvaluep <-
+      DABL.takeTill (\x -> x == 09 || isEndOfLine x)
+    -- Parse LN value of the header section.
+    case (sqheadersequencelengthvaluep =~ [re|[0-9]*|]) of -- Make this regex actually check the range of [1,2^31 - 1]?
+      False ->
+        fail $ show SAM_V1_6_Error_Reference_Sequence_Dictionary_Reference_Sequence_Length_Invalid_Value
+      True  ->
+        -- LN value is in the accepted format.
+        return sqheadersequencelengthvaluep
   return SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Length { sam_v1_6_reference_sequence_dictionary_reference_sequence_length_value = sqheadersequencelengthvalue
                                                                           }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Header/SQ/M5.hs b/src/Data/SAM/Version1_6/Read/Parser/Header/SQ/M5.hs
--- a/src/Data/SAM/Version1_6/Read/Parser/Header/SQ/M5.hs
+++ b/src/Data/SAM/Version1_6/Read/Parser/Header/SQ/M5.hs
@@ -14,7 +14,7 @@
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Read.Parser.Header.SQ.M5
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -55,13 +55,19 @@
 -- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
 parse_SAM_V1_6_Reference_Sequence_Dictionary_M5 :: Parser SAM_V1_6_Reference_Sequence_Dictionary_MD5_Checksum
 parse_SAM_V1_6_Reference_Sequence_Dictionary_M5 = do
-  _ <- do sqheadermd5checksumtagp <- DABL.takeTill (== 58)
-          -- Parse M5 tag of the header section.
-          case (sqheadermd5checksumtagp =~ [re|[M][5]|]) of
-            False -> fail $ show SAM_V1_6_Error_Reference_Sequence_Dictionary_MD5_Checksum_Incorrect_Format 
-            True  -> -- M5 tag is in the accepted format.
-                     return ()
-  _ <- word8 58
-  sqheadermd5checksumvalue <- DABL.takeTill (\x -> x == 09 || isEndOfLine x)
+  _                        <- do
+    sqheadermd5checksumtagp <-
+      DABL.takeTill (== 58)
+    -- Parse M5 tag of the header section.
+    case (sqheadermd5checksumtagp =~ [re|[M][5]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Reference_Sequence_Dictionary_MD5_Checksum_Incorrect_Format 
+      True  ->
+        -- M5 tag is in the accepted format.
+        return ()
+  _                        <-
+    word8 58
+  sqheadermd5checksumvalue <-
+    DABL.takeTill (\x -> x == 09 || isEndOfLine x)
   return SAM_V1_6_Reference_Sequence_Dictionary_MD5_Checksum { sam_v1_6_reference_sequence_dictionary_md5_checksum_value = sqheadermd5checksumvalue
                                                              }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Header/SQ/SN.hs b/src/Data/SAM/Version1_6/Read/Parser/Header/SQ/SN.hs
--- a/src/Data/SAM/Version1_6/Read/Parser/Header/SQ/SN.hs
+++ b/src/Data/SAM/Version1_6/Read/Parser/Header/SQ/SN.hs
@@ -14,7 +14,7 @@
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Read.Parser.Header.SQ.SN
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -55,18 +55,27 @@
 -- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
 parse_SAM_V1_6_Reference_Sequence_Dictionary_SN :: Parser SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Name
 parse_SAM_V1_6_Reference_Sequence_Dictionary_SN = do
-  _ <- do sqheadersequencenametagp <- DABL.takeTill (== 58)
-          -- Parse SN tag of the header section.
-          case (sqheadersequencenametagp =~ [re|[S][N]|]) of
-            False -> fail $ show SAM_V1_6_Error_Reference_Sequence_Dictionary_Reference_Sequence_Name_Incorrect_Format
-            True  -> -- SN tag is in the accepted format. 
-                     return ()
-  _ <- word8 58
-  sqheadersequencenamevalue <- do sqheadersequencenamevaluep <- DABL.takeTill (\x -> x == 09 || isEndOfLine x)
-                                  -- Parse SN value of the header section.
-                                  case (sqheadersequencenamevaluep =~ [re|[0-9A-Za-z!#$%&+./:;?@^_|~-][0-9A-Za-z!#$%&*+./:;=?@^_|~-]*|]) of
-                                    False -> fail $ show SAM_V1_6_Error_Reference_Sequence_Dictionary_Reference_Sequence_Name_Invalid_Value
-                                    True  -> -- SN value is in the accepted format.
-                                             return sqheadersequencenamevaluep
+  _                         <- do
+    sqheadersequencenametagp <-
+      DABL.takeTill (== 58)
+    -- Parse SN tag of the header section.
+    case (sqheadersequencenametagp =~ [re|[S][N]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Reference_Sequence_Dictionary_Reference_Sequence_Name_Incorrect_Format
+      True  ->
+        -- SN tag is in the accepted format. 
+        return ()
+  _                         <-
+    word8 58
+  sqheadersequencenamevalue <- do
+    sqheadersequencenamevaluep <-
+      DABL.takeTill (\x -> x == 09 || isEndOfLine x)
+    -- Parse SN value of the header section.
+    case (sqheadersequencenamevaluep =~ [re|[0-9A-Za-z!#$%&+./:;?@^_|~-][0-9A-Za-z!#$%&*+./:;=?@^_|~-]*|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Reference_Sequence_Dictionary_Reference_Sequence_Name_Invalid_Value
+      True  ->
+        -- SN value is in the accepted format.
+        return sqheadersequencenamevaluep
   return SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Name { sam_v1_6_reference_sequence_dictionary_reference_sequence_name_value = sqheadersequencenamevalue
                                                                         }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Header/SQ/SP.hs b/src/Data/SAM/Version1_6/Read/Parser/Header/SQ/SP.hs
--- a/src/Data/SAM/Version1_6/Read/Parser/Header/SQ/SP.hs
+++ b/src/Data/SAM/Version1_6/Read/Parser/Header/SQ/SP.hs
@@ -15,7 +15,7 @@
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Read.Parser.Header.SQ.SP
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -56,13 +56,19 @@
 -- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
 parse_SAM_V1_6_Reference_Sequence_Dictionary_SP :: Parser SAM_V1_6_Reference_Sequence_Dictionary_Species
 parse_SAM_V1_6_Reference_Sequence_Dictionary_SP = do
-  _ <- do sqheaderspeciestagp <- DABL.takeTill (== 58)
-          -- Parse SP tag of the header section.
-          case (sqheaderspeciestagp =~ [re|[S][P]|]) of
-            False -> fail $ show SAM_V1_6_Error_Reference_Sequence_Dictionary_Species_Incorrect_Format
-            True  -> -- SP tag is in the accepted format.
-                     return ()
-  _ <- word8 58
-  sqheaderspeciesvalue <- DABL.takeTill (\x -> x == 09 || isEndOfLine x)
+  _                    <- do
+    sqheaderspeciestagp <-
+      DABL.takeTill (== 58)
+    -- Parse SP tag of the header section.
+    case (sqheaderspeciestagp =~ [re|[S][P]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Reference_Sequence_Dictionary_Species_Incorrect_Format
+      True  ->
+        -- SP tag is in the accepted format.
+        return ()
+  _                    <-
+    word8 58
+  sqheaderspeciesvalue <-
+    DABL.takeTill (\x -> x == 09 || isEndOfLine x)
   return SAM_V1_6_Reference_Sequence_Dictionary_Species { sam_v1_6_reference_sequence_dictionary_species_value = sqheaderspeciesvalue
                                                         }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Header/SQ/TP.hs b/src/Data/SAM/Version1_6/Read/Parser/Header/SQ/TP.hs
--- a/src/Data/SAM/Version1_6/Read/Parser/Header/SQ/TP.hs
+++ b/src/Data/SAM/Version1_6/Read/Parser/Header/SQ/TP.hs
@@ -14,7 +14,7 @@
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Read.Parser.Header.SQ.TP
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -55,18 +55,27 @@
 -- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
 parse_SAM_V1_6_Reference_Sequence_Dictionary_TP :: Parser SAM_V1_6_Reference_Sequence_Dictionary_Molecule_Topology
 parse_SAM_V1_6_Reference_Sequence_Dictionary_TP = do
-  _ <- do sqheadermoleculetopologytagp <- DABL.takeTill (== 58)
-          -- Parse TP tag of the header section.
-          case (sqheadermoleculetopologytagp =~ [re|[T][P]|]) of
-            False -> fail $ show SAM_V1_6_Error_Reference_Sequence_Dictionary_Molecule_Topology_Incorrect_Format
-            True  -> -- TP tag is in the accepted format. 
-                     return ()
-  _ <- word8 58
-  sqheadermoleculetopologyvalue <- do sqheadermoleculetopologyvaluep <- DABL.takeTill (\x -> x == 09 || isEndOfLine x)
-                                      -- Parse TP value of the header section.
-                                      case (sqheadermoleculetopologyvaluep =~ [re|[l][i][n][e][a][r]|[c][i][r][c][u][l][a][r]|]) of
-                                        False -> fail $ show SAM_V1_6_Error_Reference_Sequence_Dictionary_Molecule_Topology_Invalid_Value
-                                        True  -> -- TP value is in the accepted format.
-                                                 return sqheadermoleculetopologyvaluep
+  _                             <- do
+    sqheadermoleculetopologytagp <-
+      DABL.takeTill (== 58)
+    -- Parse TP tag of the header section.
+    case (sqheadermoleculetopologytagp =~ [re|[T][P]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Reference_Sequence_Dictionary_Molecule_Topology_Incorrect_Format
+      True  ->
+        -- TP tag is in the accepted format. 
+        return ()
+  _                             <-
+    word8 58
+  sqheadermoleculetopologyvalue <- do
+    sqheadermoleculetopologyvaluep <-
+      DABL.takeTill (\x -> x == 09 || isEndOfLine x)
+    -- Parse TP value of the header section.
+    case (sqheadermoleculetopologyvaluep =~ [re|[l][i][n][e][a][r]|[c][i][r][c][u][l][a][r]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Reference_Sequence_Dictionary_Molecule_Topology_Invalid_Value
+      True  ->
+        -- TP value is in the accepted format.
+        return sqheadermoleculetopologyvaluep
   return SAM_V1_6_Reference_Sequence_Dictionary_Molecule_Topology { sam_v1_6_reference_sequence_dictionary_molecule_topology_value = sqheadermoleculetopologyvalue
                                                                   }
diff --git a/src/Data/SAM/Version1_6/Read/Parser/Header/SQ/UR.hs b/src/Data/SAM/Version1_6/Read/Parser/Header/SQ/UR.hs
--- a/src/Data/SAM/Version1_6/Read/Parser/Header/SQ/UR.hs
+++ b/src/Data/SAM/Version1_6/Read/Parser/Header/SQ/UR.hs
@@ -14,7 +14,7 @@
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Read.Parser.Header.SQ.UR
--- Copyright   :  (c) Matthew Mosior 2023
+-- Copyright   :  (c) Matthew Mosior 2024
 -- License     :  BSD-style
 -- Maintainer  :  mattm.github@gmail.com
 -- Portability :  portable
@@ -55,13 +55,19 @@
 -- See the [SAM v1.6](http://samtools.github.io/hts-specs/SAMv1.pdf) specification documentation.
 parse_SAM_V1_6_Reference_Sequence_Dictionary_UR :: Parser SAM_V1_6_Reference_Sequence_Dictionary_URI
 parse_SAM_V1_6_Reference_Sequence_Dictionary_UR = do
-  _ <- do sqheaderuritagp <- DABL.takeTill (== 58)
-          -- Parse UR tag of the header section.
-          case (sqheaderuritagp =~ [re|[U][R]|]) of
-            False -> fail $ show SAM_V1_6_Error_Reference_Sequence_Dictionary_URI_Incorrect_Format
-            True  -> -- UR tag is in the accepted format.
-                     return ()
-  _ <- word8 58
-  sqheaderurivalue <- DABL.takeTill (\x -> x == 09 || isEndOfLine x)
+  _                <- do
+    sqheaderuritagp <-
+      DABL.takeTill (== 58)
+    -- Parse UR tag of the header section.
+    case (sqheaderuritagp =~ [re|[U][R]|]) of
+      False ->
+        fail $ show SAM_V1_6_Error_Reference_Sequence_Dictionary_URI_Incorrect_Format
+      True  ->
+        -- UR tag is in the accepted format.
+        return ()
+  _                <-
+    word8 58
+  sqheaderurivalue <-
+    DABL.takeTill (\x -> x == 09 || isEndOfLine x)
   return SAM_V1_6_Reference_Sequence_Dictionary_URI { sam_v1_6_reference_sequence_dictionary_uri_value = sqheaderurivalue
                                                     }
diff --git a/src/Data/SAM/Version1_6/Write/Base.hs b/src/Data/SAM/Version1_6/Write/Base.hs
--- a/src/Data/SAM/Version1_6/Write/Base.hs
+++ b/src/Data/SAM/Version1_6/Write/Base.hs
@@ -5,537 +5,994 @@
 
 -- |
 -- Module      :  Data.SAM.Version1_6.Write.Base
--- Copyright   :  (c) Matthew Mosior 2023
--- License     :  BSD-style
--- Maintainer  :  mattm.github@gmail.com
--- Portability :  portable
---
--- = Description
---
--- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
-
-module Data.SAM.Version1_6.Write.Base ( -- * Writing
-                                       writeSAM_V1_6
-                                      ) where
-
-import Data.SAM.Version1_6.Base
-import Data.SAM.Version1_6.Header.HD
-import Data.SAM.Version1_6.Header.SQ
-import Data.SAM.Version1_6.Header.RG
-import Data.SAM.Version1_6.Header.PG
-import Data.SAM.Version1_6.Header.CO
-import Data.SAM.Version1_6.Alignment.Base
-import Data.SAM.Version1_6.Alignment.AOPT
-import Data.SAM.Version1_6.Alignment.IOPT
-import Data.SAM.Version1_6.Alignment.FOPT
-import Data.SAM.Version1_6.Alignment.ZOPT
-import Data.SAM.Version1_6.Alignment.HOPT
-import Data.SAM.Version1_6.Alignment.BOPT
-
-import Data.ByteString            as DB    (pack,singleton)
-import Data.ByteString.Lazy       as DBL   (filter)
-import Data.ByteString.Lazy.Char8 as DBLC8 (fromStrict,unpack)
-import Data.Foldable                       (toList)
-import Data.List                           (intercalate)
-import Data.Word
-import Data.ByteString.Builder             (toLazyByteString,word16LE,word32LE)
-import System.IO                           (hFlush,hClose,hPutStr,IOMode(..),openFile, Handle)
-
-
--- | Deconstruct a @"SAM_V1_6"@ to a `String`.
-deconstructSAM_V1_6 :: SAM_V1_6
-                    -> String
-deconstructSAM_V1_6 samv16 =
-  ( intercalate "\n" $
-      Prelude.filter (not . Prelude.null)
-                          [ sam_v1_6_file_level_metadata_tos
-                          , sam_v1_6_reference_sequence_dictionary_tos
-                          , sam_v1_6_read_group_tos
-                          , sam_v1_6_program_tos
-                          , sam_v1_6_one_line_comment_tos
-                          , sam_v1_6_alignment_tos
-                          ]
-  )
-  ++ "\n"
-  where
-    sam_v1_6_file_level_metadata_format_version_tos x = "VN:" ++
-                                                        ( unpack     $
-                                                          fromStrict $
-                                                          sam_v1_6_file_level_metadata_format_version_value $
-                                                          sam_v1_6_file_level_metadata_format_version x
-                                                        )
-    sam_v1_6_file_level_metadata_sorting_order_tos x = case (sam_v1_6_file_level_metadata_sorting_order x) of
-                                                         Nothing  -> ""
-                                                         Just rgf -> "SO:" ++
-                                                                     ( unpack     $
-                                                                       fromStrict $
-                                                                       sam_v1_6_file_level_metadata_sorting_order_value rgf
-                                                                     )
-    sam_v1_6_file_level_metadata_alignment_grouping_tos x = case (sam_v1_6_file_level_metadata_alignment_grouping x) of
-                                                              Nothing  -> ""
-                                                              Just rgf -> "GO:" ++
-                                                                          ( unpack     $
-                                                                            fromStrict $
-                                                                            sam_v1_6_file_level_metadata_alignment_grouping_value rgf
-                                                                          )
-    sam_v1_6_file_level_metadata_subsorting_order_tos x = case (sam_v1_6_file_level_metadata_subsorting_order x) of
-                                                            Nothing  -> ""
-                                                            Just rgf -> "SS:" ++
-                                                                        ( unpack     $
-                                                                          fromStrict $
-                                                                          sam_v1_6_file_level_metadata_subsorting_order_value rgf
-                                                                        )
-    sam_v1_6_file_level_metadata_tos = case (sam_v1_6_file_level_metadata samv16) of
-                                         Nothing  -> ""
-                                         Just hdf -> intercalate "\t" $
-                                                       Prelude.filter (not . Prelude.null) $
-                                                                           [ "@HD"
-                                                                           , sam_v1_6_file_level_metadata_format_version_tos hdf
-                                                                           , sam_v1_6_file_level_metadata_sorting_order_tos hdf
-                                                                           , sam_v1_6_file_level_metadata_alignment_grouping_tos hdf
-                                                                           , sam_v1_6_file_level_metadata_subsorting_order_tos hdf 
-                                                                           ]
-    sam_v1_6_reference_sequence_dictionary_reference_sequence_name_tos x = "SN:" ++
-                                                                           ( unpack                                                               $
-                                                                             fromStrict                                                           $
-                                                                             sam_v1_6_reference_sequence_dictionary_reference_sequence_name_value $
-                                                                             sam_v1_6_reference_sequence_dictionary_reference_sequence_name x
-                                                                           )
-    sam_v1_6_reference_sequence_dictionary_reference_sequence_length_tos x = "LN:" ++
-                                                                             ( unpack                                                                 $
-                                                                               fromStrict                                                             $
-                                                                               sam_v1_6_reference_sequence_dictionary_reference_sequence_length_value $
-                                                                               sam_v1_6_reference_sequence_dictionary_reference_sequence_length x
-                                                                             )
-    sam_v1_6_reference_sequence_dictionary_alternative_locus_tos x = case (sam_v1_6_reference_sequence_dictionary_alternative_locus x) of
-                                                                       Nothing  -> ""
-                                                                       Just sqf -> "AH:" ++
-                                                                                   ( unpack     $
-                                                                                     fromStrict $
-                                                                                     sam_v1_6_reference_sequence_dictionary_alternative_locus_value sqf
-                                                                                   )
-    sam_v1_6_reference_sequence_dictionary_alternative_reference_sequence_names_tos x = case (sam_v1_6_reference_sequence_dictionary_alternative_reference_sequence_names x) of
-                                                                                          Nothing  -> "" 
-                                                                                          Just sqf -> "AN:" ++
-                                                                                                      ( unpack     $
-                                                                                                        fromStrict $
-                                                                                                        sam_v1_6_reference_sequence_dictionary_alternative_reference_sequence_names_value sqf
-                                                                                                      )
-    sam_v1_6_reference_sequence_dictionary_genome_assembly_identifier_tos x = case (sam_v1_6_reference_sequence_dictionary_genome_assembly_identifier x) of
-                                                                                Nothing  -> ""
-                                                                                Just sqf -> "AS:" ++
-                                                                                            ( unpack     $
-                                                                                              fromStrict $
-                                                                                              sam_v1_6_reference_sequence_dictionary_genome_assembly_identifier_value sqf
-                                                                                            )
-    sam_v1_6_reference_sequence_dictionary_description_tos x = case (sam_v1_6_reference_sequence_dictionary_description x) of
-                                                                 Nothing  -> ""
-                                                                 Just sqf -> "DS:" ++
-                                                                             ( unpack     $
-                                                                               fromStrict $
-                                                                               sam_v1_6_reference_sequence_dictionary_description_value sqf
-                                                                             )
-    sam_v1_6_reference_sequence_dictionary_md5_checksum_tos x = case (sam_v1_6_reference_sequence_dictionary_md5_checksum x) of
-                                                                  Nothing  -> ""
-                                                                  Just sqf -> "M5:" ++
-                                                                              ( unpack     $
-                                                                                fromStrict $
-                                                                                sam_v1_6_reference_sequence_dictionary_md5_checksum_value sqf
-                                                                              )
-    sam_v1_6_reference_sequence_dictionary_species_tos x = case (sam_v1_6_reference_sequence_dictionary_species x) of
-                                                             Nothing  -> ""
-                                                             Just sqf -> "SP:" ++
-                                                                         ( unpack     $
-                                                                           fromStrict $
-                                                                           sam_v1_6_reference_sequence_dictionary_species_value sqf
-                                                                         )
-    sam_v1_6_reference_sequence_dictionary_molecule_topology_tos x = case (sam_v1_6_reference_sequence_dictionary_molecule_topology x) of
-                                                                       Nothing  -> ""
-                                                                       Just sqf -> "TP:" ++
-                                                                                   ( unpack     $
-                                                                                     fromStrict $
-                                                                                     sam_v1_6_reference_sequence_dictionary_molecule_topology_value sqf
-                                                                                   )
-    sam_v1_6_reference_sequence_dictionary_uri_tos x = case (sam_v1_6_reference_sequence_dictionary_uri x) of
-                                                         Nothing  -> ""
-                                                         Just sqf -> "UR:" ++
-                                                                     ( unpack     $
-                                                                       fromStrict $
-                                                                       sam_v1_6_reference_sequence_dictionary_uri_value sqf
-                                                                     )
-    sam_v1_6_reference_sequence_dictionary_tos = case (sam_v1_6_reference_sequence_dictionary samv16) of
-                                                   Nothing  -> ""
-                                                   Just sqf -> intercalate "\n" $
-                                                                   map (\x -> intercalate "\t" $
-                                                                                Prelude.filter (not . Prelude.null) $
-                                                                                                    [ "@SQ"
-                                                                                                    , sam_v1_6_reference_sequence_dictionary_reference_sequence_name_tos x
-                                                                                                    , sam_v1_6_reference_sequence_dictionary_reference_sequence_length_tos x
-                                                                                                    , sam_v1_6_reference_sequence_dictionary_alternative_locus_tos x
-                                                                                                    , sam_v1_6_reference_sequence_dictionary_alternative_reference_sequence_names_tos x
-                                                                                                    , sam_v1_6_reference_sequence_dictionary_genome_assembly_identifier_tos x
-                                                                                                    , sam_v1_6_reference_sequence_dictionary_description_tos x
-                                                                                                    , sam_v1_6_reference_sequence_dictionary_md5_checksum_tos x
-                                                                                                    , sam_v1_6_reference_sequence_dictionary_species_tos x
-                                                                                                    , sam_v1_6_reference_sequence_dictionary_molecule_topology_tos x
-                                                                                                    , sam_v1_6_reference_sequence_dictionary_uri_tos x
-                                                                                                    ]
-                                                                       ) (toList sqf)
-    sam_v1_6_read_group_identifer_tos x = "ID:" ++
-                                          ( unpack                               $
-                                            fromStrict                           $
-                                            sam_v1_6_read_group_identifier_value $
-                                            sam_v1_6_read_group_identifier x
-                                          )
-    sam_v1_6_read_group_barcode_sequence_tos x = case (sam_v1_6_read_group_barcode_sequence x) of
-                                                   Nothing  -> ""
-                                                   Just rgf -> "BC:" ++
-                                                               ( unpack     $
-                                                                 fromStrict $
-                                                                 sam_v1_6_read_group_barcode_sequence_value rgf
-                                                               )
-    sam_v1_6_read_group_sequencing_center_tos x = case (sam_v1_6_read_group_sequencing_center x) of
-                                                    Nothing  -> ""
-                                                    Just rgf -> "CN:" ++
-                                                                ( unpack     $
-                                                                  fromStrict $
-                                                                  sam_v1_6_read_group_sequencing_center_value rgf
-                                                                )
-    sam_v1_6_read_group_description_tos x = case (sam_v1_6_read_group_description x) of
-                                              Nothing  -> ""
-                                              Just rgf -> "DS:" ++
-                                                          ( unpack     $
-                                                            fromStrict $
-                                                            sam_v1_6_read_group_description_value rgf
-                                                          )
-    sam_v1_6_read_group_run_date_tos x = case (sam_v1_6_read_group_run_date x) of
-                                           Nothing  -> ""
-                                           Just rgf -> "DT:" ++
-                                                       ( unpack     $
-                                                         fromStrict $
-                                                         sam_v1_6_read_group_run_date_value rgf
-                                                       )
-    sam_v1_6_read_group_flow_order_tos x = case (sam_v1_6_read_group_flow_order x) of
-                                             Nothing  -> ""
-                                             Just rgf -> "FO:" ++
-                                                         ( unpack     $
-                                                           fromStrict $
-                                                           sam_v1_6_read_group_flow_order_value rgf
-                                                         )
-    sam_v1_6_read_group_key_sequence_tos x = case (sam_v1_6_read_group_key_sequence x) of
-                                               Nothing  -> ""
-                                               Just rgf -> "KS:" ++
-                                                           ( unpack     $
-                                                             fromStrict $
-                                                             sam_v1_6_read_group_key_sequence_value rgf
-                                                           )
-    sam_v1_6_read_group_library_tos x = case (sam_v1_6_read_group_library x) of
-                                          Nothing  -> ""
-                                          Just rgf -> "LB:" ++
-                                                      ( unpack     $
-                                                        fromStrict $
-                                                        sam_v1_6_read_group_library_value rgf
-                                                      )
-    sam_v1_6_read_group_programs_tos x = case (sam_v1_6_read_group_programs x) of
-                                           Nothing  -> ""
-                                           Just rgf -> "PG:" ++
-                                                       ( unpack     $
-                                                         fromStrict $
-                                                         sam_v1_6_read_group_programs_value rgf
-                                                       )
-    sam_v1_6_read_group_predicted_median_insert_size_tos x = case (sam_v1_6_read_group_predicted_median_insert_size x) of
-                                                               Nothing  -> ""
-                                                               Just rgf -> "PI:" ++
-                                                                           ( unpack     $
-                                                                             fromStrict $
-                                                                             sam_v1_6_read_group_predicted_median_insert_size_value rgf
-                                                                           )
-    sam_v1_6_read_group_platform_tos x = case (sam_v1_6_read_group_platform x) of
-                                           Nothing  -> ""
-                                           Just rgf -> "PL:" ++
-                                                       ( unpack     $
-                                                         fromStrict $
-                                                         sam_v1_6_read_group_platform_value rgf
-                                                       )
-    sam_v1_6_read_group_platform_model_tos x = case (sam_v1_6_read_group_platform_model x) of
-                                                 Nothing  -> ""
-                                                 Just rgf -> "PM:" ++
-                                                             ( unpack     $
-                                                               fromStrict $
-                                                               sam_v1_6_read_group_platform_model_value rgf
-                                                             )
-    sam_v1_6_read_group_platform_unit_tos x = case (sam_v1_6_read_group_platform_unit x) of
-                                                Nothing  -> ""
-                                                Just rgf -> "PU:" ++
-                                                            ( unpack     $
-                                                              fromStrict $
-                                                              sam_v1_6_read_group_platform_unit_value rgf
-                                                            )
-    sam_v1_6_read_group_sample_tos x = case (sam_v1_6_read_group_sample x) of
-                                         Nothing  -> ""
-                                         Just rgf -> "SM:" ++
-                                                     ( unpack     $
-                                                       fromStrict $
-                                                       sam_v1_6_read_group_sample_value rgf
-                                                     )
-    sam_v1_6_read_group_tos = case (sam_v1_6_read_group samv16) of
-                                Nothing  -> ""
-                                Just rgf -> intercalate "\n" $
-                                              map (\x -> intercalate "\t" $
-                                                           Prelude.filter (not . Prelude.null) $
-                                                                               [ "@RG"
-                                                                               , sam_v1_6_read_group_identifer_tos x
-                                                                               , sam_v1_6_read_group_barcode_sequence_tos x
-                                                                               , sam_v1_6_read_group_sequencing_center_tos x
-                                                                               , sam_v1_6_read_group_description_tos x
-                                                                               , sam_v1_6_read_group_run_date_tos x
-                                                                               , sam_v1_6_read_group_flow_order_tos x
-                                                                               , sam_v1_6_read_group_key_sequence_tos x
-                                                                               , sam_v1_6_read_group_library_tos x
-                                                                               , sam_v1_6_read_group_programs_tos x
-                                                                               , sam_v1_6_read_group_predicted_median_insert_size_tos x
-                                                                               , sam_v1_6_read_group_platform_tos x
-                                                                               , sam_v1_6_read_group_platform_model_tos x
-                                                                               , sam_v1_6_read_group_platform_unit_tos x
-                                                                               , sam_v1_6_read_group_sample_tos x
-                                                                               ]
-                                                  ) (toList rgf)
-    sam_v1_6_program_record_identifier_tos x = "ID:" ++
-                                               ( unpack                                   $
-                                                 fromStrict                               $
-                                                 sam_v1_6_program_record_identifier_value $
-                                                 sam_v1_6_program_record_identifier x
-                                               )
-    sam_v1_6_program_name_tos x = case (sam_v1_6_program_name x) of
-                                    Nothing  -> ""
-                                    Just rgf -> "PN:" ++
-                                                ( unpack     $
-                                                  fromStrict $
-                                                  sam_v1_6_program_name_value rgf
-                                                )
-    sam_v1_6_program_command_line_tos x = case (sam_v1_6_program_command_line x) of
-                                            Nothing  -> ""
-                                            Just rgf -> "CL:" ++
-                                                        ( unpack     $
-                                                          fromStrict $
-                                                          sam_v1_6_program_command_line_value rgf
-                                                        )
-    sam_v1_6_program_previous_pg_id_tos x = case (sam_v1_6_program_previous_pg_id x) of
-                                              Nothing  -> ""
-                                              Just rgf -> "PP:" ++
-                                                          ( unpack     $
-                                                            fromStrict $
-                                                            sam_v1_6_program_previous_pg_id_value rgf
-                                                          )
-    sam_v1_6_program_description_tos x = case (sam_v1_6_program_description x) of
-                                           Nothing  -> ""
-                                           Just rgf -> "DS:" ++
-                                                       ( unpack     $
-                                                         fromStrict $
-                                                         sam_v1_6_program_description_value rgf
-                                                       )
-    sam_v1_6_program_version_tos x = case (sam_v1_6_program_version x) of
-                                       Nothing  -> ""
-                                       Just rgf -> "VN:" ++
-                                                   ( unpack     $
-                                                     fromStrict $
-                                                     sam_v1_6_program_version_value rgf
-                                                   )
-    sam_v1_6_program_tos = case (sam_v1_6_program samv16) of
-                             Nothing  -> ""
-                             Just pgf -> intercalate "\t" $
-                                           Prelude.filter (not . Prelude.null) $
-                                                               [ "@PG"
-                                                               , sam_v1_6_program_record_identifier_tos pgf
-                                                               , sam_v1_6_program_name_tos pgf
-                                                               , sam_v1_6_program_command_line_tos pgf
-                                                               , sam_v1_6_program_previous_pg_id_tos pgf
-                                                               , sam_v1_6_program_description_tos pgf
-                                                               , sam_v1_6_program_version_tos pgf
-                                                               ]
-    sam_v1_6_one_line_comment_tos = case (sam_v1_6_one_line_comment samv16) of
-                                      Nothing  -> ""
-                                      Just cof -> intercalate "\n" $
-                                                    map (\x -> intercalate "\t" $
-                                                                 Prelude.filter (not . Prelude.null) 
-                                                                                     [ "@CO"
-                                                                                     , unpack     $
-                                                                                       fromStrict $
-                                                                                       sam_v1_6_one_line_comment_value x
-                                                                                     ]
-                                                        ) (toList cof)
-    sam_v1_6_alignment_tos            = intercalate "\n" $
-                                          map (\x -> case (Prelude.null $ sam_v1_6_alignment_opts x) of
-                                                       True  -> sam_v1_6_alignment_mand x 
-                                                       False -> intercalate "\t"
-                                                                            [ sam_v1_6_alignment_mand x
-                                                                            , sam_v1_6_alignment_opts x
-                                                                            ] ) (toList $ sam_v1_6_alignment samv16)
-    sam_v1_6_alignment_mand x           = intercalate "\t" $
-                                            Prelude.filter (not . Prelude.null)
-                                                                [ unpack $ fromStrict $ sam_v1_6_alignment_qname x 
-                                                                , show $ sam_v1_6_alignment_flag x 
-                                                                , unpack $ fromStrict $ sam_v1_6_alignment_rname x 
-                                                                , show $ sam_v1_6_alignment_pos x 
-                                                                , show $ sam_v1_6_alignment_mapq x 
-                                                                , unpack $ fromStrict $ sam_v1_6_alignment_cigar x 
-                                                                , unpack $ fromStrict $ sam_v1_6_alignment_rnext x 
-                                                                , show $ sam_v1_6_alignment_pnext x 
-                                                                , show $ sam_v1_6_alignment_tlen x 
-                                                                , unpack $ fromStrict $ sam_v1_6_alignment_seq x 
-                                                                , unpack $ fromStrict $ sam_v1_6_alignment_qual x
-                                                                ]
-    sam_v1_6_alignment_opts x           = intercalate "\t" $
-                                            Prelude.filter (not . Prelude.null)
-                                                                [ sam_v1_6_alignment_aopt_d x 
-                                                                , sam_v1_6_alignment_iopt_d x 
-                                                                , sam_v1_6_alignment_fopt_d x 
-                                                                , sam_v1_6_alignment_zopt_d x
-                                                                , sam_v1_6_alignment_hopt_d x 
-                                                                , sam_v1_6_alignment_bopt_d x
-                                                                ]
-    sam_v1_6_alignment_aopt_d x         = case (sam_v1_6_alignment_aopt x) of
-                                            Nothing   -> ""
-                                            Just aopt -> ( unpack     $
-                                                           fromStrict $
-                                                           sam_v1_6_alignment_aopt_tag aopt
-                                                         )
-                                                         ++
-                                                         ":A:"
-                                                         ++
-                                                         ( unpack     $
-                                                           fromStrict $
-                                                           sam_v1_6_alignment_aopt_value aopt
-                                                         )
-    sam_v1_6_alignment_iopt_d x         = case (sam_v1_6_alignment_iopt x) of
-                                            Nothing   -> ""
-                                            Just iopt -> ( unpack     $
-                                                           fromStrict $
-                                                           sam_v1_6_alignment_iopt_tag iopt
-                                                         )
-                                                         ++
-                                                         ":i:"
-                                                         ++
-                                                         ( show $
-                                                           sam_v1_6_alignment_iopt_value iopt
-                                                         )
-    sam_v1_6_alignment_fopt_d x         = case (sam_v1_6_alignment_fopt x) of
-                                            Nothing   -> ""
-                                            Just fopt -> ( unpack     $
-                                                           fromStrict $
-                                                           sam_v1_6_alignment_fopt_tag fopt
-                                                         )
-                                                         ++
-                                                         ":f:"
-                                                         ++
-                                                         ( show $
-                                                           sam_v1_6_alignment_fopt_value fopt
-                                                         )
-    sam_v1_6_alignment_zopt_d x         = case (sam_v1_6_alignment_zopt x) of
-                                            Nothing   -> ""
-                                            Just zopt -> ( unpack     $
-                                                           fromStrict $
-                                                           sam_v1_6_alignment_zopt_tag zopt
-                                                         )
-                                                         ++
-                                                         ":Z:"
-                                                         ++
-                                                         ( unpack     $
-                                                           fromStrict $
-                                                           sam_v1_6_alignment_zopt_value zopt
-                                                         )
-    sam_v1_6_alignment_hopt_d x         = case (sam_v1_6_alignment_hopt x) of
-                                            Nothing   -> ""
-                                            Just hopt -> ( unpack     $
-                                                           fromStrict $
-                                                           sam_v1_6_alignment_hopt_tag hopt
-                                                         )
-                                                         ++
-                                                         ":H:"
-                                                         ++
-                                                         ( unpack     $
-                                                           fromStrict $
-                                                           sam_v1_6_alignment_hopt_value hopt
-                                                         )
-    sam_v1_6_alignment_bopt_d x         = case (sam_v1_6_alignment_bopt x) of
-                                            Nothing   -> ""
-                                            Just bopt -> concat $
-                                                           Prelude.filter (not . Prelude.null)
-                                                                               [ sam_v1_6_alignment_bopt_int8_d bopt
-                                                                               , sam_v1_6_alignment_bopt_word8_d bopt
-                                                                               , sam_v1_6_alignment_bopt_int16_d bopt
-                                                                               , sam_v1_6_alignment_bopt_word16_d bopt
-                                                                               , sam_v1_6_alignment_bopt_int32_d bopt
-                                                                               , sam_v1_6_alignment_bopt_word32_d bopt
-                                                                               , sam_v1_6_alignment_bopt_float_d bopt
-                                                                               ]
-    sam_v1_6_alignment_bopt_int8_d x = case (sam_v1_6_alignment_bopt_int8 x) of
-                                         Nothing        -> ""
-                                         Just bopt_int8 -> (unpack $ fromStrict $ pack $ toList $ sam_v1_6_alignment_bopt_int8_tag bopt_int8) ++
-                                                           ":"                                                                                ++
-                                                           "B"                                                                                ++
-                                                           ":"                                                                                ++
-                                                           (unpack $ fromStrict $ DB.singleton $ sam_v1_6_alignment_bopt_int8_type bopt_int8) ++
-                                                           ","                                                                                ++
-                                                           (concat $ map show $ toList $ sam_v1_6_alignment_bopt_int8_value bopt_int8)
-    sam_v1_6_alignment_bopt_word8_d x = case (sam_v1_6_alignment_bopt_word8 x) of 
-                                          Nothing         -> ""
-                                          Just bopt_word8 -> (unpack $ fromStrict $ pack $ toList $ sam_v1_6_alignment_bopt_word8_tag bopt_word8) ++
-                                                             ":"                                                                                  ++
-                                                             "B"                                                                                  ++
-                                                             ":"                                                                                  ++
-                                                             (unpack $ fromStrict $ DB.singleton $ sam_v1_6_alignment_bopt_word8_type bopt_word8) ++
-                                                             ","                                                                                  ++
-                                                             (unpack $ fromStrict $ pack $ toList $ sam_v1_6_alignment_bopt_word8_value bopt_word8)
-    sam_v1_6_alignment_bopt_int16_d x = case (sam_v1_6_alignment_bopt_int16 x) of 
-                                          Nothing         -> ""
-                                          Just bopt_int16 -> (unpack $ fromStrict $ pack $ toList $ sam_v1_6_alignment_bopt_int16_tag bopt_int16) ++
-                                                             ":"                                                                                  ++
-                                                             "B"                                                                                  ++
-                                                             ":"                                                                                  ++
-                                                             (unpack $ fromStrict $ DB.singleton $ sam_v1_6_alignment_bopt_int16_type bopt_int16) ++
-                                                             ","                                                                                  ++
-                                                             (concat $ map show $ toList $ sam_v1_6_alignment_bopt_int16_value bopt_int16)
-    sam_v1_6_alignment_bopt_word16_d x = case (sam_v1_6_alignment_bopt_word16 x) of
-                                           Nothing          -> ""
-                                           Just bopt_word16 -> (unpack $ fromStrict $ pack $ toList $ sam_v1_6_alignment_bopt_word16_tag bopt_word16) ++
-                                                               ":"                                                                                    ++
-                                                               "B"                                                                                    ++
-                                                               ":"                                                                                    ++
-                                                               (unpack $ fromStrict $ DB.singleton $ sam_v1_6_alignment_bopt_word16_type bopt_word16) ++
-                                                               ","                                                                                    ++
-                                                               (concat $ map encodeWord16 $ toList $ sam_v1_6_alignment_bopt_word16_value bopt_word16)
-    sam_v1_6_alignment_bopt_int32_d x = case (sam_v1_6_alignment_bopt_int32 x) of
-                                          Nothing         -> ""
-                                          Just bopt_int32 -> (unpack $ fromStrict $ pack $ toList $ sam_v1_6_alignment_bopt_int32_tag bopt_int32) ++
-                                                             ":"                                                                                  ++
-                                                             "B"                                                                                  ++
-                                                             ":"                                                                                  ++
-                                                             (unpack $ fromStrict $ DB.singleton $ sam_v1_6_alignment_bopt_int32_type bopt_int32) ++
-                                                             ","                                                                                  ++
-                                                             (concat $ map show $ toList $ sam_v1_6_alignment_bopt_int32_value bopt_int32)
-    sam_v1_6_alignment_bopt_word32_d x = case (sam_v1_6_alignment_bopt_word32 x) of 
-                                           Nothing          -> ""
-                                           Just bopt_word32 -> (unpack $ fromStrict $ pack $ toList $ sam_v1_6_alignment_bopt_word32_tag bopt_word32) ++
-                                                               ":"                                                                                    ++
-                                                               "B"                                                                                    ++
-                                                               ":"                                                                                    ++
-                                                               (unpack $ fromStrict $ DB.singleton $ sam_v1_6_alignment_bopt_word32_type bopt_word32) ++
-                                                               ","                                                                                    ++
-                                                               (concat $ map encodeWord32 $ toList $ sam_v1_6_alignment_bopt_word32_value bopt_word32)
-    sam_v1_6_alignment_bopt_float_d x = case (sam_v1_6_alignment_bopt_float x) of 
-                                          Nothing         -> ""
-                                          Just bopt_float -> (unpack $ fromStrict $ pack $ toList $ sam_v1_6_alignment_bopt_float_tag bopt_float) ++
-                                                             ":"                                                                                  ++
-                                                             "B"                                                                                  ++
-                                                             ":"                                                                                  ++
-                                                             (unpack $ fromStrict $ DB.singleton $ sam_v1_6_alignment_bopt_float_type bopt_float) ++
-                                                             ","                                                                                  ++
-                                                             (concat $ map show $ toList $ sam_v1_6_alignment_bopt_float_value bopt_float)
-    encodeWord16 :: Word16 -> [Char]
-    encodeWord16 = unpack . DBL.filter (\x -> x /= 0) . toLazyByteString . word16LE
-    encodeWord32 :: Word32 -> [Char]
-    encodeWord32 = unpack . DBL.filter (\x -> x /= 0) . toLazyByteString . word32LE
+-- Copyright   :  (c) Matthew Mosior 2024
+-- License     :  BSD-style
+-- Maintainer  :  mattm.github@gmail.com
+-- Portability :  portable
+--
+-- = Description
+--
+-- This library enables the decoding/encoding of SAM, BAM and CRAM file formats.
+
+module Data.SAM.Version1_6.Write.Base ( -- * Writing
+                                        writeSAM_V1_6
+                                      ) where
+
+import Data.SAM.Version1_6.Base
+import Data.SAM.Version1_6.Header.HD
+import Data.SAM.Version1_6.Header.SQ
+import Data.SAM.Version1_6.Header.RG
+import Data.SAM.Version1_6.Header.PG
+import Data.SAM.Version1_6.Header.CO
+import Data.SAM.Version1_6.Alignment.Base
+import Data.SAM.Version1_6.Alignment.OptionalFields.Base
+import Data.SAM.Version1_6.Alignment.OptionalFields.AOPT
+import Data.SAM.Version1_6.Alignment.OptionalFields.IOPT
+import Data.SAM.Version1_6.Alignment.OptionalFields.FOPT
+import Data.SAM.Version1_6.Alignment.OptionalFields.ZOPT
+import Data.SAM.Version1_6.Alignment.OptionalFields.HOPT
+import Data.SAM.Version1_6.Alignment.OptionalFields.BOPT
+
+import Control.Monad                       (forM)
+import Data.ByteString            as DB    (pack,singleton)
+import Data.ByteString.Lazy       as DBL   (filter)
+import Data.ByteString.Lazy.Char8 as DBLC8 (fromStrict,unpack)
+import Data.Foldable                       (toList)
+import Data.List                           (intercalate)
+import Data.Word
+import Data.ByteString.Builder             (toLazyByteString,word16LE,word32LE)
+import System.IO                           (hFlush,hClose,hPutStr,IOMode(..),openFile,Handle)
+
+
+-- | Deconstruct a @"SAM_V1_6"@ to a `String`.
+deconstructSAM_V1_6 :: SAM_V1_6
+                    -> String
+deconstructSAM_V1_6 samv16 =
+  ( intercalate "\n" $
+      Prelude.filter (not . Prelude.null)
+                     [ sam_v1_6_file_level_metadata_tos
+                     , sam_v1_6_reference_sequence_dictionary_tos
+                     , sam_v1_6_read_group_tos
+                     , sam_v1_6_program_tos
+                     , sam_v1_6_one_line_comment_tos
+                     , sam_v1_6_alignment_tos
+                     ]
+  )
+  ++ "\n"
+  where
+    sam_v1_6_file_level_metadata_format_version_tos x = "VN:" ++
+                                                        ( unpack     $
+                                                          fromStrict $
+                                                          sam_v1_6_file_level_metadata_format_version_value $
+                                                          sam_v1_6_file_level_metadata_format_version x
+                                                        )
+    sam_v1_6_file_level_metadata_sorting_order_tos x = case (sam_v1_6_file_level_metadata_sorting_order x) of
+                                                         Nothing  ->
+                                                           ""
+                                                         Just rgf ->
+                                                           "SO:" ++
+                                                           ( unpack     $
+                                                             fromStrict $
+                                                             sam_v1_6_file_level_metadata_sorting_order_value rgf
+                                                           )
+    sam_v1_6_file_level_metadata_alignment_grouping_tos x = case (sam_v1_6_file_level_metadata_alignment_grouping x) of
+                                                              Nothing  ->
+                                                                ""
+                                                              Just rgf ->
+                                                                "GO:" ++
+                                                                ( unpack     $
+                                                                  fromStrict $
+                                                                  sam_v1_6_file_level_metadata_alignment_grouping_value rgf
+                                                                )
+    sam_v1_6_file_level_metadata_subsorting_order_tos x = case (sam_v1_6_file_level_metadata_subsorting_order x) of
+                                                            Nothing  ->
+                                                              ""
+                                                            Just rgf ->
+                                                              "SS:" ++
+                                                              ( unpack     $
+                                                                fromStrict $
+                                                                sam_v1_6_file_level_metadata_subsorting_order_value rgf
+                                                              )
+    sam_v1_6_file_level_metadata_tos = case (sam_v1_6_file_level_metadata samv16) of
+                                         Nothing  ->
+                                           ""
+                                         Just hdf ->
+                                           intercalate "\t" $
+                                             Prelude.filter (not . Prelude.null)
+                                                            [ "@HD"
+                                                            , sam_v1_6_file_level_metadata_format_version_tos hdf
+                                                            , sam_v1_6_file_level_metadata_sorting_order_tos hdf
+                                                            , sam_v1_6_file_level_metadata_alignment_grouping_tos hdf
+                                                            , sam_v1_6_file_level_metadata_subsorting_order_tos hdf 
+                                                            ]
+    sam_v1_6_reference_sequence_dictionary_reference_sequence_name_tos x = "SN:" ++
+                                                                           ( unpack                                                               $
+                                                                             fromStrict                                                           $
+                                                                             sam_v1_6_reference_sequence_dictionary_reference_sequence_name_value $
+                                                                             sam_v1_6_reference_sequence_dictionary_reference_sequence_name x
+                                                                           )
+    sam_v1_6_reference_sequence_dictionary_reference_sequence_length_tos x = "LN:" ++
+                                                                             ( unpack                                                                 $
+                                                                               fromStrict                                                             $
+                                                                               sam_v1_6_reference_sequence_dictionary_reference_sequence_length_value $
+                                                                               sam_v1_6_reference_sequence_dictionary_reference_sequence_length x
+                                                                             )
+    sam_v1_6_reference_sequence_dictionary_alternative_locus_tos x = case (sam_v1_6_reference_sequence_dictionary_alternative_locus x) of
+                                                                       Nothing  ->
+                                                                         ""
+                                                                       Just sqf ->
+                                                                         "AH:" ++
+                                                                         ( unpack     $
+                                                                           fromStrict $
+                                                                           sam_v1_6_reference_sequence_dictionary_alternative_locus_value sqf
+                                                                         )
+    sam_v1_6_reference_sequence_dictionary_alternative_reference_sequence_names_tos x = case (sam_v1_6_reference_sequence_dictionary_alternative_reference_sequence_names x) of
+                                                                                          Nothing  ->
+                                                                                            "" 
+                                                                                          Just sqf ->
+                                                                                            "AN:" ++
+                                                                                            ( unpack     $
+                                                                                              fromStrict $
+                                                                                              sam_v1_6_reference_sequence_dictionary_alternative_reference_sequence_names_value sqf
+                                                                                            )
+    sam_v1_6_reference_sequence_dictionary_genome_assembly_identifier_tos x = case (sam_v1_6_reference_sequence_dictionary_genome_assembly_identifier x) of
+                                                                                Nothing  ->
+                                                                                  ""
+                                                                                Just sqf ->
+                                                                                  "AS:" ++
+                                                                                  ( unpack     $
+                                                                                    fromStrict $
+                                                                                    sam_v1_6_reference_sequence_dictionary_genome_assembly_identifier_value sqf
+                                                                                  )
+    sam_v1_6_reference_sequence_dictionary_description_tos x = case (sam_v1_6_reference_sequence_dictionary_description x) of
+                                                                 Nothing  ->
+                                                                   ""
+                                                                 Just sqf ->
+                                                                   "DS:" ++
+                                                                   ( unpack     $
+                                                                     fromStrict $
+                                                                     sam_v1_6_reference_sequence_dictionary_description_value sqf
+                                                                   )
+    sam_v1_6_reference_sequence_dictionary_md5_checksum_tos x = case (sam_v1_6_reference_sequence_dictionary_md5_checksum x) of
+                                                                  Nothing  ->
+                                                                    ""
+                                                                  Just sqf ->
+                                                                    "M5:" ++
+                                                                    ( unpack     $
+                                                                      fromStrict $
+                                                                      sam_v1_6_reference_sequence_dictionary_md5_checksum_value sqf
+                                                                    )
+    sam_v1_6_reference_sequence_dictionary_species_tos x = case (sam_v1_6_reference_sequence_dictionary_species x) of
+                                                             Nothing  ->
+                                                               ""
+                                                             Just sqf ->
+                                                               "SP:" ++
+                                                               ( unpack     $
+                                                                 fromStrict $
+                                                                 sam_v1_6_reference_sequence_dictionary_species_value sqf
+                                                               )
+    sam_v1_6_reference_sequence_dictionary_molecule_topology_tos x = case (sam_v1_6_reference_sequence_dictionary_molecule_topology x) of
+                                                                       Nothing  ->
+                                                                         ""
+                                                                       Just sqf ->
+                                                                         "TP:" ++
+                                                                         ( unpack     $
+                                                                           fromStrict $
+                                                                           sam_v1_6_reference_sequence_dictionary_molecule_topology_value sqf
+                                                                         )
+    sam_v1_6_reference_sequence_dictionary_uri_tos x = case (sam_v1_6_reference_sequence_dictionary_uri x) of
+                                                         Nothing  ->
+                                                           ""
+                                                         Just sqf ->
+                                                           "UR:" ++
+                                                           ( unpack     $
+                                                             fromStrict $
+                                                             sam_v1_6_reference_sequence_dictionary_uri_value sqf
+                                                           )
+    sam_v1_6_reference_sequence_dictionary_tos = case (sam_v1_6_reference_sequence_dictionary samv16) of
+                                                   Nothing  ->
+                                                     ""
+                                                   Just sqf ->
+                                                     intercalate "\n" $
+                                                       map (\x -> intercalate "\t" $
+                                                                    Prelude.filter (not . Prelude.null)
+                                                                                   [ "@SQ"
+                                                                                   , sam_v1_6_reference_sequence_dictionary_reference_sequence_name_tos x
+                                                                                   , sam_v1_6_reference_sequence_dictionary_reference_sequence_length_tos x
+                                                                                   , sam_v1_6_reference_sequence_dictionary_alternative_locus_tos x
+                                                                                   , sam_v1_6_reference_sequence_dictionary_alternative_reference_sequence_names_tos x
+                                                                                   , sam_v1_6_reference_sequence_dictionary_genome_assembly_identifier_tos x
+                                                                                   , sam_v1_6_reference_sequence_dictionary_description_tos x
+                                                                                   , sam_v1_6_reference_sequence_dictionary_md5_checksum_tos x
+                                                                                   , sam_v1_6_reference_sequence_dictionary_species_tos x
+                                                                                   , sam_v1_6_reference_sequence_dictionary_molecule_topology_tos x
+                                                                                   , sam_v1_6_reference_sequence_dictionary_uri_tos x
+                                                                                   ]
+                                                           ) (toList sqf)
+    sam_v1_6_read_group_identifer_tos x = "ID:" ++
+                                          ( unpack                               $
+                                            fromStrict                           $
+                                            sam_v1_6_read_group_identifier_value $
+                                            sam_v1_6_read_group_identifier x
+                                          )
+    sam_v1_6_read_group_barcode_sequence_tos x = case (sam_v1_6_read_group_barcode_sequence x) of
+                                                   Nothing  ->
+                                                     ""
+                                                   Just rgf ->
+                                                     "BC:" ++
+                                                     ( unpack     $
+                                                       fromStrict $
+                                                       sam_v1_6_read_group_barcode_sequence_value rgf
+                                                     )
+    sam_v1_6_read_group_sequencing_center_tos x = case (sam_v1_6_read_group_sequencing_center x) of
+                                                    Nothing  ->
+                                                      ""
+                                                    Just rgf ->
+                                                      "CN:" ++
+                                                      ( unpack     $
+                                                        fromStrict $
+                                                        sam_v1_6_read_group_sequencing_center_value rgf
+                                                      )
+    sam_v1_6_read_group_description_tos x = case (sam_v1_6_read_group_description x) of
+                                              Nothing  ->
+                                                ""
+                                              Just rgf ->
+                                                "DS:" ++
+                                                ( unpack     $
+                                                  fromStrict $
+                                                  sam_v1_6_read_group_description_value rgf
+                                                )
+    sam_v1_6_read_group_run_date_tos x = case (sam_v1_6_read_group_run_date x) of
+                                           Nothing  ->
+                                             ""
+                                           Just rgf ->
+                                             "DT:" ++
+                                             ( unpack     $
+                                               fromStrict $
+                                               sam_v1_6_read_group_run_date_value rgf
+                                             )
+    sam_v1_6_read_group_flow_order_tos x = case (sam_v1_6_read_group_flow_order x) of
+                                             Nothing  ->
+                                               ""
+                                             Just rgf ->
+                                               "FO:" ++
+                                               ( unpack     $
+                                                 fromStrict $
+                                                 sam_v1_6_read_group_flow_order_value rgf
+                                               )
+    sam_v1_6_read_group_key_sequence_tos x = case (sam_v1_6_read_group_key_sequence x) of
+                                               Nothing  ->
+                                                 ""
+                                               Just rgf ->
+                                                 "KS:" ++
+                                                 ( unpack     $
+                                                   fromStrict $
+                                                   sam_v1_6_read_group_key_sequence_value rgf
+                                                 )
+    sam_v1_6_read_group_library_tos x = case (sam_v1_6_read_group_library x) of
+                                          Nothing  ->
+                                            ""
+                                          Just rgf ->
+                                            "LB:" ++
+                                            ( unpack     $
+                                              fromStrict $
+                                              sam_v1_6_read_group_library_value rgf
+                                            )
+    sam_v1_6_read_group_programs_tos x = case (sam_v1_6_read_group_programs x) of
+                                           Nothing  ->
+                                             ""
+                                           Just rgf ->
+                                             "PG:" ++
+                                             ( unpack     $
+                                               fromStrict $
+                                               sam_v1_6_read_group_programs_value rgf
+                                             )
+    sam_v1_6_read_group_predicted_median_insert_size_tos x = case (sam_v1_6_read_group_predicted_median_insert_size x) of
+                                                               Nothing  ->
+                                                                 ""
+                                                               Just rgf ->
+                                                                 "PI:" ++
+                                                                 ( unpack     $
+                                                                   fromStrict $
+                                                                   sam_v1_6_read_group_predicted_median_insert_size_value rgf
+                                                                 )
+    sam_v1_6_read_group_platform_tos x = case (sam_v1_6_read_group_platform x) of
+                                           Nothing  ->
+                                             ""
+                                           Just rgf ->
+                                             "PL:" ++
+                                             ( unpack     $
+                                               fromStrict $
+                                               sam_v1_6_read_group_platform_value rgf
+                                             )
+    sam_v1_6_read_group_platform_model_tos x = case (sam_v1_6_read_group_platform_model x) of
+                                                 Nothing  ->
+                                                   ""
+                                                 Just rgf ->
+                                                   "PM:" ++
+                                                   ( unpack     $
+                                                     fromStrict $
+                                                     sam_v1_6_read_group_platform_model_value rgf
+                                                   )
+    sam_v1_6_read_group_platform_unit_tos x = case (sam_v1_6_read_group_platform_unit x) of
+                                                Nothing  ->
+                                                  ""
+                                                Just rgf ->
+                                                  "PU:" ++
+                                                  ( unpack     $
+                                                    fromStrict $
+                                                    sam_v1_6_read_group_platform_unit_value rgf
+                                                  )
+    sam_v1_6_read_group_sample_tos x = case (sam_v1_6_read_group_sample x) of
+                                         Nothing  ->
+                                           ""
+                                         Just rgf ->
+                                           "SM:" ++
+                                           ( unpack     $
+                                             fromStrict $
+                                             sam_v1_6_read_group_sample_value rgf
+                                           )
+    sam_v1_6_read_group_tos = case (sam_v1_6_read_group samv16) of
+                                Nothing  ->
+                                  ""
+                                Just rgf ->
+                                  intercalate "\n" $
+                                    map (\x -> intercalate "\t" $
+                                                 Prelude.filter (not . Prelude.null)
+                                                                [ "@RG"
+                                                                , sam_v1_6_read_group_identifer_tos x
+                                                                , sam_v1_6_read_group_barcode_sequence_tos x
+                                                                , sam_v1_6_read_group_sequencing_center_tos x
+                                                                , sam_v1_6_read_group_description_tos x
+                                                                , sam_v1_6_read_group_run_date_tos x
+                                                                , sam_v1_6_read_group_flow_order_tos x
+                                                                , sam_v1_6_read_group_key_sequence_tos x
+                                                                , sam_v1_6_read_group_library_tos x
+                                                                , sam_v1_6_read_group_programs_tos x
+                                                                , sam_v1_6_read_group_predicted_median_insert_size_tos x
+                                                                , sam_v1_6_read_group_platform_tos x
+                                                                , sam_v1_6_read_group_platform_model_tos x
+                                                                , sam_v1_6_read_group_platform_unit_tos x
+                                                                , sam_v1_6_read_group_sample_tos x
+                                                                ]
+                                        ) (toList rgf)
+    sam_v1_6_program_record_identifier_tos x = "ID:" ++
+                                               ( unpack                                   $
+                                                 fromStrict                               $
+                                                 sam_v1_6_program_record_identifier_value $
+                                                 sam_v1_6_program_record_identifier x
+                                               )
+    sam_v1_6_program_name_tos x = case (sam_v1_6_program_name x) of
+                                    Nothing  ->
+                                      ""
+                                    Just rgf ->
+                                      "PN:" ++
+                                      ( unpack     $
+                                        fromStrict $
+                                        sam_v1_6_program_name_value rgf
+                                      )
+    sam_v1_6_program_command_line_tos x = case (sam_v1_6_program_command_line x) of
+                                            Nothing  ->
+                                              ""
+                                            Just rgf ->
+                                              "CL:" ++
+                                              ( unpack     $
+                                                fromStrict $
+                                                sam_v1_6_program_command_line_value rgf
+                                              )
+    sam_v1_6_program_previous_pg_id_tos x = case (sam_v1_6_program_previous_pg_id x) of
+                                              Nothing  ->
+                                                ""
+                                              Just rgf ->
+                                                "PP:" ++
+                                                ( unpack     $
+                                                  fromStrict $
+                                                  sam_v1_6_program_previous_pg_id_value rgf
+                                                )
+    sam_v1_6_program_description_tos x = case (sam_v1_6_program_description x) of
+                                           Nothing  ->
+                                             ""
+                                           Just rgf ->
+                                             "DS:" ++
+                                             ( unpack     $
+                                               fromStrict $
+                                               sam_v1_6_program_description_value rgf
+                                             )
+    sam_v1_6_program_version_tos x = case (sam_v1_6_program_version x) of
+                                       Nothing  ->
+                                         ""
+                                       Just rgf ->
+                                         "VN:" ++
+                                         ( unpack     $
+                                           fromStrict $
+                                           sam_v1_6_program_version_value rgf
+                                         )
+    sam_v1_6_program_tos = case (sam_v1_6_program samv16) of
+                             Nothing  ->
+                               ""
+                             Just pgf ->
+                               intercalate "\t" $
+                                 Prelude.filter (not . Prelude.null)
+                                                [ "@PG"
+                                                , sam_v1_6_program_record_identifier_tos pgf
+                                                , sam_v1_6_program_name_tos pgf
+                                                , sam_v1_6_program_command_line_tos pgf
+                                                , sam_v1_6_program_previous_pg_id_tos pgf
+                                                , sam_v1_6_program_description_tos pgf
+                                                , sam_v1_6_program_version_tos pgf
+                                                ]
+    sam_v1_6_one_line_comment_tos = case (sam_v1_6_one_line_comment samv16) of
+                                      Nothing  ->
+                                        ""
+                                      Just cof ->
+                                        intercalate "\n" $
+                                          map (\x -> intercalate "\t" $
+                                                       Prelude.filter (not . Prelude.null) 
+                                                                      [ "@CO"
+                                                                      , unpack       $
+                                                                          fromStrict $
+                                                                            sam_v1_6_one_line_comment_value x
+                                                                      ]
+                                              ) (toList cof)
+    sam_v1_6_alignment_tos            = intercalate "\n" $
+                                          map (\x -> case (Prelude.null $ sam_v1_6_alignment_opts x) of
+                                                       True  ->
+                                                         sam_v1_6_alignment_mand x 
+                                                       False ->
+                                                         intercalate "\t"
+                                                                     [ sam_v1_6_alignment_mand x
+                                                                     , sam_v1_6_alignment_opts x
+                                                                     ]
+                                              ) ( toList $
+                                                    sam_v1_6_alignment samv16
+                                                )
+    sam_v1_6_alignment_mand x           = intercalate "\t" $
+                                            Prelude.filter (not . Prelude.null)
+                                                           [ unpack $ fromStrict $ sam_v1_6_alignment_qname x 
+                                                           , show $ sam_v1_6_alignment_flag x 
+                                                           , unpack $ fromStrict $ sam_v1_6_alignment_rname x 
+                                                           , show $ sam_v1_6_alignment_pos x 
+                                                           , show $ sam_v1_6_alignment_mapq x 
+                                                           , unpack $ fromStrict $ sam_v1_6_alignment_cigar x 
+                                                           , unpack $ fromStrict $ sam_v1_6_alignment_rnext x 
+                                                           , show $ sam_v1_6_alignment_pnext x 
+                                                           , show $ sam_v1_6_alignment_tlen x 
+                                                           , unpack $ fromStrict $ sam_v1_6_alignment_seq x 
+                                                           , unpack $ fromStrict $ sam_v1_6_alignment_qual x
+                                                           ]
+    --sam_v1_6_alignment_opts x           = intercalate "\t" $
+    --                                        Prelude.filter (not . Prelude.null)
+    --                                                       [ sam_v1_6_alignment_aopt_d x 
+    --                                                       , sam_v1_6_alignment_iopt_d x 
+    --                                                       , sam_v1_6_alignment_fopt_d x 
+    --                                                       , sam_v1_6_alignment_zopt_d x
+    --                                                       , sam_v1_6_alignment_hopt_d x 
+    --                                                       , sam_v1_6_alignment_bopt_d x
+    --                                                       ]
+    sam_v1_6_alignment_opts x         = case (sam_v1_6_alignment_optionalfields x) of
+                                            Nothing             ->
+                                              ""
+                                            Just optionalfields ->
+                                              concat $ forM (toList optionalfields) $ \currentoptionalfield -> 
+                                                intercalate "\t" $
+                                                  Prelude.filter (not . Prelude.null)
+                                                                 [ case (sam_v1_6_alignment_optionalfields_aopt currentoptionalfield) of
+                                                                     Nothing   ->
+                                                                       ""
+                                                                     Just aopt ->
+                                                                       ( unpack       $
+                                                                           fromStrict $
+                                                                             sam_v1_6_alignment_optionalfields_aopt_tag aopt
+                                                                       )
+                                                                       ++
+                                                                       ":A:"
+                                                                       ++
+                                                                       ( unpack       $
+                                                                           fromStrict $
+                                                                             sam_v1_6_alignment_optionalfields_aopt_value aopt
+                                                                       )
+                                                                 , case (sam_v1_6_alignment_optionalfields_iopt currentoptionalfield) of
+                                                                     Nothing   ->
+                                                                       ""
+                                                                     Just iopt ->
+                                                                       ( unpack       $
+                                                                           fromStrict $
+                                                                             sam_v1_6_alignment_optionalfields_iopt_tag iopt
+                                                                       )
+                                                                       ++
+                                                                       ":i:"
+                                                                       ++
+                                                                       ( show $
+                                                                           sam_v1_6_alignment_optionalfields_iopt_value iopt
+                                                                       )
+                                                                 , case (sam_v1_6_alignment_optionalfields_fopt currentoptionalfield) of
+                                                                     Nothing   ->
+                                                                       ""
+                                                                     Just fopt ->
+                                                                       ( unpack       $
+                                                                           fromStrict $
+                                                                             sam_v1_6_alignment_optionalfields_fopt_tag fopt
+                                                                       )
+                                                                       ++
+                                                                       ":f:"
+                                                                       ++
+                                                                       ( show $
+                                                                           sam_v1_6_alignment_optionalfields_fopt_value fopt
+                                                                       )
+                                                                 , case (sam_v1_6_alignment_optionalfields_zopt currentoptionalfield) of
+                                                                     Nothing   ->
+                                                                       ""
+                                                                     Just zopt ->
+                                                                       ( unpack       $
+                                                                           fromStrict $
+                                                                             sam_v1_6_alignment_optionalfields_zopt_tag zopt
+                                                                       )
+                                                                       ++
+                                                                       ":Z:"
+                                                                       ++
+                                                                       ( unpack       $
+                                                                           fromStrict $
+                                                                             sam_v1_6_alignment_optionalfields_zopt_value zopt
+                                                                       )
+                                                                 , case (sam_v1_6_alignment_optionalfields_hopt currentoptionalfield) of
+                                                                     Nothing   ->
+                                                                       ""
+                                                                     Just hopt ->
+                                                                       ( unpack       $
+                                                                           fromStrict $
+                                                                             sam_v1_6_alignment_optionalfields_hopt_tag hopt
+                                                                       )
+                                                                       ++
+                                                                       ":H:"
+                                                                       ++
+                                                                       ( unpack       $
+                                                                           fromStrict $
+                                                                             sam_v1_6_alignment_optionalfields_hopt_value hopt
+                                                                       )
+                                                                 , case (sam_v1_6_alignment_optionalfields_bopt currentoptionalfield) of
+                                                                     Nothing   ->
+                                                                       ""
+                                                                     Just bopt ->
+                                                                       concat $
+                                                                         Prelude.filter (not . Prelude.null)
+                                                                                        [ case (sam_v1_6_alignment_optionalfields_bopt_int8 bopt) of
+                                                                                            Nothing        ->
+                                                                                              ""
+                                                                                            Just bopt_int8 ->
+                                                                                              ( unpack       $
+                                                                                                  fromStrict $
+                                                                                                    pack     $
+                                                                                                      toList $
+                                                                                                        sam_v1_6_alignment_optionalfields_bopt_int8_tag bopt_int8
+                                                                                              )   ++
+                                                                                              ":" ++
+                                                                                              "B" ++
+                                                                                              ":" ++
+                                                                                              ( unpack           $
+                                                                                                  fromStrict     $
+                                                                                                    DB.singleton $
+                                                                                                      sam_v1_6_alignment_optionalfields_bopt_int8_type bopt_int8
+                                                                                              )   ++
+                                                                                              "," ++
+                                                                                              ( concat     $
+                                                                                                  map show $
+                                                                                                    toList $
+                                                                                                      sam_v1_6_alignment_optionalfields_bopt_int8_value bopt_int8
+                                                                                              )
+                                                                                        , case (sam_v1_6_alignment_optionalfields_bopt_word8 bopt) of 
+                                                                                            Nothing         ->
+                                                                                              ""
+                                                                                            Just bopt_word8 ->
+                                                                                              ( unpack       $
+                                                                                                  fromStrict $
+                                                                                                    pack     $
+                                                                                                      toList $
+                                                                                                        sam_v1_6_alignment_optionalfields_bopt_word8_tag bopt_word8
+                                                                                              )   ++
+                                                                                              ":" ++
+                                                                                              "B" ++
+                                                                                              ":" ++
+                                                                                              ( unpack           $
+                                                                                                  fromStrict     $
+                                                                                                    DB.singleton $
+                                                                                                      sam_v1_6_alignment_optionalfields_bopt_word8_type bopt_word8
+                                                                                              )   ++
+                                                                                              "," ++
+                                                                                              ( unpack       $
+                                                                                                  fromStrict $
+                                                                                                    pack     $
+                                                                                                      toList $
+                                                                                                        sam_v1_6_alignment_optionalfields_bopt_word8_value bopt_word8
+                                                                                              )
+                                                                                        , case (sam_v1_6_alignment_optionalfields_bopt_int16 bopt) of 
+                                                                                            Nothing         ->
+                                                                                              ""
+                                                                                            Just bopt_int16 ->
+                                                                                              ( unpack       $
+                                                                                                  fromStrict $
+                                                                                                    pack     $
+                                                                                                      toList $
+                                                                                                        sam_v1_6_alignment_optionalfields_bopt_int16_tag bopt_int16
+                                                                                              )   ++
+                                                                                              ":" ++
+                                                                                              "B" ++
+                                                                                              ":" ++
+                                                                                              ( unpack           $
+                                                                                                  fromStrict     $
+                                                                                                    DB.singleton $
+                                                                                                      sam_v1_6_alignment_optionalfields_bopt_int16_type bopt_int16
+                                                                                              )   ++
+                                                                                              "," ++
+                                                                                              ( concat     $
+                                                                                                  map show $
+                                                                                                    toList $
+                                                                                                      sam_v1_6_alignment_optionalfields_bopt_int16_value bopt_int16
+                                                                                              )
+                                                                                        , case (sam_v1_6_alignment_optionalfields_bopt_word16 bopt) of
+                                                                                            Nothing          ->
+                                                                                              ""
+                                                                                            Just bopt_word16 ->
+                                                                                              ( unpack       $
+                                                                                                  fromStrict $
+                                                                                                    pack     $
+                                                                                                      toList $
+                                                                                                        sam_v1_6_alignment_optionalfields_bopt_word16_tag bopt_word16
+                                                                                              )   ++
+                                                                                              ":" ++
+                                                                                              "B" ++
+                                                                                              ":" ++
+                                                                                              ( unpack           $
+                                                                                                  fromStrict     $
+                                                                                                    DB.singleton $
+                                                                                                      sam_v1_6_alignment_optionalfields_bopt_word16_type bopt_word16
+                                                                                              )   ++
+                                                                                              "," ++
+                                                                                              ( concat             $
+                                                                                                  map encodeWord16 $
+                                                                                                    toList         $
+                                                                                                      sam_v1_6_alignment_optionalfields_bopt_word16_value bopt_word16
+                                                                                              )
+                                                                                        , case (sam_v1_6_alignment_optionalfields_bopt_int32 bopt) of
+                                                                                            Nothing         ->
+                                                                                              ""
+                                                                                            Just bopt_int32 ->
+                                                                                              ( unpack       $
+                                                                                                  fromStrict $
+                                                                                                    pack     $
+                                                                                                      toList $
+                                                                                                        sam_v1_6_alignment_optionalfields_bopt_int32_tag bopt_int32
+                                                                                              )   ++
+                                                                                              ":" ++
+                                                                                              "B" ++
+                                                                                              ":" ++
+                                                                                              ( unpack           $
+                                                                                                  fromStrict     $
+                                                                                                    DB.singleton $
+                                                                                                      sam_v1_6_alignment_optionalfields_bopt_int32_type bopt_int32
+                                                                                              )   ++
+                                                                                              "," ++
+                                                                                              ( concat     $
+                                                                                                  map show $
+                                                                                                    toList $
+                                                                                                      sam_v1_6_alignment_optionalfields_bopt_int32_value bopt_int32
+                                                                                              )
+                                                                                        , case (sam_v1_6_alignment_optionalfields_bopt_word32 bopt) of 
+                                                                                            Nothing          ->
+                                                                                              ""
+                                                                                            Just bopt_word32 ->
+                                                                                              ( unpack       $
+                                                                                                  fromStrict $
+                                                                                                    pack     $
+                                                                                                      toList $
+                                                                                                        sam_v1_6_alignment_optionalfields_bopt_word32_tag bopt_word32
+                                                                                              )   ++
+                                                                                              ":" ++
+                                                                                              "B" ++
+                                                                                              ":" ++
+                                                                                              ( unpack           $
+                                                                                                  fromStrict     $
+                                                                                                    DB.singleton $
+                                                                                                      sam_v1_6_alignment_optionalfields_bopt_word32_type bopt_word32
+                                                                                              )   ++
+                                                                                              "," ++
+                                                                                              ( concat             $
+                                                                                                  map encodeWord32 $
+                                                                                                    toList         $
+                                                                                                      sam_v1_6_alignment_optionalfields_bopt_word32_value bopt_word32
+                                                                                              )
+                                                                                        , case (sam_v1_6_alignment_optionalfields_bopt_float bopt) of 
+                                                                                            Nothing         ->
+                                                                                              ""
+                                                                                            Just bopt_float ->
+                                                                                              ( unpack       $
+                                                                                                  fromStrict $
+                                                                                                    pack     $
+                                                                                                      toList $
+                                                                                                        sam_v1_6_alignment_optionalfields_bopt_float_tag bopt_float
+                                                                                              )   ++
+                                                                                              ":" ++
+                                                                                              "B" ++
+                                                                                              ":" ++
+                                                                                              ( unpack           $
+                                                                                                  fromStrict     $
+                                                                                                    DB.singleton $
+                                                                                                      sam_v1_6_alignment_optionalfields_bopt_float_type bopt_float
+                                                                                              )   ++
+                                                                                              "," ++
+                                                                                              ( concat     $
+                                                                                                  map show $
+                                                                                                    toList $
+                                                                                                      sam_v1_6_alignment_optionalfields_bopt_float_value bopt_float
+                                                                                              )
+                                                                                        ]
+                                                                 ]
+
+{-
+    sam_v1_6_alignment_aopt_d x =             ( unpack       $
+                                                  fromStrict $
+                                                    sam_v1_6_alignment_aopt_tag aopt
+                                              )
+                                              ++
+                                              ":A:"
+                                              ++
+                                              ( unpack       $
+                                                  fromStrict $
+                                                    sam_v1_6_alignment_aopt_value aopt
+                                              )
+    sam_v1_6_alignment_iopt_d x         = case (sam_v1_6_alignment_iopt x) of
+                                            Nothing   ->
+                                              ""
+                                            Just iopt ->
+                                              ( unpack       $
+                                                  fromStrict $
+                                                    sam_v1_6_alignment_iopt_tag iopt
+                                              )
+                                              ++
+                                              ":i:"
+                                              ++
+                                              ( show $
+                                                  sam_v1_6_alignment_iopt_value iopt
+                                              )
+    sam_v1_6_alignment_fopt_d x         = case (sam_v1_6_alignment_fopt x) of
+                                            Nothing   ->
+                                              ""
+                                            Just fopt ->
+                                              ( unpack       $
+                                                  fromStrict $
+                                                    sam_v1_6_alignment_fopt_tag fopt
+                                              )
+                                              ++
+                                              ":f:"
+                                              ++
+                                              ( show $
+                                                  sam_v1_6_alignment_fopt_value fopt
+                                              )
+    sam_v1_6_alignment_zopt_d x         = case (sam_v1_6_alignment_zopt x) of
+                                            Nothing   ->
+                                              ""
+                                            Just zopt ->
+                                              ( unpack       $
+                                                  fromStrict $
+                                                    sam_v1_6_alignment_zopt_tag zopt
+                                              )
+                                              ++
+                                              ":Z:"
+                                              ++
+                                              ( unpack       $
+                                                  fromStrict $
+                                                    sam_v1_6_alignment_zopt_value zopt
+                                              )
+    sam_v1_6_alignment_hopt_d x         = case (sam_v1_6_alignment_hopt x) of
+                                            Nothing   ->
+                                              ""
+                                            Just hopt ->
+                                              ( unpack       $
+                                                  fromStrict $
+                                                    sam_v1_6_alignment_hopt_tag hopt
+                                              )
+                                              ++
+                                              ":H:"
+                                              ++
+                                              ( unpack       $
+                                                  fromStrict $
+                                                    sam_v1_6_alignment_hopt_value hopt
+                                              )
+    sam_v1_6_alignment_bopt_d x         = case (sam_v1_6_alignment_bopt x) of
+                                            Nothing   ->
+                                              ""
+                                            Just bopt ->
+                                              concat $
+                                                Prelude.filter (not . Prelude.null)
+                                                               [ sam_v1_6_alignment_bopt_int8_d bopt
+                                                               , sam_v1_6_alignment_bopt_word8_d bopt
+                                                               , sam_v1_6_alignment_bopt_int16_d bopt
+                                                               , sam_v1_6_alignment_bopt_word16_d bopt
+                                                               , sam_v1_6_alignment_bopt_int32_d bopt
+                                                               , sam_v1_6_alignment_bopt_word32_d bopt
+                                                               , sam_v1_6_alignment_bopt_float_d bopt
+                                                               ]
+    sam_v1_6_alignment_bopt_int8_d x = case (sam_v1_6_alignment_bopt_int8 x) of
+                                         Nothing        ->
+                                           ""
+                                         Just bopt_int8 ->
+                                           ( unpack       $
+                                               fromStrict $
+                                                 pack     $
+                                                   toList $
+                                                     sam_v1_6_alignment_bopt_int8_tag bopt_int8
+                                           )   ++
+                                           ":" ++
+                                           "B" ++
+                                           ":" ++
+                                           ( unpack           $
+                                               fromStrict     $
+                                                 DB.singleton $
+                                                   sam_v1_6_alignment_bopt_int8_type bopt_int8
+                                           )   ++
+                                           "," ++
+                                           ( concat     $
+                                               map show $
+                                                 toList $
+                                                   sam_v1_6_alignment_bopt_int8_value bopt_int8
+                                           )
+    sam_v1_6_alignment_bopt_word8_d x = case (sam_v1_6_alignment_bopt_word8 x) of 
+                                          Nothing         ->
+                                            ""
+                                          Just bopt_word8 ->
+                                            ( unpack       $
+                                                fromStrict $
+                                                  pack     $
+                                                    toList $
+                                                      sam_v1_6_alignment_bopt_word8_tag bopt_word8
+                                            )   ++
+                                            ":" ++
+                                            "B" ++
+                                            ":" ++
+                                            ( unpack           $
+                                                fromStrict     $
+                                                  DB.singleton $
+                                                    sam_v1_6_alignment_bopt_word8_type bopt_word8
+                                            )   ++
+                                            "," ++
+                                            ( unpack       $
+                                                fromStrict $
+                                                  pack     $
+                                                    toList $
+                                                      sam_v1_6_alignment_bopt_word8_value bopt_word8
+                                            )
+    sam_v1_6_alignment_bopt_int16_d x = case (sam_v1_6_alignment_bopt_int16 x) of 
+                                          Nothing         ->
+                                            ""
+                                          Just bopt_int16 ->
+                                            ( unpack       $
+                                                fromStrict $
+                                                  pack     $
+                                                    toList $
+                                                      sam_v1_6_alignment_bopt_int16_tag bopt_int16
+                                            )   ++
+                                            ":" ++
+                                            "B" ++
+                                            ":" ++
+                                            ( unpack           $
+                                                fromStrict     $
+                                                  DB.singleton $
+                                                    sam_v1_6_alignment_bopt_int16_type bopt_int16
+                                            )   ++
+                                            "," ++
+                                            ( concat     $
+                                                map show $
+                                                  toList $
+                                                    sam_v1_6_alignment_bopt_int16_value bopt_int16
+                                            )
+    sam_v1_6_alignment_bopt_word16_d x = case (sam_v1_6_alignment_bopt_word16 x) of
+                                           Nothing          ->
+                                             ""
+                                           Just bopt_word16 ->
+                                             ( unpack       $
+                                                 fromStrict $
+                                                   pack     $
+                                                     toList $
+                                                       sam_v1_6_alignment_bopt_word16_tag bopt_word16
+                                             )   ++
+                                             ":" ++
+                                             "B" ++
+                                             ":" ++
+                                             ( unpack           $
+                                                 fromStrict     $
+                                                   DB.singleton $
+                                                     sam_v1_6_alignment_bopt_word16_type bopt_word16
+                                             )   ++
+                                             "," ++
+                                             ( concat             $
+                                                 map encodeWord16 $
+                                                   toList         $
+                                                     sam_v1_6_alignment_bopt_word16_value bopt_word16
+                                             )
+    sam_v1_6_alignment_bopt_int32_d x = case (sam_v1_6_alignment_bopt_int32 x) of
+                                          Nothing         ->
+                                            ""
+                                          Just bopt_int32 ->
+                                            ( unpack       $
+                                                fromStrict $
+                                                  pack     $
+                                                    toList $
+                                                      sam_v1_6_alignment_bopt_int32_tag bopt_int32
+                                            )   ++
+                                            ":" ++
+                                            "B" ++
+                                            ":" ++
+                                            ( unpack           $
+                                                fromStrict     $
+                                                  DB.singleton $
+                                                    sam_v1_6_alignment_bopt_int32_type bopt_int32
+                                            )   ++
+                                            "," ++
+                                            ( concat     $
+                                                map show $
+                                                  toList $
+                                                    sam_v1_6_alignment_bopt_int32_value bopt_int32
+                                            )
+    sam_v1_6_alignment_bopt_word32_d x = case (sam_v1_6_alignment_bopt_word32 x) of 
+                                           Nothing          ->
+                                             ""
+                                           Just bopt_word32 ->
+                                             ( unpack       $
+                                                 fromStrict $
+                                                   pack     $
+                                                     toList $
+                                                       sam_v1_6_alignment_bopt_word32_tag bopt_word32
+                                             )   ++
+                                             ":" ++
+                                             "B" ++
+                                             ":" ++
+                                             ( unpack           $
+                                                 fromStrict     $
+                                                   DB.singleton $
+                                                     sam_v1_6_alignment_bopt_word32_type bopt_word32
+                                             )   ++
+                                             "," ++
+                                             ( concat             $
+                                                 map encodeWord32 $
+                                                   toList         $
+                                                     sam_v1_6_alignment_bopt_word32_value bopt_word32
+                                             )
+    sam_v1_6_alignment_bopt_float_d x = case (sam_v1_6_alignment_bopt_float x) of 
+                                          Nothing         ->
+                                            ""
+                                          Just bopt_float ->
+                                            ( unpack       $
+                                                fromStrict $
+                                                  pack     $
+                                                    toList $
+                                                      sam_v1_6_alignment_bopt_float_tag bopt_float
+                                            )   ++
+                                            ":" ++
+                                            "B" ++
+                                            ":" ++
+                                            ( unpack           $
+                                                fromStrict     $
+                                                  DB.singleton $
+                                                    sam_v1_6_alignment_bopt_float_type bopt_float
+                                            )   ++
+                                            "," ++
+                                            ( concat     $
+                                                map show $
+                                                  toList $
+                                                    sam_v1_6_alignment_bopt_float_value bopt_float
+                                            )
+-}
+    encodeWord16 :: Word16
+                 -> [Char]
+    encodeWord16 = unpack                      .
+                     DBL.filter (\x -> x /= 0) .
+                       toLazyByteString        .
+                         word16LE
+    encodeWord32 :: Word32
+                 -> [Char]
+    encodeWord32 = unpack                      .
+                     DBL.filter (\x -> x /= 0) .
+                       toLazyByteString        .
+                         word32LE
 
 -- | Write @"SAM_V1_6"@ to a file.
 -- Calls deconstructSAM_V1_6.
diff --git a/test/Main.hs b/test/Main.hs
--- a/test/Main.hs
+++ b/test/Main.hs
@@ -1,62 +1,47 @@
 module Main (main) where
 
-import Data.SAM.Version1_6.Base
-import Data.SAM.Version1_6.Alignment
-import Data.SAM.Version1_6.Alignment.IOPT
-import Data.SAM.Version1_6.Alignment.ZOPT
-import Data.SAM.Version1_6.Alignment.BOPT
-import Data.SAM.Version1_6.Header
+import Data.BAM.Version1_6.Read.Base
+import Data.BAM.Version1_6.Write.Base
 import Data.SAM.Version1_6.Read.Base
+import Data.SAM.Version1_6.Write.Base
 
-import Data.Sequence (fromList)
-import Data.String   (fromString)
 import Test.Hspec
-import Data.SAM.Version1_6.Write.Base 
 
 main :: IO ()
-main = hspec $ do
-  describe "Data.SAM.Version1_6.Read.Base" $ do
-    describe "readSAM_V1_6" $ do
-      describe "toy5.sam" $ do
-        it "Ensures that readSAM_V1_6 can read and parse a SAM file with only alignment fields." $ do
-          readSAM_V1_6 "test/examples/toy5.sam" `shouldReturn` toy5sam
-      describe "toy4.sam" $ do
-        it "Ensures that readSAM_V1_6 can read and parse a SAM file with an optional alignment field." $ do
-          readSAM_V1_6 "test/examples/toy4.sam" `shouldReturn` toy4sam
-      describe "toy2.sam" $ do
-        it "Ensures that readSAM_V1_6 can read and parse a SAM file with file-level metadata (@HD) and reference sequence dictionary (@SQ) optional header fields." $ do
-          readSAM_V1_6 "test/examples/toy2.sam" `shouldReturn` toy2sam
-      describe "toy1.sam" $ do
-        it "Ensures that readSAM_V1_6 can read and parse a SAM file with multiple reference sequence dictionary (@SQ) optional header fields." $ do
-          readSAM_V1_6 "test/examples/toy1.sam" `shouldReturn` toy1sam
-  describe "Data.SAM.Version1_6.Write.Base" $ do
-    describe "writeSAM_V1_6" $ do
-      describe "toy5.sam" $ do
-        it "Ensures writeSAM_V1_6 produces the a sam file equivalent to what was parsed via readSAM_V1_6." $ do
-          toy5 <- readSAM_V1_6 "test/examples/toy5.sam"
-          writeSAM_V1_6 "test/examples/toy5f.sam" toy5
-          toy5f <- readSAM_V1_6 "test/examples/toy5f.sam"
-          toy5 `shouldBe` toy5f
-      describe "toy4.sam" $ do
-        it "Ensures writeSAM_V1_6 produces the a sam file equivalent to what was parsed via readSAM_V1_6." $ do
-          toy4 <- readSAM_V1_6 "test/examples/toy4.sam"
-          writeSAM_V1_6 "test/examples/toy4f.sam" toy4
-          toy4f <- readSAM_V1_6 "test/examples/toy4f.sam"
-          toy4 `shouldBe` toy4f
-      describe "toy2.sam" $ do
-        it "Ensures writeSAM_V1_6 produces the a sam file equivalent to what was parsed via readSAM_V1_6." $ do
-          toy2 <- readSAM_V1_6 "test/examples/toy2.sam"
-          writeSAM_V1_6 "test/examples/toy2f.sam" toy2
-          toy2f <- readSAM_V1_6 "test/examples/toy2f.sam"
-          toy2 `shouldBe` toy2f
-      describe "toy1.sam" $ do
-        it "Ensures writeSAM_V1_6 produces the a sam file equivalent to what was parsed via readSAM_V1_6." $ do
-          toy1 <- readSAM_V1_6 "test/examples/toy1.sam"
-          writeSAM_V1_6 "test/examples/toy1f.sam" toy1
-          toy1f <- readSAM_V1_6 "test/examples/toy1f.sam"
-          toy1 `shouldBe` toy1f
-  where
-    toy1sam = SAM_V1_6 { sam_v1_6_file_level_metadata = Nothing , sam_v1_6_reference_sequence_dictionary = Just (fromList [SAM_V1_6_Reference_Sequence_Dictionary { sam_v1_6_reference_sequence_dictionary_reference_sequence_name = SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Name { sam_v1_6_reference_sequence_dictionary_reference_sequence_name_value = fromString  "ref" } , sam_v1_6_reference_sequence_dictionary_reference_sequence_length = SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Length { sam_v1_6_reference_sequence_dictionary_reference_sequence_length_value = fromString  "45" } , sam_v1_6_reference_sequence_dictionary_alternative_locus = Nothing , sam_v1_6_reference_sequence_dictionary_alternative_reference_sequence_names = Nothing , sam_v1_6_reference_sequence_dictionary_genome_assembly_identifier = Nothing , sam_v1_6_reference_sequence_dictionary_description = Nothing , sam_v1_6_reference_sequence_dictionary_md5_checksum = Nothing , sam_v1_6_reference_sequence_dictionary_species = Nothing , sam_v1_6_reference_sequence_dictionary_molecule_topology = Nothing , sam_v1_6_reference_sequence_dictionary_uri = Nothing },SAM_V1_6_Reference_Sequence_Dictionary { sam_v1_6_reference_sequence_dictionary_reference_sequence_name = SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Name { sam_v1_6_reference_sequence_dictionary_reference_sequence_name_value = fromString  "ref2" } , sam_v1_6_reference_sequence_dictionary_reference_sequence_length = SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Length { sam_v1_6_reference_sequence_dictionary_reference_sequence_length_value = fromString  "40" } , sam_v1_6_reference_sequence_dictionary_alternative_locus = Nothing , sam_v1_6_reference_sequence_dictionary_alternative_reference_sequence_names = Nothing , sam_v1_6_reference_sequence_dictionary_genome_assembly_identifier = Nothing , sam_v1_6_reference_sequence_dictionary_description = Nothing , sam_v1_6_reference_sequence_dictionary_md5_checksum = Nothing , sam_v1_6_reference_sequence_dictionary_species = Nothing , sam_v1_6_reference_sequence_dictionary_molecule_topology = Nothing , sam_v1_6_reference_sequence_dictionary_uri = Nothing }]) , sam_v1_6_read_group = Nothing , sam_v1_6_program = Nothing , sam_v1_6_one_line_comment = Nothing , sam_v1_6_alignment = fromList [SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r001" , sam_v1_6_alignment_flag = 163 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 7 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "8M4I4M1D3M" , sam_v1_6_alignment_rnext = fromString  "=" , sam_v1_6_alignment_pnext = 37 , sam_v1_6_alignment_tlen = 39 , sam_v1_6_alignment_seq = fromString  "TTAGATAAAGAGGATACTG" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Just SAM_V1_6_Alignment_BOPT { sam_v1_6_alignment_bopt_int8 = Nothing , sam_v1_6_alignment_bopt_word8 = Nothing , sam_v1_6_alignment_bopt_int16 = Nothing , sam_v1_6_alignment_bopt_word16 = Just SAM_V1_6_Alignment_BOPT_Word16 { sam_v1_6_alignment_bopt_word16_tag  = fromList [88,88] , sam_v1_6_alignment_bopt_word16_type = 83 , sam_v1_6_alignment_bopt_word16_value = fromList [49,50,53,54,49,44,50,44,50,48,44,49,49,50] } , sam_v1_6_alignment_bopt_int32 = Nothing , sam_v1_6_alignment_bopt_word32 = Nothing , sam_v1_6_alignment_bopt_float = Nothing } },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r002" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 9 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "1S2I6M1P1I1P1I4M2I" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "AAAAGATAAGGGATAAA" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r003" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 9 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "5H6M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "AGCTAA" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r004" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 16 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "6M14N1I5M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "ATAGCTCTCAGC" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r003" , sam_v1_6_alignment_flag = 16 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 29 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "6H5M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "TAGGC" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r001" , sam_v1_6_alignment_flag = 83 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 37 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "9M" , sam_v1_6_alignment_rnext = fromString  "=" , sam_v1_6_alignment_pnext = 7 , sam_v1_6_alignment_tlen = -39 , sam_v1_6_alignment_seq = fromString  "CAGCGCCAT" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "x1" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref2" , sam_v1_6_alignment_pos = 1 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "20M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "aggttttataaaacaaataa" , sam_v1_6_alignment_qual = fromString  "????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "x2" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref2" , sam_v1_6_alignment_pos = 2 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "21M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "ggttttataaaacaaataatt" , sam_v1_6_alignment_qual = fromString  "?????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "x3" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref2" , sam_v1_6_alignment_pos = 6 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "9M4I13M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "ttataaaacAAATaattaagtctaca" , sam_v1_6_alignment_qual = fromString  "??????????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "x4" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref2" , sam_v1_6_alignment_pos = 10 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "25M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "CaaaTaattaagtctacagagcaac" , sam_v1_6_alignment_qual = fromString  "?????????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "x5" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref2" , sam_v1_6_alignment_pos = 12 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "24M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "aaTaattaagtctacagagcaact" , sam_v1_6_alignment_qual = fromString  "????????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "x6" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref2" , sam_v1_6_alignment_pos = 14 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "23M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "Taattaagtctacagagcaacta" , sam_v1_6_alignment_qual = fromString  "???????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing }] }
-    toy2sam = SAM_V1_6 { sam_v1_6_file_level_metadata = Just SAM_V1_6_File_Level_Metadata { sam_v1_6_file_level_metadata_format_version = SAM_V1_6_File_Level_Metadata_Format_Version { sam_v1_6_file_level_metadata_format_version_value = fromString  "1.6" } , sam_v1_6_file_level_metadata_sorting_order = Just SAM_V1_6_File_Level_Metadata_Sorting_Order { sam_v1_6_file_level_metadata_sorting_order_value = fromString  "coordinate" } , sam_v1_6_file_level_metadata_alignment_grouping = Nothing , sam_v1_6_file_level_metadata_subsorting_order = Nothing } , sam_v1_6_reference_sequence_dictionary = Just (fromList [SAM_V1_6_Reference_Sequence_Dictionary { sam_v1_6_reference_sequence_dictionary_reference_sequence_name = SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Name { sam_v1_6_reference_sequence_dictionary_reference_sequence_name_value = fromString  "ref" } , sam_v1_6_reference_sequence_dictionary_reference_sequence_length = SAM_V1_6_Reference_Sequence_Dictionary_Reference_Sequence_Length { sam_v1_6_reference_sequence_dictionary_reference_sequence_length_value = fromString  "45" } , sam_v1_6_reference_sequence_dictionary_alternative_locus = Nothing , sam_v1_6_reference_sequence_dictionary_alternative_reference_sequence_names = Nothing , sam_v1_6_reference_sequence_dictionary_genome_assembly_identifier = Nothing , sam_v1_6_reference_sequence_dictionary_description = Nothing , sam_v1_6_reference_sequence_dictionary_md5_checksum = Nothing , sam_v1_6_reference_sequence_dictionary_species = Nothing , sam_v1_6_reference_sequence_dictionary_molecule_topology = Nothing , sam_v1_6_reference_sequence_dictionary_uri = Nothing }]) , sam_v1_6_read_group = Nothing , sam_v1_6_program = Nothing , sam_v1_6_one_line_comment = Nothing , sam_v1_6_alignment = fromList [SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r001" , sam_v1_6_alignment_flag = 99 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 7 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "8M2I4M1D3M" , sam_v1_6_alignment_rnext = fromString  "=" , sam_v1_6_alignment_pnext = 37 , sam_v1_6_alignment_tlen = 39 , sam_v1_6_alignment_seq = fromString  "TTAGATAAAGGATACTG" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r002" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 9 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "3S6M1P1I4M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "AAAAGATAAGGATA" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r003" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 9 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "5S6M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "GCCTAAGCTAA" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Just SAM_V1_6_Alignment_ZOPT { sam_v1_6_alignment_zopt_tag = fromString  "SA" , sam_v1_6_alignment_zopt_value = fromString  "ref,29,-,6H5M,17,0;" } , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r004" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 16 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "6M14N5M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "ATAGCTTCAGC" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r003" , sam_v1_6_alignment_flag = 2064 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 29 , sam_v1_6_alignment_mapq = 17 , sam_v1_6_alignment_cigar = fromString  "6H5M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "TAGGC" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Just SAM_V1_6_Alignment_ZOPT { sam_v1_6_alignment_zopt_tag = fromString  "SA" , sam_v1_6_alignment_zopt_value = fromString  "ref,9,+,5S6M,30,1;" } , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r001" , sam_v1_6_alignment_flag = 147 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 37 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "9M" , sam_v1_6_alignment_rnext = fromString  "=" , sam_v1_6_alignment_pnext = 7 , sam_v1_6_alignment_tlen = -39 , sam_v1_6_alignment_seq = fromString  "CAGCGGCAT" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Just SAM_V1_6_Alignment_IOPT { sam_v1_6_alignment_iopt_tag = fromString  "NM" , sam_v1_6_alignment_iopt_value = 1 } , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing }] } 
-    toy4sam = SAM_V1_6 { sam_v1_6_file_level_metadata = Nothing , sam_v1_6_reference_sequence_dictionary = Nothing , sam_v1_6_read_group = Nothing , sam_v1_6_program = Nothing , sam_v1_6_one_line_comment = Nothing , sam_v1_6_alignment = fromList [SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r001" , sam_v1_6_alignment_flag = 163 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 7 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "8M4I4M1D3M" , sam_v1_6_alignment_rnext = fromString  "=" , sam_v1_6_alignment_pnext = 37 , sam_v1_6_alignment_tlen = 39 , sam_v1_6_alignment_seq = fromString  "TTAGATAAAGAGGATACTG" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Just SAM_V1_6_Alignment_BOPT { sam_v1_6_alignment_bopt_int8 = Nothing , sam_v1_6_alignment_bopt_word8 = Nothing , sam_v1_6_alignment_bopt_int16 = Nothing , sam_v1_6_alignment_bopt_word16 = Just SAM_V1_6_Alignment_BOPT_Word16 { sam_v1_6_alignment_bopt_word16_tag  = fromList [88,88] , sam_v1_6_alignment_bopt_word16_type = 83 , sam_v1_6_alignment_bopt_word16_value = fromList [49,50,53,54,49,44,50,44,50,48,44,49,49,50] } , sam_v1_6_alignment_bopt_int32 = Nothing , sam_v1_6_alignment_bopt_word32 = Nothing , sam_v1_6_alignment_bopt_float = Nothing } },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r002" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 9 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "1S2I6M1P1I1P1I4M2I" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "AAAAGATAAGGGATAAA" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r003" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 9 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "5H6M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "AGCTAA" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r004" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 16 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "6M14N1I5M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "ATAGCTCTCAGC" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r003" , sam_v1_6_alignment_flag = 16 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 29 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "6H5M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "TAGGC" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r001" , sam_v1_6_alignment_flag = 83 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 37 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "9M" , sam_v1_6_alignment_rnext = fromString  "=" , sam_v1_6_alignment_pnext = 7 , sam_v1_6_alignment_tlen = -39 , sam_v1_6_alignment_seq = fromString  "CAGCGCCAT" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "x1" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref2" , sam_v1_6_alignment_pos = 1 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "20M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "aggttttataaaacaaataa" , sam_v1_6_alignment_qual = fromString  "????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "x2" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref2" , sam_v1_6_alignment_pos = 2 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "21M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "ggttttataaaacaaataatt" , sam_v1_6_alignment_qual = fromString  "?????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "x3" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref2" , sam_v1_6_alignment_pos = 6 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "9M4I13M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "ttataaaacAAATaattaagtctaca" , sam_v1_6_alignment_qual = fromString  "??????????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "x4" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref2" , sam_v1_6_alignment_pos = 10 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "25M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "CaaaTaattaagtctacagagcaac" , sam_v1_6_alignment_qual = fromString  "?????????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "x5" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref2" , sam_v1_6_alignment_pos = 12 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "24M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "aaTaattaagtctacagagcaact" , sam_v1_6_alignment_qual = fromString  "????????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "x6" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref2" , sam_v1_6_alignment_pos = 14 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "23M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "Taattaagtctacagagcaacta" , sam_v1_6_alignment_qual = fromString  "???????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing }] } 
-    toy5sam = SAM_V1_6 { sam_v1_6_file_level_metadata = Nothing , sam_v1_6_reference_sequence_dictionary = Nothing , sam_v1_6_read_group = Nothing , sam_v1_6_program = Nothing , sam_v1_6_one_line_comment = Nothing , sam_v1_6_alignment = fromList [SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r001" , sam_v1_6_alignment_flag = 163 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 7 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "8M4I4M1D3M" , sam_v1_6_alignment_rnext = fromString  "=" , sam_v1_6_alignment_pnext = 37 , sam_v1_6_alignment_tlen = 39 , sam_v1_6_alignment_seq = fromString  "TTAGATAAAGAGGATACTG" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r002" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 9 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "1S2I6M1P1I1P1I4M2I" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "AAAAGATAAGGGATAAA" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r003" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 9 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "5H6M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "AGCTAA" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r004" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 16 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "6M14N1I5M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "ATAGCTCTCAGC" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r003" , sam_v1_6_alignment_flag = 16 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 29 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "6H5M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "TAGGC" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "r001" , sam_v1_6_alignment_flag = 83 , sam_v1_6_alignment_rname = fromString  "ref" , sam_v1_6_alignment_pos = 37 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "9M" , sam_v1_6_alignment_rnext = fromString  "=" , sam_v1_6_alignment_pnext = 7 , sam_v1_6_alignment_tlen = -39 , sam_v1_6_alignment_seq = fromString  "CAGCGCCAT" , sam_v1_6_alignment_qual = fromString  "*" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "x1" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref2" , sam_v1_6_alignment_pos = 1 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "20M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "aggttttataaaacaaataa" , sam_v1_6_alignment_qual = fromString  "????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "x2" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref2" , sam_v1_6_alignment_pos = 2 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "21M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "ggttttataaaacaaataatt" , sam_v1_6_alignment_qual = fromString  "?????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "x3" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref2" , sam_v1_6_alignment_pos = 6 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "9M4I13M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "ttataaaacAAATaattaagtctaca" , sam_v1_6_alignment_qual = fromString  "??????????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "x4" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref2" , sam_v1_6_alignment_pos = 10 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "25M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "CaaaTaattaagtctacagagcaac" , sam_v1_6_alignment_qual = fromString  "?????????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "x5" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref2" , sam_v1_6_alignment_pos = 12 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "24M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "aaTaattaagtctacagagcaact" , sam_v1_6_alignment_qual = fromString  "????????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing },SAM_V1_6_Alignment { sam_v1_6_alignment_qname = fromString  "x6" , sam_v1_6_alignment_flag = 0 , sam_v1_6_alignment_rname = fromString  "ref2" , sam_v1_6_alignment_pos = 14 , sam_v1_6_alignment_mapq = 30 , sam_v1_6_alignment_cigar = fromString  "23M" , sam_v1_6_alignment_rnext = fromString  "*" , sam_v1_6_alignment_pnext = 0 , sam_v1_6_alignment_tlen = 0 , sam_v1_6_alignment_seq = fromString  "Taattaagtctacagagcaacta" , sam_v1_6_alignment_qual = fromString  "???????????????????????" , sam_v1_6_alignment_aopt = Nothing , sam_v1_6_alignment_iopt = Nothing , sam_v1_6_alignment_fopt = Nothing , sam_v1_6_alignment_zopt = Nothing , sam_v1_6_alignment_hopt = Nothing , sam_v1_6_alignment_bopt = Nothing }] }
+main =
+  hspec $ do
+    describe "Data.SAM.Version1_6.Write.Base" $ do
+      describe "writeSAM_V1_6" $ do
+        describe "SAM/toy5.sam" $ do
+          it "Ensures writeSAM_V1_6 produces the a sam file equivalent to what was parsed via readSAM_V1_6." $ do
+            toy5 <- readSAM_V1_6 "test/examples/SAM/toy5.sam"
+            writeSAM_V1_6 "test/examples/SAM/toy5f.sam" toy5
+            toy5f <- readSAM_V1_6 "test/examples/SAM/toy5f.sam"
+            toy5 `shouldBe` toy5f
+        describe "SAM/toy4.sam" $ do
+          it "Ensures writeSAM_V1_6 produces the a sam file equivalent to what was parsed via readSAM_V1_6." $ do
+            toy4 <- readSAM_V1_6 "test/examples/SAM/toy4.sam"
+            writeSAM_V1_6 "test/examples/SAM/toy4f.sam" toy4
+            toy4f <- readSAM_V1_6 "test/examples/SAM/toy4f.sam"
+            toy4 `shouldBe` toy4f
+        describe "SAM/toy2.sam" $ do
+          it "Ensures writeSAM_V1_6 produces the a sam file equivalent to what was parsed via readSAM_V1_6." $ do
+            toy2 <- readSAM_V1_6 "test/examples/SAM/toy2.sam"
+            writeSAM_V1_6 "test/examples/SAM/toy2f.sam" toy2
+            toy2f <- readSAM_V1_6 "test/examples/SAM/toy2f.sam"
+            toy2 `shouldBe` toy2f
+        describe "SAM/toy1.sam" $ do
+          it "Ensures writeSAM_V1_6 produces the a sam file equivalent to what was parsed via readSAM_V1_6." $ do
+            toy1 <- readSAM_V1_6 "test/examples/SAM/toy1.sam"
+            writeSAM_V1_6 "test/examples/SAM/toy1f.sam" toy1
+            toy1f <- readSAM_V1_6 "test/examples/SAM/toy1f.sam"
+            toy1 `shouldBe` toy1f
+    describe "Data.BAM.Version1_6.Write.Base" $ do
+      describe "WriteBAM_V1_6" $ do
+        describe "BAM/ex1ff_sorted.bam" $ do
+          it "Ensures writeBAM_V1_6 produces a bam file equivalent to what was parsed via readBAM_V1_6." $ do
+            _        <- readBAM_V1_6 "test/examples/BAM/ex1ff_sorted.bam" >>= writeBAM_V1_6 "test/examples/BAM/ex1ff_sortedf.bam"
+            bamv16f  <- readBAM_V1_6 "test/examples/BAM/ex1ff_sortedf.bam"
+            _        <- writeBAM_V1_6 "test/examples/BAM/ex1ff_sortedff.bam" bamv16f
+            bamv16ff <- readBAM_V1_6 "test/examples/BAM/ex1ff_sortedff.bam"
+            bamv16f `shouldBe` bamv16ff
