Skip to content

Commit

Permalink
Put original string instead of foldedCase
Browse files Browse the repository at this point in the history
The foldedCase is derivative of the original string, while the latter
is unique. So, putting foldedCase instead of original string leads to
loss of data, while getting from the original string must always restore
CI object correctly as it has been built from the original string.

Probably it should also fix weird cases like in issue haskellari#7.

My own case was restoring serialized ResponseHeaders from
Network.HTTP.Types. Say, putting Custom-Header and restoring it later
makes it custom-header (when I take it with original), while when
putting original string it restores correctly as Custom-Header (when I
take it with original).
  • Loading branch information
lyokha committed Jul 28, 2020
1 parent 9040f38 commit bcef15d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Data/Binary/Instances/CaseInsensitive.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ import qualified Data.CaseInsensitive as CI

instance (CI.FoldCase a, Binary a) => Binary (CI.CI a) where
get = fmap CI.mk get
put = put . CI.foldedCase
put = put . CI.original

0 comments on commit bcef15d

Please sign in to comment.