News aggregator

Foldr/build fusion and reverse

libraries list - Mon, 08/11/2014 - 9:01pm
Currently, reverse does not participate at all. This law looks eminently exploitable: foldr c n (reverse xs) = foldl (flip c) n xs foldr c n $ reverse $ build xs = _______________________________________________ Libraries mailing list Libraries< at >
Categories: Offsite Discussion

Any tips on "doing it right" for a small program?

haskell-cafe - Mon, 08/11/2014 - 7:41pm
Dear reader, I'm still new to haskell, and decided to convert a simple bash script to a full-on-bells-and-whistles Haskell program (as a learning experience). As you might guess I could use some help. The program is very simple, in Bash it reads: CMDPATTERN="$< at >" while [[ "`pgrep --count --full "$CMDPATTERN"`" -gt 1 ]]; do sleep 5 done AKA: while there is a command running with the given string, loop. I called this script "after" and use it on the commandline to chain commands from different terminals. The Haskell version is available at What I have done: - Add Travis CI - Add a first test case using test-framework - Add commandline option parsing using "options" - Implement a fork-join behavior using parallel-io What I would like help with: - How to add a --version that reflects the after.cabal version? - Is there a library for what I'm doing in Process.hs (listing running processes, etc.)? - How to add "-p <pid>" support, so I can do "after -p 129 -p 402" (after bot
Categories: Offsite Discussion

New Functional Programming Job Opportunities

haskell-cafe - Mon, 08/11/2014 - 5:00pm
Here are some functional programming job opportunities that were posted recently: Big Data Engineer / Data Scientist at Recruit IT Cheers, Sean Murphy
Categories: Offsite Discussion

Updating code to work with vinyl 0.4

haskell-cafe - Mon, 08/11/2014 - 10:43am
Hi, I'm looking for some help in helping to migrate to vinyl-0.4 from earlier version. I'll first outline how I currently have things set up and then ask a few questions. For reference the whole project is at [1]. You can just skip to questions in the end if you want to. I have a small project which goes out to a few sites, fetches some similar XML data, parses some fields and returns a data type. My original attempt was to generate a data type per site but that was very ugly: couldn't reuse functions, accessors, anything. So I then turned to vinyl and have the following solution: I have a bunch of common fields defined like this: -- file_url ∷ "file_url" ::: String file_url = Field parent_id ∷ "parent_id" ::: Maybe Integer parent_id = Field -- and so on. I'm using HXT to process the XML I get from each site so I have created many HXT arrows creating each field like this: -- parent_idA ∷ (Functor (cat XmlTree), ArrowXml cat) ⇒ cat XmlTree (PlainRec '["parent_id" ::: Maybe Integer]
Categories: Offsite Discussion

WLP/WFLP - Call for Participation - September 15-17

General haskell list - Mon, 08/11/2014 - 9:17am
Call for Participation 28th Workshop on (Constraint) Logic Programming (WLP 2014) co-located with 23rd International Workshop on Functional and (Constraint) Logic Programming (WFLP 2014) Lutherstadt Wittenberg, Germany, September 15 - 17 Early registration deadline: August 26 The international workshops on functional and logic programming aim at bringing together researchers interested in functional programming, logic programming, as well as their integration. The workshops on (constraint) logic programming serve as the scientific forum of the annual meeting of the Society of Logic Programming (GLP e.V.) and bring together researchers interested in logic programming, constraint programming, and related areas like databases, artificial intelligence, and operations research. Invited Speakers: Michael Hanus: Declarative Multi-paradigm Programming (Tutorial). Sven Thiele: Answer Set Programming for Systems Biology. Accepted Papers and Preliminary Program:
Categories: Incoming News

Irritating Referential Transparency behavior?

haskell-cafe - Sun, 08/10/2014 - 7:20pm
Hello all, I came across something strange: This code compiles: ------------------------------------------------------------ data LProcess a = LP {lstep :: Writer [String] (Event a -> ([Event a], LProcess a))} ------------------------------------------------------------ exProcess2 :: ProcState -> Location -> LProcess EvtData exProcess2 pState loc = LP {lstep = xxx} where xxx = myStep pState myStep _ = return $ \(E t l _) -> ([E (t+1) l Wakeup], (proc' pState)) proc' state = exProcess2 (trc state) loc but when I replace xxx by myStep pState as in exProcess2 pState loc = LP {lstep = myStep pState} where xxx = myStep pState myStep _ = return $ \(E t l _) -> ([E (t+1) l Wakeup], (proc' pState)) proc' state = exProcess2 (trc state) loc I get No instance for (Monad m0) arising from a use of `myStep' The type variable `m0' is ambiguous Possible fix: add a type signature that fixes these type variable(s) I
Categories: Offsite Discussion

Haskell Platform 2014.2.0.0 is Released!

haskell-cafe - Sat, 08/09/2014 - 11:28pm
On behalf of the Haskell Platform team, I'm happy to announce the release of *Haskell Platform 2014.2.0.0* featuring: GHC 7.8.3 53 packages 860+ public modules 4 tools This release features a major upgrade to OpenGL and GLUT. In addition, "behind the scenes", this release of the platform is produced with a new build system, and many improvements to the installations on all three OS families. Get it now: Download Haskell Platform <> — for Windows <> — for Mac OS X <> — for Linux <> (and similar systems) N.B.: You may need to explicitly re-fresh those links when visiting in your browser - those pages tend to get cached for very long periods of time. — Mark "platform wrangler" Lentczner P.S.: I realize this one was a long time a'comin'. I take the responsibility for the decisions that lead up to being this late, including deciding it was
Categories: Offsite Discussion

ANN: immortal-0.1

haskell-cafe - Sat, 08/09/2014 - 1:57pm
I am pleased to announce the first release of the "immortal" package. Immortal allows you to create threads that never die. If the action executed by such a thread finishes or is killed by an exception, it is automatically restarted. Such a behavior is often desired when writing servers, so I decided to release a package that does exactly that. Roman _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >
Categories: Offsite Discussion

Proposal: Export Data.Word.Word from Prelude

libraries list - Sat, 08/09/2014 - 12:38pm
Hello *, Proposal -------- I hereby propose to export Haskell2010's Data.Word.Word type from the Prelude Motivation ---------- Starting with Haskell2010, "Data.Word" exporting the type 'Word', "an unsigned integral type, with the same size as 'Int'" became part of the Haskell Report. 'Word' is usually a better choice than 'Int' when non-negative quantities (such as list lengths, bit or vector indices, or number of items in a container) need to be represented. Currently however, 'Word' is at a disadvantage (with respect to 'Int') in terms of public exposure by being accessible only after an "import Data.Word". Moreover, since 'Word' is now part of the Haskell Report, libraries should attempt to avoid name-clashing with 'Word' (and if they do, it ought to be a conscious decision, which ought to be declared by a requiring a "import Prelude hiding (Word)"). While one might think 'Word' would be a popular type-name to use in Haskell code, the current level of name collision is still rather low (as is show
Categories: Offsite Discussion

Get out structured data from a C/C++ library inHaskell

haskell-cafe - Fri, 08/08/2014 - 3:34pm
Hello everybody. I'm new to the list so I'd like to say hello to you. I'm a student of computer science and early practitioner of Haskell. I've decided to implement the next project in Haskell but I need to interface a C++ library. I've read all the wikis material about the matter and I have an understanding of how FFI to C works in general. The library in question is a SAT solver for LTL formulas, and all I need to do is to be able to create the AST of the formula (Haskell will do the parsing) and pass it to the library, and then get back the reply. From the C++ point of view, the AST of the formulas consists simply of objects linked together with raw pointers. Nodes are of the same type, with an internal enum that specifies the type of node, so it's not an inheritance hierarchy or fancy things... What I would like to do is to be able to declare an algebraic data type that represents the AST and somehow mangle it to a form that can be passed to the C++ function of the library (that I can wrap into an ex
Categories: Offsite Discussion

Visualising Haskell function execution

haskell-cafe - Fri, 08/08/2014 - 6:30am
Hey all, Last weekend my friend Steve and I did a small project for visualising Haskell function execution in the browser. It's meant to be used in education, and uses a tiny custom parser. I figured it could be of interest for anyone here learning or teaching Haskell: To see it in action, scroll a bit down to the red bordered box, and click on "map", and then keep clicking on each new line. I hope it can be useful to someone. Cheers, JP _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >
Categories: Offsite Discussion

How to improve the zipwith's performance

haskell-cafe - Fri, 08/08/2014 - 4:24am
Dear All I write a code for Clustering with Data.Clustering.Hierarchical, but it's slow. I use the profiling and change some code, but I don't know why zipwith take so many time? (even I change list to vector) My code is as blow, Any one kindly give me some advices. ====================== main = do .... let cluster = dendrogram SingleLinkage vectorList getVectorDistance .... getExp2 v1 v2 = d*d where d = v1 - v2 getExp v1 v2 | v1 == v2 = 0 | otherwise = getExp2 v1 v2 tfoldl d = DV.foldl1' (+) d changeDataType:: Int -> Double changeDataType d = fromIntegral d getVectorDistance::(a,DV.Vector Int)->(a, DV.Vector Int )->Double getVectorDistance v1 v2 = fromIntegral $ tfoldl dat where l1 = snd v1 l2 = snd v2 dat = DV.zipWith getExp l1 l2 ======================================= build with ghc -prof -fprof-auto -rtsopts -O2 log_cluster.hs run with log_cluster.exe +RTS -p profiling result is log_cluster.exe +RTS -p -RTS total time =
Categories: Offsite Discussion

[ANN] rtorrent-state

haskell-cafe - Thu, 08/07/2014 - 8:07pm
Hi, rtorrent-state is a library that allows working with rtorrent state files (SOMEHASH.torrent.rtorrent) placed in your session directory. If you're an rtorrent user and ever had to manually muck around with those files, you should be able to use this library to make your life easier. For example, you can stop all torrents in your session directory with just: “overFilesIn "rtorrent/session/dir" stopTorrent” The way it works is by parsing the session files, modifying the resulting data type and serialising it back into the file. I did not do optimisation but I had no problem with test sample of 100,000 files. I need to add IOException handling and maybe extra utility functions but otherwise I consider the library finished. Thanks
Categories: Offsite Discussion

Performance of StateT and best practices fordebugging

haskell-cafe - Thu, 08/07/2014 - 6:57pm
Hello, I was looking at cleaning up my refactoring a core loop of template rendering to go from a loop with many parameters loop :: RenderConfig -> BlockMap -> InputBucket m -> Builder -> [Pieces] -> ExceptT StrapError m Builder to a looped state monad transformer loop :: [Pieces] -> RenderT m Builder newtype RenderT m a = RenderT { runRenderT :: ExceptT StrapError (StateT (RenderState m) m) a } deriving ( Functor, Applicative, Monad, MonadIO ) data RenderState m = RenderState { position :: SourcePos , renderConfig :: RenderConfig , blocks :: BlockMap , bucket :: InputBucket m } however, there is a big slow down (about 6-10x) using a StateT. I think it might have something to do with laziness but I am not exactly sure of where to begin in tracking it down. Swapping out the Lazy State to a Strict State helps a little (only a 5x slow down) You can find some of the processing code here:
Categories: Offsite Discussion

parsec: problem combining lookAhead with many1 (bug?)

haskell-cafe - Thu, 08/07/2014 - 3:25pm
Suppose that we have the following parser: p = lookAhead (char 'a') >> char 'b' If we use it like so parse p "" "a" we get the following error: Left (line 1, column 1): unexpected "a" expecting "b" What happened is that char 'a' succeeded by consuming the 'a' from the input and then lookAhead rewinded the input stream (as it does on success). Then, char 'b' tries to parse (again) the first character of the input and fails. Everything works as expected. Now let's slightly modify our parser: p' = lookAhead (many1 $ char 'a') >> char 'b' I've only added a many1. I was expecting this parser to give the same error as the previous one: many1 $ char 'a' will succeed consuming one 'a' and then lookAhead will rewind the input (as it does on success). Thus when we call char 'b' we are going to be in the beginning of the input again. Well, that doesn't happen: Left (line 1, column 2): unexpected end of input expecting "b" As you can see, lookAhead did not rewind the input as it was supposed to.
Categories: Offsite Discussion

Free monad based EDSL for writing LLVM programs.

haskell-cafe - Thu, 08/07/2014 - 3:16pm
Hello. I'm new with Haskell and FP, so i wanted someone to give comments on the package i've made [1]. It's, actually, my first attempt to create something more or less real, so any feedback would be welcome. I've used Free monad to create EDSL that allows writing LLVM IR code. Afterwards it could be converted into pure AST structure provided by llvm-general-pure[2] package. Currently, it supports almost every instruction, but i haven't yet come up with sensible defaults for them. Another thing that bugs me is the ability to transform the code in syb way. I want take a user-supplied function that would pattern-match instruction and produce another code block and apply this function everywhere in the code, but still can't get my head around it. I've come up with extF function, that unlike extM, would resort to wrap instead of return, but that's all i've managed to do. Thanks in advance. [1] [2] _______
Categories: Offsite Discussion

Haskell Weekly News: Issue 301

haskell-cafe - Thu, 08/07/2014 - 5:43am
Welcome to issue 301 of the HWN, an issue covering crowd-sourced bits of information about Haskell from around the web. This issue covers from July 27 to August 2, 2014 Quotes of the Week * bernalex: I used to have a problem then I used lens now I have an abstraction problem? * trap_exit: haskell is like the 'and they lived happily ever after' of programming languages Top Reddit Stories * The Comonad.Reader » Letter to a Young Haskell Enthusiast Domain:, Score: 236, Comments: 56 Original: [1] On Reddit: [2] * seL4 is now open source: the world's first end-to-end verified OS kernel Domain:, Score: 87, Comments: 20 Original: [3] On Reddit: [4] * FP Haskell Center now free for open projects Domain:, Score: 81, Comments: 23 Original: [5] On Reddit: [6] * -XOverlappingI
Categories: Offsite Discussion

cabal repl failing silently on missing exposed-modules

glasgow-user - Wed, 08/06/2014 - 3:18pm
Hi, I have just spent some time trying to figure out why all of a sudden "cabal repl" silently exits without an error message. What helped was to take a project that could launch the repl and compare the cabal files to my new project. It turns out the exposed-modules entry was missing. I was wondering whether this behaviour was intentional, as I don't recollect this happening before, but I don't have older systems to test this on. The reason I wanted to run a repl without editing exposed modules was to test some dependencies I pulled in to the sandbox with cabal install. The package in question didn't have any code of its own yet. In this case I would just expect ghci to load with the Prelude. Thanks!
Categories: Offsite Discussion

Side-by-side pretty printing

haskell-cafe - Tue, 08/05/2014 - 8:49pm
Hi all, When looking into Text.PrettyPrint, I stumbled upon <> (beside) combinator. Is it true that multi-line documents can't be printed one beside other? E.g. this let doc1 = vcat $ map text ["This", "is", "a", "document"] in doc1 <> doc1 prints this: This is a documentThis is a document As well as if I would write `doc1 <> nest 50 doc1`. What I was expecting, was This This is is a a documentdocument Do I get it right that Text.PrettyPrint was not intended for such things?
Categories: Offsite Discussion

Old code broken by new Typeable class

glasgow-user - Tue, 08/05/2014 - 5:41pm
Hi! I've been working with GHC-4.6.3, and updating to GHC-4.8.3 breaks my code, because the Typeable class has been changed. The compiler produces this message: --------- src/HsShellScript/ProcErr.chs:2294:4: ‘typeOf’ is not a (visible) method of class ‘Typeable’ --------- I want to define System.Posix.Process.ProcessStatus to be an instance of Typeable, so I can throw and catch it as an exception. ProcessStatus isn't typeable by default. Is it still possible to make ProcessStatus a member of Typeable? How? Obviously, you can't accomplish it by deriving Typeable, because the definition can't be changed any longer. This is the spot in question: ---------- import System.Posix.Process import Data.Typeable {- data ProcessStatus = Exited ExitCode / | Terminated Signal/ / | Stopped Signal/ deriving (Eq, Ord, Show) -} instance Typeable ProcessStatus where typeOf = const tyCon_ProcessStatus tyCon_ProcessStatus = mkTyConApp
Categories: Offsite Discussion