Named field with Umlaut not recognized with Cassava

Solution 1:

You need to write:

import qualified Data.Text.Encoding as Text
instance FromNamedRecord Transaction where
  parseNamedRecord m =
    Tx
      <$> m .: Text.encodeUtf8 "Währung"
      <*> m .: "Betrag"

The problem is that cassava is internally representing field names as the ByteString of the UTF-8 encoding of the text. However, the IsString instance for ByteStrings which is used to encode a string literal to a ByteString does not use UTF-8 encoding but rather encodes each character as the least-significant byte of its code point (which is basically never what you want for non-ASCII strings).