News aggregator

How to approach implementing imperative algorithms functionally?

Haskell on Reddit - Mon, 04/13/2015 - 8:49pm

Recently, I experimented with implementing Eugene Myers' "diff algorithm". The same algorithm that the well known UNIX diff program is based on.

Working through the paper, I got to a part where pseudo-code was presented that was very imperative in nature. It relied on nested loops, calculating based on an array that was written and rewritten repeatedly and using values based on array indices and associated values. It was not obvious to me how to translate this into a functional implementation.

In general, is translating imperative algorithms to functional implementations supposed to be straightforward or non-straightforward? Are there rules of thumb to follow or must each algorithm's functional expression be worked out individually?

And specifically for the pseudo-code linked above, what would be a good way to structure the code to implement it?

submitted by stasiana
[link] [53 comments]
Categories: Incoming News

LOLA 2015: Second Call for Talk Proposals

General haskell list - Mon, 04/13/2015 - 5:29pm
SECOND CALL FOR TALK PROPOSALS ______________________________________________________________________ LOLA 2015: Syntax and Semantics of Low Level Languages Sunday, 5 July 2015, Kyoto, Japan A satellite workshop of ICALP/LICS http://lola15.tcs.ifi.lmu.de ______________________________________________________________________ /Important Dates/ Abstract submission: Monday, 20 April 2015 Author notification: Friday, 1 May 2015 LOLA 2015 workshop: Sunday, 5 July 2015 /Invited Speakers/ Katsuhiro Ueno, Tohoku University, Japan Other invited speakers to be announced. /Workshop Description/ It has been understood since the late 1960s that tools and structures arising in mathematical logic and proof theory can usefully be applied to the design of high level programming languages, and to the development of reasoning principles for such languages. Yet low level languages, such as machine code, and the compilation of high level languages into a low level ones have traditionally been seen as having little
Categories: Incoming News

Why no Floating instance for Data.Fixed /Data.Fixed.Binary

haskell-cafe - Mon, 04/13/2015 - 4:31pm
I'm wondering why the decision was made not to have a Floating instance for Data.Fixed. I understand that -- being a fixed point number type -- it doesn't line up with the name of the Floating typeclass. But it also seems that Floating is misnamed, because none of the functions there really have anything to do with floating point representation. This is why we still have Floating instances for, say, exact reals or symbolic numbers, neither of which has a floating point representation. It seems that the actual criterion for membership in Floating is something like "has a canonical choice for degree of approximation". Double and Float are in because we round to the nearest value. Exact reals are in because we don't have to approximate, symbolic numbers too. Rational is out because there's no clear choice of how to approximate. But by this criterion, Data.Fixed should be in. And indeed it would be useful for it to be in. If I choose to represent values from the real world by a fixed point approximation inst
Categories: Offsite Discussion

Improvements to package hosting and security

haskell-cafe - Mon, 04/13/2015 - 11:02am
Many of you saw the blog post Mathieu wrote[1] about having more composable community infrastructure, which in particular focused on improvements to Hackage. I've been discussing some of these ideas with both Mathieu and others in the community working on some similar thoughts. I've also separately spent some time speaking with Chris about package signing[2]. Through those discussions, it's become apparent to me that there are in fact two core pieces of functionality we're relying on Hackage for today: * A centralized location for accessing package metadata (i.e., the cabal files) and the package contents themselves (i.e., the sdist tarballs) * A central authority for deciding who is allowed to make releases of packages, and make revisions to cabal files In my opinion, fixing the first problem is in fact very straightforward to do today using existing tools. FP Complete already hosts a full Hackage mirror[3] backed by S3, for instance, and having the metadata mirrored to a Git repository as well is not a d
Categories: Offsite Discussion

Static executables in minimal Docker containers

haskell-cafe - Mon, 04/13/2015 - 9:54am
I'm trying to put together a minimal Docker container consisting of nothing but GHC-compiled static executables. Below you can see a full interaction I've had with GHC and Docker. The high level summary is that: * When compiled statically, the executable runs just fine in both my host OS (Ubuntu 14.04) and an Ubuntu 14.04 Docker image * That same executable run from a busybox (or a "scratch" image, not shown here since it's slightly longer to set up) hangs and then runs out of memory I've watched the process in top, and it uses up a huge amount of CPU and memory. I get the same behavior whether I compiled with or without optimizations or the multithreaded runtime. I also get identical behavior with both GHC 7.8.4 and 7.10.1. I'm not sure how best to proceed with trying to debug this, any suggestions? vagrant< at >vagrant-ubuntu-trusty-64:~/Desktop$ cat > hello.hs <<EOF main :: IO () main = putStrLn "Static Hello" EOF vagrant< at >vagrant-ubuntu-trusty-64:~/Desktop$ ghc -optl-static -optl-pthread hello.hs -static [
Categories: Offsite Discussion

If n-tuples were just nested pairs

Haskell on Reddit - Mon, 04/13/2015 - 8:47am

I've been mulling over this thought for a while. I know that Haskell is not like this, but it seems like it would have been a design improvement, and I've never seen it explicitly mentioned before. What if n-tuples (triples, quadruples, etc.) where just syntactic sugar for nested tuples? Roughly speaking:

type (a,b,c) = (a,(b,c)) -- or maybe even ((a,b),c) type (a,b,c,d) = (a,(b,(c,d))) -- etc.

You could make it associate in the other direction instead if you wanted and then you would get the formulation in my comment. That is not a super important point here. Nesting works out better for typeclasses and currying (particularly for multiple arguments, as in uncurry . uncurry . uncurry), and you could still get the aesthetic benefit of not having so many parentheses. Anyway, if anyone else has thought about this or has any thoughts on downsides to this, I would enjoying hearing from you.

submitted by andrewthad
[link] [40 comments]
Categories: Incoming News

replicate' :: (Num i, Ord i) => i -> a -> [a] , is Ord i redundant?

Haskell on Reddit - Mon, 04/13/2015 - 4:17am

Is Ord i redundant in the following type signature?

replicate' :: (Num i, Ord i) => i -> a -> [a] submitted by tmtwd
[link] [10 comments]
Categories: Incoming News

What's the purpose of a constraint in the MonadThrow instance of Either?

Haskell on Reddit - Mon, 04/13/2015 - 1:40am

While skimming through the API of the "exceptions" package I've stumbled upon the following instance:

instance e ~ SomeException => MonadThrow (Either e) where throwM = Left . toException

What exactly does the e ~ SomeException equality constraint achieve here and how's that different from simple instance MonadThrow (Either SomeException)?

submitted by nikita-volkov
[link] [16 comments]
Categories: Incoming News

[Announcement] FLTKHS - Bindings to the FLTK GUIToolkit

haskell-cafe - Mon, 04/13/2015 - 12:53am
I'm pleased to announce the first release of Haskell bindings [1] to the FLTK GUI [2] toolkit. It now works smoothly on Windows (64-bit), Linux and Mac allowing you to create truly cross-platform native GUI applications in pure Haskell and deploy statically linked executables with no dependencies. Most of the FLTK API is covered except for a few minor widgets which I plan to get to in the next release. Motivation behind the package and installation instructions are found in the Haddocks [3]. And to get you started it ships with a number of demos. If you have any issues please report them on the Github [4] page. I'd also love any other feedback so feel free to comment here or email me at the address listed on the Hackage [5] page. Hope you enjoy! [1] https://hackage.haskell.org/package/fltkhs-0.1.0.2 [2] http://fltk.org [3] https://hackage.haskell.org/package/fltkhs-0.1.0.2/docs/Graphics-UI-FLTK-LowLevel-FLTKHS.html [4] http://github.com/deech/fltkhs [5] https://hackage.haskell.org/package/fltkhs-0.1.0
Categories: Offsite Discussion

[Announcement] FLTKHS - Bindings to the FLTK GUI Toolkit

libraries list - Mon, 04/13/2015 - 12:52am
I'm pleased to announce the first release of Haskell bindings [1] to the FLTK GUI [2] toolkit. It now works smoothly on Windows (64-bit), Linux and Mac allowing you to create truly cross-platform native GUI applications in pure Haskell and deploy statically linked executables with no dependencies. Most of the FLTK API is covered except for a few minor widgets which I plan to get to in the next release. Motivation behind the package and installation instructions are found in the Haddocks [3]. And to get you started it ships with a number of demos. If you have any issues please report them on the Github [4] page. I'd also love any other feedback so feel free to comment here or email me at the address listed on the Hackage [5] page. Hope you enjoy! [1] https://hackage.haskell.org/package/fltkhs-0.1.0.2 [2] http://fltk.org [3] https://hackage.haskell.org/package/fltkhs-0.1.0.2/docs/Graphics-UI-FLTK-LowLevel-FLTKHS.html [4] http://github.com/deech/fltkhs [5] https://hackage.haskell.org/package/fltkhs-0.1.0
Categories: Offsite Discussion

Function Currying Question

Haskell on Reddit - Sun, 04/12/2015 - 11:16pm

Is it always true that func a = func2 a can be reduced to func = func2 Or bar a b = foo a b can be reduced to bar = foo?

And this is because of the way functions are curried?

EDIT: some typos

submitted by tmtwd
[link] [12 comments]
Categories: Incoming News

Question From Learn You A Haskell For Good (Kinds and types)

Haskell on Reddit - Sun, 04/12/2015 - 9:26pm

data Frank a b = Frank {frankField :: b a} deriving (Show)
The writer says this has a kind of: * -> (* -> *) - > *

The first represents the a, the (* -> *) represents the b. So what does the last * represent?

submitted by tmtwd
[link] [7 comments]
Categories: Incoming News

Compilation time with cabal under Windows

Haskell on Reddit - Sun, 04/12/2015 - 5:30pm

I've been wondering: how fast "should" ghc/cabal work?

I'm installing lens-4.9 with cabal 1.20.0.6 and GHC 7.8.3 in a fresh sandbox right now and the process has been running for about 3.5 hours, at 100% CPU usage (quad-core i7). Granted, lens installs transformers and friends, but is it really supposed to take this long, or is something wrong with my setup? Deleting the .cabal-folder/reinstalling the Haskell platform hasn't helped.

Has anyone else had this problem? Is compilation perhaps faster under Linux?

submitted by ForTheFunctionGod
[link] [14 comments]
Categories: Incoming News

beginner Q: how do you tell how well-maintained a library is?

Haskell on Reddit - Sun, 04/12/2015 - 4:33pm

As a beginner, there's a huge number of packages to wade through and it's often difficult to tell what's well-maintained vs. what's abandoned. How do you go about figuring out which packages are being actively used and developed vs. abandoned?

submitted by klaxion
[link] [24 comments]
Categories: Incoming News

Haskell IDE on Windows (source editing; project preparation and compiling/building)

Haskell on Reddit - Sun, 04/12/2015 - 12:39pm

I'm learning C++ at college ATM and using Visual Studio. Needless to say, it's a breeze; I only ever have to worry about the code and the dependencies between files. Everything else just works.

So I've become quite interested, very recently, in Haskell. In FP in general. Started out with messing with F# a bit and it intrigued me. Read around, went ahead and installed the Haskell Platform, and now I'm supremely stuck.

I can load/run separate .hs files through GHCi/runhaskell but otherwise, nothing works. Tried setting up several plugins, the last being several IntelliJ ones, but I can't for the life of me figure out how project handling works. Some sources speak of GHC and Cabal different build environments, of manually written make files and stuff like that...

I've yet to find a tutorial speaking a language I can understand. Using cabal init fails on the 3rd step with "Error: cabal: git: no source" or something like that.

Thanks a lot.

submitted by Enamex
[link] [44 comments]
Categories: Incoming News

Why there isn't a Pure typeclass ?

Haskell on Reddit - Sun, 04/12/2015 - 11:50am

An Applicative is a Functor with 2 functions, one to create an instance from a value (pure) and one to zip them (through <*>). However, I'm sure they are functors for which pure makes sense, but <*> doesn't. As now Applicative is a superclass of Monad, it would have make sense to also introduce a Pure class just defining pure?.

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