-
-
Save theqp/8f049861498df238f398b87c8e401fc4 to your computer and use it in GitHub Desktop.
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 Foo where | |
newtype MyData = MyData {myField :: Integer} | |
f :: MyData -> Integer | |
f MyData {myField} = myField | |
-- I want to ensure that f is called only with a variable named myField | |
-- this does work but too verbose | |
-- something like "f {myField}" would be better | |
-- "f MyData {otherField}" shows a syntax error and that is the purpose | |
foo = | |
let myField = 1; otherField = 2 | |
in f MyData {myField} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment