Skip to content

Instantly share code, notes, and snippets.

@danidiaz
Created January 25, 2014 12:52
Show Gist options
  • Select an option

  • Save danidiaz/8615935 to your computer and use it in GitHub Desktop.

Select an option

Save danidiaz/8615935 to your computer and use it in GitHub Desktop.
Deriving a Control.Lens.Wrapped instance using Template Haskell
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
import Control.Lens
data Foo a = Foo { unFoo :: (Int,a) } deriving Show
$(makeWrapped ''Foo)
main :: IO ()
main = putStrLn ""
-- *Main> view wrapped (5,'a') :: Foo Char
-- Foo {unFoo = (5,'a')}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment