Skip to content

Instantly share code, notes, and snippets.

@adituv
Last active August 29, 2015 14:15
Show Gist options
  • Select an option

  • Save adituv/43f4c0a1789b70e0fe9a to your computer and use it in GitHub Desktop.

Select an option

Save adituv/43f4c0a1789b70e0fe9a to your computer and use it in GitHub Desktop.
Qualified Record Pun
{-# LANGUAGE NamedFieldPuns #-}
module Main where
import qualified MyRecord as M
someFunction :: M.MyRecordType -> Int
someFunction (MyRecordType { M.someVal }) = M.someVal * M.someVal
main :: IO ()
main = print . someFunction . MyRecordType $ 3
module MyRecord where
data MyRecordType = MyRecordType { someVal :: Int }
@adituv

adituv commented Feb 19, 2015

Copy link
Copy Markdown
Author

For more information on record punning, see GHC user's guide, section 7.3.15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment