3.0.0 – Encoding and better errors
Csv.Encode
You can now encode CSVs using this package:
import Csv.Encode as Encode
Encode.encode
{ encoder =
Encode.withFieldNames
(\(r, g, b) ->
[ ( "red", r )
, ( "green", g )
, ( "blue", b )
]
)
, fieldSeparator = ','
}
[ ( "FF", "FF", "FF" )
, ( "00", "00", "00" )
]
--> "red,green,blue\r\nFF,FF,FF\r\n00,00,00"
Fields will be properly quoted and escaped. In addition, withFieldNames
will always produce aligned CSVs, even in cases where the provided function does not provide all the fields every time.
Better Error Messages
Error messages are greatly improved.
- Row numbers are never negative.
- Errors now specify which column they came frome.
- You now get all the problems in a decoding run in a single error, instead of having to re-run to discover further problems.
- Message strings and constructors are streamlined and clarified.
These changes are why this release is numbered 3.0.0 instead of 2.1.0—the internal custom types representing errors changed. However, unless you were doing your own message-to-string encoding, this release is unlikely to have broken your code. (decodeCsv
produces the error that errorToString
takes, just like before. If you were using that, you can upgrade safely!)
End-of-line Quotes Bug Fix
There was a bug (#15) where quoted fields at the end of a line would combine adjacent lines into one. This release fixes that!