Created
December 24, 2011 06:53
-
-
Save avaitla/1516620 to your computer and use it in GitHub Desktop.
composition of lenses
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 #-} | |
import Data.Lens.Template | |
import Data.Lens.Lazy | |
data Line = Line { | |
_lnBeg :: Point | |
, _lnEnd :: Point | |
} deriving (Show) | |
data Point = Point { | |
_ptX :: Int | |
, _ptY :: Int | |
} deriving (Show) | |
$( makeLenses [''Point, ''Line] ) | |
ptX :: Lens Point Int | |
lnBeg :: Lens Line Point | |
compose = ptX . lnBeg | |
test_lens.hs:18:11: | |
Couldn't match expected type `b0 -> c0' | |
with actual type `Lens Point Int' | |
In the first argument of `(.)', namely `ptX' | |
In the expression: ptX . lnBeg | |
In an equation for `compose': compose = ptX . lnBeg | |
Failed, modules loaded: none. | |
Note: | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment