Last active
August 29, 2015 14:15
-
-
Save adituv/43f4c0a1789b70e0fe9a to your computer and use it in GitHub Desktop.
Qualified Record Pun
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 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 |
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
module MyRecord where | |
data MyRecordType = MyRecordType { someVal :: Int } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For more information on record punning, see GHC user's guide, section 7.3.15