<html><head><style>p{margin-top:0px;margin-bottom:0px;}</style></head><body><div style="font-size:10pt; font-family:Gulim, sans-serif;"><p><span style="font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255); color: rgb(0, 0, 0);">For use of ciphers (SHA-256, RSA-2048, etc.), a type must be able to be injectively mapped to integers. It seems `Enum` is currently the closest thing that does this. </span></p><p><span style="font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255); color: rgb(0, 0, 0);">But `Enum` is supposed to be for arithmetic sequences, so it seems better to define a new typeclass. (Here named `Cipherable`) </span></p><p><span style="font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255); color: rgb(0, 0, 0);">There are some types that aren't members of `Enum`. For example, `Maybe`, `[]`, etc. They seem okay to be Cipherable. Hence:</span></p><p><span style="font-family: courier new, serif;"> </span></p><p> </p><div style="color: #d4d4d4;background-color: #1e1e1e;font-family: Unifont;font-weight: normal;font-size: 16px;line-height: 22px;white-space: pre;"><div><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">{-# LANGUAGE ScopedTypeVariables #-}</span></div><span style="font-family: courier new, serif; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-size: 10pt;"></span><br><div><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">instance</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> </span><span style="font-family: courier new, serif; font-size: 10pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">Cipherable</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">a</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">=></span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> </span><span style="font-family: courier new, serif; font-size: 10pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">Cipherable</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> (</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">Maybe</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">a</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">) </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">where</span></div><div><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> toEnum </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">0</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">=</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> Nothing</span></div><div><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> toEnum n </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">=</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> Just (toEnum n)</span></div><div><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> fromEnum Nothing </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">=</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">0</span></div><div><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> fromEnum (Just x) </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">=</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">1</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">+</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> fromEnum x</span></div><br><div><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">instance</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">forall</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">a</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">. (</span><span style="font-family: courier new, serif; font-size: 10pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">Cipherable</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">a</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">, </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">Bounded</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">a</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">) </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">=></span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> </span><span style="font-family: courier new, serif; font-size: 10pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">Cipherable</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> [</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">a</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">] </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">where</span></div><div><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> toEnum </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">0</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">=</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">[]</span></div><div><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> toEnum n </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">=</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">let</span></div><div><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> (q,r) </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">=</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> (n</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">-</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">1</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">) </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">`quotRem`</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> (</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">1</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">+</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> fromEnum (maxBound </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">::</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">a</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">))</span></div><div><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">in</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> toEnum r </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">:</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> toEnum q</span></div><div><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> fromEnum </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">[]</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">=</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">0</span></div><div><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> fromEnum (x</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">:</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">xs) </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">=</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">1</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">+</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> fromEnum x </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">+</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> (</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">1</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">+</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> fromEnum (maxBound </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">::</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">a</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">)) </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">*</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> fromEnum xs</span></div><div><div style="color: #d4d4d4;background-color: #1e1e1e;font-family: Unifont;font-weight: normal;font-size: 16px;line-height: 22px;white-space: pre;"><br><div><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">instance</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> </span><span style="font-family: courier new, serif; font-size: 10pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">Cipherable</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">Void</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">where</span></div><div><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> toEnum </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">=</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> errorWithoutStackTrace </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">"Cipher.</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"><span style="font-family: courier new, serif; font-size: 10pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">Cipherable</span>.Void.toEnum"</span></div><div><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> fromEnum </span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);">=</span><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"> absurd</span></div><div><br></div><div><br></div><div><span style="font-family: courier new, serif; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-size: 10pt;">(Besides, it is possible to re-write that of `[]` without ScopedTypeVariables? I see no way...)</span><br><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"></span></div><div><br><span style="color: rgb(0, 0, 0); font-family: courier new, serif; font-size: 10pt; background-color: rgb(255, 255, 255);"></span></div></div></div></div><p><span style="font-family: courier new, serif;"></span></p></div></body></html><table style='display:none'><tr><td><img src="https://mail.naver.com/readReceipt/notify/?img=J9RCbHFTpz%2FYaqgZKrRZaxKqMrUZKqtwMxpSFoUdF4k0FxJvMrMlpzF0p63gMX%2B0MoUl74lR74lcWNFlbX30WLloWrdQarwGMNiCb400bdIcMBFOp6wn74eZpm%3D%3D.gif" border="0"/></td></tr></table>