Closed fendor closed 3 years ago
I don't think it is acceptable to impose an additional constraint by default. However, I think it might be possible to design a custom alteration that would use that EveryDict
module. That might make it really easy to support both plain Dict
for those who don't care or don't have the performance problem, and those who need EveryDict
.
You mean, an additional derive option? For example:
-- | Note that This default set of options is distinct from that in
-- the @aeson@ package.
defaultOptions :: A.Options
defaultOptions
= A.defaultOptions
{ {- ommit other fields for clarity -}
...
, A.useEveryDict = False
}
But I think this would require an additional argument to at least makeElmModuleWithVersion
. Probably to a lot of others as well, since I use custom encoding and decoding functions.
No, I mean the first argument to makeModuleContentWithAlterations
. What I linked to in the previous message is the default "alteration", that is used with makeModuleContent
.
OK, I think I understand what you mean, I will look into it later and squash these comments, sorry, it was not possible to edit these from phone
I have currently no intention on working on this, thus I am closing the PR.
Because of Elm's rather weird situation with
comparable
, theDict
in the core library can not take arbitrary types as a key.This raises the inconvenience to substitute data structures with a non-comparable type, to be rewritten to the following form
List ( k, v )
wherek
is the key andv
the value. This can cause a performance issue on large data-sets and also inconvenient access-functions which have to be defined by the programmer.For this reason, my fork solves this problem by declaring an additional dependency on the elm-all-dict-library and replacing all occurrences of the form
List ( k, v )
andDict comparable v
toEveryDict k v
.The tests have been updated and run, and the fork is currently used in a project without a problem, but I think some use-cases have not been tested yet.
I also defined own function for decoding and encoding
EveryDict
which are based on the functionsencodeMap
anddecodeMap
from json-helpers.