Nested Lambdas in wxHaskell Library
Posted
by
kunkelwe
on Stack Overflow
See other posts from Stack Overflow
or by kunkelwe
Published on 2012-11-17T22:28:01Z
Indexed on
2012/11/17
23:01 UTC
Read the original article
Hit count: 170
I've been trying to figure out how I can make staticText elements resize to fit their contents with wxHaskell. From what I can tell, this is the default behavior in wxWidgets, but the wxHaskell wrapper specifically disables this behavior. However, the library code that creates new elements has me very confused. Can anyone provide an explanation for what this code does?
staticText :: Window a -> [Prop (StaticText ())] -> IO (StaticText ())
staticText parent props
= feed2 props 0 $
initialWindow $ \id rect ->
initialText $ \txt -> \props flags ->
do t <- staticTextCreate parent id txt rect flags {- (wxALIGN_LEFT + wxST_NO_AUTORESIZE) -}
set t props
return t
I know that feed2 x y f = f x y
, and that the type signature of initialWindow is
initialWindow :: (Id -> Rect -> [Prop (Window w)] -> Style -> a) -> [Prop (Window w)] -> Style -> a
and the signature of initialText is
initialText :: Textual w => (String -> [Prop w] -> a) -> [Prop w] -> a
but I just can't wrap my head around all the lambdas.
© Stack Overflow or respective owner