Skip to content

Instantly share code, notes, and snippets.

@boj
Created April 9, 2020 19:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boj/f1de233d99a6e5fa2a90645bd23a239d to your computer and use it in GitHub Desktop.
Save boj/f1de233d99a6e5fa2a90645bd23a239d to your computer and use it in GitHub Desktop.
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TemplateHaskell #-}
module Main where
import Control.Lens
import GHC.Generics
data Foo
= Foo
{ fooField1 :: Int
, fooField2 :: Int
} deriving (Generic, Show)
makeFields ''Foo
data Bar
= Bar
{ barField1 :: Float
, barField2 :: Float
} deriving (Generic, Show)
makeFields ''Bar
main :: IO ()
main = do
let f = Foo 1 2
let b = Bar 1 2
print (view field1 f)
print (view field1 b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment