derived types - Why explicit derivation of Show/Read in Haskell? -


we can't read somevalue :: somedatatype or show somevalue every type because deriving (show, read) has written in data declarations. there case, other mistake, don't want our type serializable? why show separated read? there case, other mistake, want show data , not read it? if not, why not have single data type serializable?

just now, i'm using the key datatype of gloss library derives show , not read, don't understand. it's shame because wanted put configuration of controls in file , read it, player can change controls , have own configuration. had wrappers key, specialkey , mousebutton, not big deal useless.

data key' = char' char | specialkey' specialkey | mousebutton' mousebutton     deriving (eq, ord, show, read) convertkey x = case x of     char' c -> char c     specialkey' sk -> specialkey sk     mousebutton' mb -> mousebutton mb 

why show separate read

i don't know why originally, feel should persist because (very few) types can shown, or have placeholder string shown, not read in. functions typical example.

another way think it: it's easy place things in separate classes hard deal many functions in 1 class doesn't make sense in same contexts. many people feel num class prime example of issue.

how can read key , other types not in read

step one: send in patch adding read set of derived instances. step two: make work around using standalone deriving:

{-# language standalonederiving #-} deriving instance show key 

step three: use cpp make code work either version of codebase, gloss library read instances ben someday release or version without.

why isn't there serializable class?

for starters, there a serialize class. also, text horrible way serialize things. perhaps you'd want lazier serialize class in case should see binary class. if you're concerned performance might blaze-builder, though i've never used it.


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c++ - Using OpenSSL in a multi-threaded application -

All overlapping substrings matching a java regex -