Last active
January 2, 2016 22:09
-
-
Save mxswd/8367868 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, TypeSynonymInstances, FlexibleInstances, MultiParamTypeClasses, UndecidableInstances #-} | |
module SingLens where | |
import Control.Lens | |
import SuperLens ((???), makeLensesPlus) | |
data Foo = Foo { _bar :: String, _baz :: Int } deriving Show | |
makeLensesPlus ''Foo | |
-- | f | |
-- >>> f | |
-- Foo {_bar = "four", _baz = 3} | |
f :: Foo | |
f = Foo "four" 3 | |
-- | g | |
-- >>> g | |
-- "four" | |
g :: String | |
g = view (???) f | |
-- | h | |
-- >>> h | |
-- 3 | |
h :: Int | |
h = view (???) f | |
-- | i | |
-- >>> i | |
-- Foo {_bar = "bar", _baz = 3} | |
i :: Foo | |
i = set (???) "bar" f |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment