[Haskell-beginners] Mutable collection of gui objects (wxHaskell)

emacstheviking objitsu at gmail.com
Wed Apr 1 08:44:30 UTC 2015


No wonder Haskell won't catch on... I saw code that looked just like that
on the wall of a pyramid on an episode Ancient Aliens recently!

April fool by the way!



On 31 March 2015 at 23:51, Henk-Jan van Tuyl <hjgtuyl at chello.nl> wrote:

> On Tue, 31 Mar 2015 22:11:47 +0200, Jeffrey Brown <jeffbrown.the at gmail.com>
> wrote:
>
>  It works! And I don't understand it! Particularly this line:
>>
>>   inputs <- map (\e -> [hfill $ widget e]) <$> varGet myVar
>>
>> I'm considering the type signatures:
>>   map :: (a -> b) -> [a] -> [b]
>>   (<$>) :: Functor f => (a -> b) -> f a -> f b
>>   varGet :: Var a -> IO a
>> map and <$> (fmap) are nearly synonymous; map seems like a special case of
>> fmap. I gather the fmap must be to map inside the IO type that varGet
>> returns, and the map must be mapping across some list. But what about
>> their
>> function arguments? Is map using the lambda expression, or is fmap? What
>> function argument is the other one using? Are they both somehow sharing
>> the
>> lambda expression?
>>
>
> The expression
>   f <$> x
> is equal to
>   fmap f x
> . If
>   f :: a -> b
>   x :: IO a
> then
>   fmap f :: IO a -> IO b
> . You could say, fmap lifts f to the IO monad (you could also use liftM
> for this).
>
> In your case, f is
>   map (\e -> [hfill $ widget e])
> and x is
>   varGet myVar
> You stored a list of textEntrys in myVar, the lambda expression is mapped
> over this list.
>
> Another way to look at it: you can replace the line
>   inputs <- map (\e -> [hfill $ widget e]) <$> varGet myVar
> with
>   xs <- varGet myVar
>   let inputs = map (\e -> [hfill $ widget e]) xs
>
> Regards,
> Henk-Jan van Tuyl
>
>
> --
> Folding at home
> What if you could share your unused computer power to help find a cure? In
> just 5 minutes you can join the world's biggest networked computer and get
> us closer sooner. Watch the video.
> http://folding.stanford.edu/
>
>
> http://Van.Tuyl.eu/
> http://members.chello.nl/hjgtuyl/tourdemonad.html
> Haskell programming
> --
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20150401/23ee429f/attachment.html>


More information about the Beginners mailing list