Created
April 9, 2020 19:55
-
-
Save boj/f1de233d99a6e5fa2a90645bd23a239d 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 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