I am trying to write some code to read flat files from a mainframe system. This includes some character fields. This is a fixed width file, so each field will have a consistent length between records, but there are fields of different length within a record. For example, I might have a &quot;name&quot; field length 20 and an eye color field length 5.<br>
<br>I am trying to use the binary library to read in this file. I&#39;ve written a binary type, MFChar2, for reading in a 2-length character field. It is defined as such (you can safely ignore the ebcdicToAscii piece, it is just doing character conversion):<br>
<br>data MFChar2 = MFChar2 [Word8]<br>instance Binary MFChar2 where<br>&nbsp;&nbsp;&nbsp; put = undefined<br>&nbsp;&nbsp;&nbsp; get = do ebcdic &lt;- replicateM 2 getWord8<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return $ MFChar2 $ map ebcdicToAscii ebcdic<br><br>What I would like to do is have some kind of generic &quot;MFChar&quot; data type which could take any character length, but I can&#39;t figure out how to do it. Any help would be appreciated.<br>
<br>Thanks,<br>Michael<br>