Created
October 20, 2022 17:14
-
-
Save Lysxia/0951fc852da2bb3274433f241a013307 to your computer and use it in GitHub Desktop.
Deriving Read and Show for records as if they weren't records
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE DeriveGeneric, DerivingVia #-} | |
import GHC.Generics (Generic) | |
import Generic.Data | |
import Generic.Data.Microsurgery | |
data R = R {a :: Int, b :: Int} | |
deriving Generic | |
deriving (Read, Show) via Surgery Derecordify R | |
main :: IO () | |
main = do | |
print (read "R 0 1" :: R) | |
-- Output: R 0 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment