Documentation for (&&) and (&&) states that they are lazy in their second argument...
[ghc.git] / testsuite / tests / typecheck / should_compile / Tc170_Aux.hs
1 {-# OPTIONS_GHC -fno-warn-redundant-constraints #-}
2
3 module Tc170_Aux where
4
5 class ReadMode mode
6
7 data Attr m w a = Attr (w -> IO a) (w -> a -> IO ())
8
9 mapAttr :: ReadMode m => (a -> b) -> (a -> b -> a) -> Attr m w a -> Attr m w b
10 mapAttr get set (Attr getter setter)
11 = Attr (\w -> do a <- getter w; return (get a))
12 (\w b -> do a <- getter w; setter w (set a b))
13
14
15 data Rect = Rect
16 data Point = Point
17 topLeft = undefined
18 rectMoveTo = undefined
19
20 class Dimensions w where
21 frame :: ReadMode m => Attr m w Rect
22
23 position :: ReadMode m => Attr m w Point
24 position = mapAttr (\f -> topLeft f) (\f p -> rectMoveTo p f) frame
25