Advertisement
NLinker

Dealing with conflicting variants of _id_

Sep 26th, 2019
529
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- krafted and shared by @cblp
  2.  
  3. {-# LANGUAGE DeriveGeneric #-}
  4. {-# LANGUAGE DuplicateRecordFields #-}
  5. {-# LANGUAGE NamedFieldPuns #-}
  6. {-# LANGUAGE OverloadedLabels #-}
  7.  
  8. import Control.Lens
  9. import Data.Generics.Labels
  10. import GHC.Generics
  11. import Prelude hiding (id)
  12. import qualified Prelude
  13.  
  14. ı = Prelude.id
  15.  
  16. data A = A {id :: Int}
  17.   deriving (Generic)
  18.  
  19. data B = B {id :: Int}
  20.   deriving (Generic)
  21.  
  22. main = do
  23.   let a = A {id = 1}
  24.   print $ let A {id} = a in ı id
  25.   let b = B {id = 2}
  26.   print $ let B {id} = b & #id %~ negate in id
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement