News aggregator

Question regarding performance

Haskell on Reddit - Tue, 01/05/2016 - 6:41am

I am writing a parser for email's headers with attoparsec. But while trying to optimize this code I stumble upon several questions that I cannot answer by myself.

So naturally I am looking for the help of the community.

  • Is function call cheap in haskell ? Because when displaying cost center with +RTS -p two near function's calls in the code seem pretty distant in time. (in a flamegraph you can detect that with huge gap between each step of the call stack). Inlining function seems to overcome most of this not solicited overhead.

  • Is it possible to see strictness in Haskell/GHC ? Often time I want to see at a certain point in the program (at runtime), what have been evaluated or not. Is there an equivalent of traceShow but for strictness ? This traceStrict will (without forcing any evaluation) recursively show the state of a variable (thunks, WHNF, NF, ...) Most of the time I am trying to guess around and add some $!, (or just adding it everywhere and see if it's making a difference). Or is it possible to use ghc to dump intermediate representation to see this at compile time ?

  • Why MonoTraversable is faster than Traversable ? I tend to use classyPrelude everywhere in my programs in replacement for prelude. By default classyPrelude uses functions from MonoTraversable instead of Traversable. For a reason that I cannot explain the Monoidic version seems faster. What is the benifit of adding the Monoid constraint instead of just using the Generic version ?

  • What's the difference between

This

func = do ... toto where toto = do ...

and

toto = do .... func = do ... toto

For me there is none, but when I changed the first version for the later one. Performance seemed to improve for unknown reasons.

Any explanation will be welcome :)

Compilation of answers
  • Is function call cheap in haskell ?

Look at tibbe answer

  • Is it possible to see strictness in Haskell/GHC ?

MaxGabriel

In GHCi you can use :sprint to print a variable without forcing its evaluation. I think if you stop the program in the GHCi debugger you should be able to then check if a value is a thunk or not

It's the perfect solution for me

tibbe

Look at the intermediate output (-ddump-simpl) you can see if e.g. arguments are passed unboxed (e.g. Int#) or boxed (e.g. Int)

It's works but the dump is really tedious to read (at least with my current knowledge)

edsko

Understanding the RealWorld

For more information about the runtime behavior

  • What's the difference between

ephrion

Top level functions are more likely to get inlined and memoized than where functions IIRC.

submitted by erebe
[link] [11 comments]
Categories: Incoming News

How do I read/debug build errors?

Haskell on Reddit - Tue, 01/05/2016 - 1:19am

Compared to Python/Java/C++, I find it really hard to read Haskell build errors. Does anyone have tips on how I could understand errors better?

submitted by Maplicant
[link] [8 comments]
Categories: Incoming News

Zero config, no server Haste.App

Haskell on Reddit - Mon, 01/04/2016 - 11:30pm
Categories: Incoming News

Compose Conference Call for Participation [NYC,Feb 4-5]

haskell-cafe - Mon, 01/04/2016 - 8:50pm
=============================================== Call for Participation Compose Conference 2016 February 4-5, 2016 New York, NY http://www.composeconference.org/ =============================================== The practice and craft of functional programming :: Conference Compose is a conference for typed functional programmers, focused specifically on Haskell, OCaml, F#, SML, and related technologies. Typed functional programming has been taken up widely, by industry and hobbyists alike. For many of us it has renewed our belief that code should be beautiful, and that programming can be as enjoyable as it is practical. Compose is about bringing together functional programmers of all levels of skill and experience — from technical leads to novices, and from long-time hackers to students just getting started. It will feature a keynote by Eugenia Cheng on her work popularizing mathematics, two days of great talks, and plans are underway for a weekend hackathon/unconference. * Invited Talks: Eugenia C
Categories: Offsite Discussion

"Hask" anything, New Years edition! The thread where you ask and we try to answer!

Haskell on Reddit - Mon, 01/04/2016 - 6:15pm

If your question wasn't answered last time feel free to ask again! (Sometimes it's just a matter of getting the right person to see your question.)

Here is a link to the previous thread: https://www.reddit.com/r/haskell/comments/3uvf4p/hask_anything_the_thread_where_you_ask_and_we_try/

Looking for questions to answer? Try sorting by new.

submitted by dagit
[link] [66 comments]
Categories: Incoming News

Spurious memory leak example from the wiki

haskell-cafe - Mon, 01/04/2016 - 4:26pm
I can't get the two examples (sum/product) in: https://wiki.haskell.org/Memory_leak#Holding_a_reference_for_a_too_long_time to behave differently under O2 or O0. Same profile report each time. Have changes to prelude (FTP? Rewrite rules/build stuff for folds?) made these do the same thing? The foldl/foldl' examples behave the same as you might expect. (216mb vs. 1mb of heap) --- Chris Allen _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Categories: Offsite Discussion

Is there any hope to see the "import problem" solved ?

Haskell on Reddit - Mon, 01/04/2016 - 3:11pm

I've been switching to Haskell as my main language for about 2 years now, and I think I'm pretty much up to speed with any scripting languages I used to use before. However, what is still killing me (and slowly me down) is the import process. For example, I'm writing a simple script which parse two (using cassava), compare them (these), and display them (tabular). Adding to that, the standard monad, maybe , monoid etc I end up with the following import section

import qualified Data.ByteString.Lazy as BL import Data.Char (toLower, ord) import Data.Csv import Data.List.Split (splitOn) import Data.Maybe (catMaybes) import Data.Monoid import System.Environment (getArgs) import Control.Monad import Control.Applicative import Data.String (fromString) import Data.Map(Map) import qualified Data.Map as Map import Data.Maybe import Data.Traversable (traverse) import Options.Applicative as Opt import Data.Align (align) import Data.These import Text.Regex.PCRE((=~~)) import Text.Regex(subRegex, mkRegex) import Text.Tabular as Table import qualified Text.Tabular.Ascii as Ascii

Not mentioning adding all the libraries to the cabal file. All of that is is somehow ridiculous for a 10 (ok 50) line script. If there is one feature in Haskell which I would like to see in the "new-haskell" is the "import problem". Is there any hope that it will be sorted somehow ? The solution I can see are

- extension allowing to alias group of import into one - template haskell allowing to declare import allowing import group alias - a community effort to propose "currated" group of libraries. - something else

I could of course write my own "prelude" and push it on hackage, but if everybody do that, hackage will become cluttered unless the community agreed on a naming scheme like Prelude.maxigit or User.maxigit ...

Am I the only one having this problem and if not how do you solve it ?

submitted by maxigit
[link] [46 comments]
Categories: Incoming News

apfelmus: FRP — Release of reactive-banana version 1.1

Planet Haskell - Mon, 01/04/2016 - 3:07pm

Happy New Year, everyone! I’m pleased to announce the release of version 1.1.0.0 of my reactive-banana library on hackage.

This is essentially a maintenance release that fixes an important type mistake. Atze van der Ploeg has kindly pointed out to me that the switchB and switchE combinators need to be in the Moment monad

switchB :: Behavior a -> Event (Behavior a) -> Moment (Behavior a) switchE :: Event (Event a) -> Moment (Event a)

This is necessary to make their efficient implementation match the semantics.

Apart from that, I have mainly improved the API documentation, adding graphical figures to visualize the main types and adding an introduction to recursion in FRP. Atze has also contributed a simplified implementation of the model semantics, it should now be much easier to digest and understand. Thanks!

The full changelog can be found in the repository. Happy hacking!

Categories: Offsite Blogs

Call for Papers (TASE 2016)

General haskell list - Mon, 01/04/2016 - 1:09pm
10th International Symposium on Theoretical Aspects of Software Engineering Call for Papers TASE 2016 July 17-19, 2016, Shanghai, China http://tase2016.ecnu.edu.cn * We are pleased to announce that the authors of selected papers will be invited after the symposium to submit an extended version to a special issue at Science of Computer Programming (SCP). * Important dates Abstract research paper 10 January 2016 Submission research paper 17 January 2016 Author notification 20 March 2016 Camera ready copy 10 April 2016 * Objectives and scope TASE is an international symposium that aims to bring together researchers and developers from academia and industry with interests in the theoretical aspects of software engineering. Modern society is increasingly dependent on software systems that are becoming larger and more complex. This poses new challenges to current software
Categories: Incoming News

Accounting data structure problem

Haskell on Reddit - Mon, 01/04/2016 - 12:22pm

Hello,

I try to make a simple accounting programm in Haskell.

Now I have to problem I cannot figure out.

I can make a custom data type for a account like this ;

data Account = Account { accountNumber :: Accountnumber , accountname :: Accountname, accountBalance :: Integer }

but how can I inplement multiple accounts who all have a seperate name and a seperate balance

IN the future when this willl be a web application . it's must be easily that the user can make and name her/his own accounts.

submitted by wobbenr
[link] [4 comments]
Categories: Incoming News

What's the major benefit of everything being immutable, anyway?

Haskell on Reddit - Mon, 01/04/2016 - 11:31am

I was discussing Haskell with a friend today, and tried to explain to him why immutability was great to make thread-safe applications, and how wrapping I/O or randomness in a monad allowed a clear indicator of when this sort of "behind the scenes" behavior was ocurring.

I kept finding myself struggling to find solid arguments to why an immutable language was actually a benefit rather than a hurdle, with him arguing that "of course you can make a language idiot proof, but you could also just teach programmers to not do idiotic things, such as modifying global state".

So what IS the actual benefit of having a (mostly) immutable language, anyway?

submitted by MeanLittleBunny
[link] [25 comments]
Categories: Incoming News

Call for Papers (UTP 2016)

General haskell list - Mon, 01/04/2016 - 6:04am
Call for Papers UTP 2016 6th International Symposium on Unifying Theories of Programming June 4–5, 2016, Reykjavík, Iceland, Co-located with iFM 2016 http://utp2016.ecnu.edu.cn Overview Interest in the fundamental problem of the combination of formal notations and theories of programming has grown consistently in recent years. The theories define, in various different ways, many common notions, such as abstraction, refinement, choice, termination, feasibility, locality, concurrency and communication. Despite these differences, such theories may be unified in a way which greatly facilitates their study and comparison. Moreover, such a unification offers a means of combining different languages describing various facets and artifacts of software development in a seamless, logically consistent way. Hoare and He's Unifying Theories of Programming (UTP) is widely acknowledged as one of the most s
Categories: Incoming News

LSFA 2016 - First Call for Papers

General haskell list - Mon, 01/04/2016 - 1:28am
(Apologies for multiple copies of this announcement) ============================================================== 11th Workshop on Logical and Semantic Frameworks, with Applications 25-26 June 2016, Porto, Portugal Satellite event of FSCD 2016 http://lsfa2016.mat.unb.br/ <http://lsfa2016.mat.unb.br/> Logical and semantic frameworks are formal languages used to represent logics, languages and systems. These frameworks provide foundations for the formal specification of systems and programming languages, supporting tool development and reasoning. LSFA 2016 aims to be a forum for presenting and discussing work in progress, and therefore to provide feedback to authors on their preliminary research. The proceedings are produced after the meeting, so that authors can incorporate this feedback in the published papers. LSFA 2016 will be a satellite event of FSCD 2016 taking place in Porto, Portuga
Categories: Incoming News