Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Re: Crash Course for C++ "Refugees"? (Dimitri DeFigueiredo)
2. Re: Crash Course for C++ "Refugees"? (Henk-Jan van Tuyl)
3. Re: Too much mapM, fmap and concat (Frerich Raabe)
----------------------------------------------------------------------
Message: 1
Date: Wed, 13 Aug 2014 13:21:57 -0600
From: Dimitri DeFigueiredo <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Crash Course for C++ "Refugees"?
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"; Format="flowed"
I think the last part of "Tackling the Awkward Squad" is a good intro to
the foreign function interface.
http://research.microsoft.com/en-us/um/people/simonpj/papers/marktoberdorf/
Dimitri
Em 13/08/14 11:19, Frank escreveu:
> Hi,
> I have recently been introduced to Haskell and find it quite
> fascinating. I am interested in incorporating it into a C++ project on
> which I am working, porting pieces of that program to Haskell when
> practical. Is Anyone able to point Me in the direction of a "crash
> course" or "quick start" guide for Anyone used to programming in C++
> seeking to call Haskell code from the C++ portion and/or vice versa? I
> am especially interested in knowing how to pass information from, say,
> the C++ standard template library containers (e.g., vector, valarray,
> etc.) and into Haskell functions/methods/procedures/etc. While I might
> have missed such information when I performed a web search on the
> topic, I did not find any information to help. Any assistance in
> finding such material would be greatly appreciated.
>
> Sincerely,
> Frank D. Martinez
>
> --
> P.S.: I prefer to be reached on BitMessage at
> BM-2D8txNiU7b84d2tgqvJQdgBog6A69oDAx6
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20140813/e611e837/attachment-0001.html>
------------------------------
Message: 2
Date: Thu, 14 Aug 2014 01:02:00 +0200
From: "Henk-Jan van Tuyl" <[email protected]>
To: [email protected], Frank <[email protected]>
Subject: Re: [Haskell-beginners] Crash Course for C++ "Refugees"?
Message-ID: <op.xkjzlrr9pz0j5l@alquantor>
Content-Type: text/plain; charset=iso-8859-15; format=flowed;
delsp=yes
On Wed, 13 Aug 2014 19:19:12 +0200, Frank <[email protected]> wrote:
> Is Anyone able to point Me in the direction of a "crash course"
> or "quick start" guide for Anyone used to programming in C++ seeking to
> call Haskell code from the C++ portion and/or vice versa? I am especially
> interested in knowing how to pass information from, say, the C++ standard
> template library containers (e.g., vector, valarray, etc.) and into
> Haskell
> functions/methods/procedures/etc. While I might have missed such
> information when I performed a web search on the topic, I did not find
> any
> information to help. Any assistance in finding such material would be
> greatly appreciated.
wxHaskell uses C to bind to wxWidgets, which is written in C++. See for
instance:
https://github.com/wxHaskell/wxHaskell/blob/master/wxc/src/cpp/wrapper.cpp
A short introduction how to write a C wrapper can be found at:
http://wewantarock.wordpress.com/2012/01/12/who-is-my-community/
look for "Wrapping C++ for beginners"
Regards,
Henk-Jan van Tuyl
--
Folding@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
--
------------------------------
Message: 3
Date: Thu, 14 Aug 2014 09:39:01 +0200
From: Frerich Raabe <[email protected]>
To: <[email protected]>
Subject: Re: [Haskell-beginners] Too much mapM, fmap and concat
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8; format=flowed
On 2014-08-13 18:21, martin wrote:
> Maybe these things just lie in the nature of the problem ("process a
> number of files"). Otherwise any style suggestions
> would be much appreciated.
I think a lot of this is because you're hopping into/outof the IO monad all
the time. The first thing which caught my
eye is
result <- mapM (return . processFile) flines
...which is just
let result = map processFile flines
Seeing that you then just concatenate those entries and print them, you can
drop this definition altogether and merge it
with the next line so that it says
mapM_ putStrLn (concatMap processFile flines)
The next thing I noticed isthat your nameAndContent function un-wraps the
result of "fmap lines $ readFile fn" only
to then wrap it again:
nameAndContent fn = do
content <- fmap lines $ readFile fn
return (fn, content)
Much like you fmap'ed "lines" on the IO [String] returned by 'readFile fn',
you can also fmap "((,) fn)" on the result. If
you also use the "<$>" alias for fmap, this becomes
nameAndContent fn = ((,) fn) . lines <$> readFile fn
--
Frerich Raabe - [email protected]
www.froglogic.com - Multi-Platform GUI Testing
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 74, Issue 9
****************************************