Last active
August 17, 2018 15:18
-
-
Save mmai/88fb7ceebf52c8cf44c3a6991af1a366 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 TemplateHaskell #-} | |
{-# LANGUAGE RankNTypes #-} | |
module Main where | |
import Control.Lens | |
data Game = Game { _player1 :: String } deriving (Show) | |
makeLenses ''Game | |
game = Game { _player1 = "Bob" } | |
main :: IO () | |
main = showElder | |
showElder :: IO () | |
showElder = | |
-- showPlayer $ const player1 $ () -- OK | |
showPlayer . (const player1) $ () -- NOK | |
showPlayer :: Lens' Game String -> IO () | |
showPlayer playerLens = print $ game ^. playerLens |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment