Skip to content

Instantly share code, notes, and snippets.

@mmai
Last active August 17, 2018 15:18
Show Gist options
  • Save mmai/88fb7ceebf52c8cf44c3a6991af1a366 to your computer and use it in GitHub Desktop.
Save mmai/88fb7ceebf52c8cf44c3a6991af1a366 to your computer and use it in GitHub Desktop.
{-# 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