What is the best way to make
type Configuration = Array DIM1 (Double, Double, Double)
an instance of Read? So later I could derive
data SimulationData = SD Configuration Double StdGen Int
to be an instance of Read too.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Such an instance will be an orphan instance, which you should generally avoid. However, it’s fairly simple to write it:
If you use the
StandaloneDerivingextension, the first two instances can be simplified:These instances should probably be in repa itself; I just based them on the example instance given in Text.Show and repa’s
showoutput. I suggest making a feature request on repa’s bug tracker, and putting these instances into a module of your program for now (unless you want to avoid orphan instances entirely, in which case you’ll have to solve the problem another way altogether).That said, you should probably consider simply converting your data to a list (with
toList) and using that; it avoids the orphan instance, and shouldn’t have any downsides. You might also want to consider using a “real” serialisation library like cereal if you’re more interested in processing the data with code than having it be human-readable;Readis generally considered to be of rather limited use.