News aggregator

How are polymorphic numeric functions implemented?

Haskell on Reddit - Fri, 08/08/2014 - 2:08pm

Are numbers boxed with a vtable for looking up functions at runtime or since Haskell knows the concrete types at runtime (I think?), is it like C++ templates where a copy of each function is created for each concrete type that is needed? If it's the latter, if you had a gigantic program and right at the beginning it "switched" on a value you read in from the user into branches for X different number types, would your executable be X times bigger? Like switch(user input){ case 1: longCalculation (read n :: Double) ; case 2: longCalculation (read n :: Integer) ... etc. } This has no relevance to anything, just weird curiousity.

submitted by chromaticburst
[link] [17 comments]
Categories: Incoming News

Brent Yorgey: Maniac week

Planet Haskell - Fri, 08/08/2014 - 1:43pm

Inspired by Bethany Soule (and indirectly by Nick Winter, and also by the fact that my dissertation defense and the start of the semester are looming), I am planning a “maniac week” while Joyia and Noah will be at the beach with my family (I will join them just for the weekend). The idea is to eliminate as many distractions as possible and to do a ton of focused work. Publically committing (like this) to a time frame, ground rules, and to putting up a time-lapse video of it afterwards are what actually make it work—if I don’t succeed I’ll have to admit it here on my blog; if I waste time on Facebook the whole internet will see it in the video; etc. (There’s actually no danger of wasting time on Facebook in particular since I have it blocked, but you get the idea.)

Here are the rules:

  • I will start at 6pm (or thereabouts) on Friday, August 8.
  • I will continue until 10pm on Wednesday, August 13, with the exception of the morning of Sunday, August 10 (until 2pm).
  • I will get at least 7.5 hours of sleep each night.
  • I will not eat cereal for any meal other than breakfast.
  • I will reserve 3 hours per day for things like showering, eating, and just plain resting.  Such things will be tracked by the TagTime tag “notwork”.
  • I will spend the remaining 13.5 hours per day working productively. Things that will count as productive work:
    • Working on my dissertation
    • Course prep for CS 354 (lecture and assignment planning, etc.) and CS 134 (reading through the textbook); making anki decks with names and faces for both courses
    • Updating my academic website (finish converting to Hakyll 4; add potential research and independent study topics for undergraduates)
    • Processing FogBugz tickets
    • I may work on other research or coding projects (e.g. diagrams) each day, but only after spending at least 7 hours on my dissertation.
  • I will not go on IRC at all during the week.  I will disable email notifications on my phone (but keep the phone around for TagTime), and close and block gmail in my browser.  I will also disable the program I use to check my UPenn email account.
  • For FogBugz tickets which require responding to emails, I will simply write the email in a text file and send it later.
  • I may read incoming email and write short replies on my phone, but will keep it to a bare minimum.
  • I will not read any RSS feeds during the week.  I will block feedly in my browser.
  • On August 18 I will post a time-lapse video of August 8-13.  I’ll probably also write a post-mortem blog post, if I feel like I have anything interesting to say.
  • I reserve the right to tweak these rules (by editing this post) up until August 8 at 6pm.  After that point it’s shut up and work time, and I cannot change the rules any more.

And no, I’m not crazy. You (yes, you) could do this too.

Categories: Offsite Blogs

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

Dealing with encodings

haskell-cafe - Tue, 08/05/2014 - 1:00pm
Hello! How teach hxt to handle "KOI8-R" encoding of input file? And it seems that so many great packages (like hxt, feed, curl) uses String. Is it some work in progress to port them to Text? -- Best regards, Dmitry Bogatov <KAction< at >>, Free Software supporter, esperantisto and netiquette guardian. GPG: 54B7F00D _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >
Categories: Offsite Discussion

Applicative & Monad as interaction between categories

haskell-cafe - Tue, 08/05/2014 - 9:46am
Hi all, I recently came across of two blog posts[1][2] by Gabriel Gonzales where he shows motivation for writing compositional functions -- and thus why the concept of category is useful -- and motivation to write functors between them. I wanted to know if something similar for has been done to `Applicative' and `Monad' as design pattern and interaction between categories. I've searching but I always hit the Monad tutorials and more info on how to use them. Thanks in advance. Excuse my English. [1]: [2]:
Categories: Offsite Discussion

Building network without MSYS [Was: Splitting Network.URI from the network package]

libraries list - Mon, 08/04/2014 - 9:52pm
Hello. I consider the original proposal to be well founded and I support it. However, I started to think if there is anything we can improve about installation of network package itself? Maybe we can get rid of MSYS, at least for the end users of network package? How would that happen? The following plan came to my mind: 1. Select a single supported configuration (Windows version) 2. Execute a "normal" build with MSYS 3. Extract a configuration that was "discovered" by MSYS 4. Bake in the configuration into installation files to be used on Windows when MSYS is not present. There shouldn't be that many supported configurations on Windows. I think it is reasonable to do: 1. Windows XP 2. Windows 7 3. Windows 8 4. some Windows Server versions? For each system the variants would be: 1. 32-bit system, 32-bit GHC 2. 64-bit system, 32-bit GHC 3. 64-bit system, 64-bit GHC Right now I have done the procedure above for my own 64-bit Windows 7/32-bit GHC pair. I also added some simple logic of choosing between "Sim
Categories: Offsite Discussion

[ANN] StrappedTemplates - general purpose templates

haskell-cafe - Mon, 08/04/2014 - 6:40pm
Hello all, I found that I wasn't quite satisfied by the template offerings (Heist, Hastache, Shakespearean, etc..) of Haskell, so I built my own. The goal is to have simple syntax that non-haskellers would be comfortable using, resembles templates found in other languages (Jinja, Django, etc) and an interface to render them that I don't have to think very hard to use. Features include inheritance, logic, includes, functions, and relatively speedy rendering (much faster than interpreted templates like Heist-I and Hastache) . Its very much a work in progress, but I felt that it was enough for an initial release and get general feedback on it. Comments are appreciated. One thing that I want to improve is how functions are handled in the template and in the "InputBucket", extend the syntax to allow you to do more inside the template and be able to define your own block functions. These will probably be added next major release.
Categories: Offsite Discussion

New Functional Programming Job Opportunities

haskell-cafe - Mon, 08/04/2014 - 5:00pm
Here are some functional programming job opportunities that were posted recently: Pragmatic Haskell Developer at Anchor Systems Cheers, Sean Murphy
Categories: Offsite Discussion

"Standardising" Haskell AST for tooling

haskell-cafe - Sun, 08/03/2014 - 8:27pm
Hi all I am looking at updating HaRe for GHC 7.8.3, and I am fighting my way through the AST changes. One of the things I have had at the back of my mind for a while is to use something like Kure universes or more generally lens to provide a set of isomorphisms from the various flavours of AST into some kind of standardised internal representation, allowing easier tool manipulation. This could potentially decouple the tools from the specific compiler/analyzer, so they could work across GHC 7.6.x, GHC 7.8.x, haskell-src-exts, haste, etc.. Obviously there would be limitations to this where an advance in the language brings in new features, but a lot of useful tool work can be done that does not touch the new stuff. I don't know if anything similar is planned in either ghc-server or another toolchain. My haskell-token-utils is a first limited attempt to bring source code round tripping to a variety of backends, but a more general solution to the AST phase would help tooling in general So, is this worth d
Categories: Offsite Discussion

[ANN] Hayoo Relaunch

haskell-cafe - Sun, 08/03/2014 - 2:13pm
Hi Cafe, Hayoo <> has been relaunched. Hayoo is a search engine for Hackage packages, which allows you to search for functions, data types and packages. It is currently work in progress. Any feedback is greatly appreciated! Hayoo uses Hunt <> for indexing and searching, which is the successor of Holumbus. Hunt is a flexible, lightweight search platform with a powerful query language and JSON API. Example search requests are: * Function names: map <> * Function signatures: (a->b)->f a->f b <> * Module names: Control.Loop <> Have a look at the examples on <> for some advances queries. The old Hayoo and Holumbus are still online at <>
Categories: Offsite Discussion

haskell-cafe - Sun, 08/03/2014 - 1:52pm
Thinks always break on the weekend, don’t they! Apologies if this is a scheduled outtake. In the meantime, there’s fortunately a Haddock mirror on ;-) Cheers, Tim
Categories: Offsite Discussion