News aggregator

Smarter way to write this little piece of code?

Haskell on Reddit - Fri, 06/12/2015 - 2:49am

Hello, I'm implementing a basic Knight's Tour path finder (Based on tuple list) and I think there should be a better way to write this, is there?:

knightJump s a b = if (plausibleJump s a b (-1) (2)) /= [] then plausibleJump s a b (-1) (2) else if (plausibleJump s a b (1) (2)) /= [] then plausibleJump s a b (1) (2) else if (plausibleJump s a b (2) (1)) /= [] then plausibleJump s a b (2) (1) else if (plausibleJump s a b (2) (-1)) /= [] then plausibleJump s a b (2) (-1) else if (plausibleJump s a b (1) (-2)) /= [] then plausibleJump s a b (1) (-2) else if (plausibleJump s a b (-1) (-2)) /= [] then plausibleJump s a b (-1) (-2) else if (plausibleJump s a b (-2) (-1)) /= [] then plausibleJump s a b (-2) (-1) else if (plausibleJump s a b (-2) (1)) /= [] then plausibleJump s a b (-2) (1) else []

PS: I'm sorry if this is some kind of eye-hurtin haskell gore. Newbie here

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

Haskell on Reddit - Fri, 06/12/2015 - 12:05am
Categories: Incoming News

Question about constraining functions to particularADT constructors

haskell-cafe - Thu, 06/11/2015 - 5:54pm
Hello there, I've been thinking on different approaches to constraint particular functions to a particular constructor of an ADT in order to reduce representation of invalid states. Say for example I've this types: data Address = Address { ... } newtype Email = Email String data Package = Package { ... } data EmailMsg = EmailMsg { ... } data User = RealUser Address | VirtualUser Email And I would like to implement two functions: deliverPackage :: User -> Package -> IO Bool sendEmail :: User -> EmailMsg -> IO () I would like to constraint both deliverPackage and sendEmail to receive only the semantically correct constructor of User. I know of an approach I could use, that is wrapping each constructor in it's own newtype, and create some smart constructor that way, that approach works, but I find it rather verbose. Is there any other well known approach to deal with this scenarios? _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at > http://mail.haskel
Categories: Offsite Discussion

7.10 branch

glasgow-user - Thu, 06/11/2015 - 5:21pm
Austin I'm getting these validation failures on the 7.10 branch. Are you? This is on Linux. Simon Unexpected failures: driver T8959a [bad stderr] (normal) ghci/scripts T9878b [bad stderr] (ghci) th T10279 [stderr mismatch] (normal) Unexpected stat failures: perf/should_run T4830 [stat not good enough] (normal) perf/should_run T7436 [stat not good enough] (normal) _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users< at >
Categories: Offsite Discussion

US Haskell Developer Position

haskell-cafe - Thu, 06/11/2015 - 4:26pm
Karamaan Group, a principal investment firm based in Manhattan, is looking for an outstanding software developer to develop tools for financial analysis and knowledge management. We are a growth oriented firm that values people who take a craftsman's pride in their work. Our ideal candidate is an experienced software developer with strong analytical, organizational, and communication skills. A candidate who demonstrates an intense focus on quality, but has the ability to recognize and make the tradeoffs that are a necessary part of day-to-day software development. Candidates should have at least a degree in a quantitative field and a keen interest in building robust and elegant computer programs. This is a high-impact, high-visibility position where successful candidates will be entrusted with a lot of responsibility for products that have a direct effect on the P&L of the firm and influences our workflow. The ideal candidate will have experience with Haskell, relational database technologies, and Java. Al
Categories: Offsite Discussion

Please help. Unable to cabal install simple libraries, like vector, boxes on OS X.

Haskell on Reddit - Thu, 06/11/2015 - 1:54pm

Has anyone else faced this?

OS X Mavericks 10.9.5

ghci version -- 7.10.1

cabal --

bash-3.2$ cabal install vector

Resolving dependencies...

Configuring vector-

Building vector-

Preprocessing library vector-

Data/Vector/Generic.hs:61:3: parse error on input ‘unsafeUpd’ Failed to install vector-

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

Syntax readability survey

Haskell on Reddit - Thu, 06/11/2015 - 1:10pm

I've been wondering what makes code syntax in one programming language more readable / fun to write than others.

I wrote two ToDo apps in pseudo-code here:

Would love your thoughts on which one feels more readable and would be more enjoyable to read/write and why. Thanks!

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

Self-Representation in Girard’s System U

Lambda the Ultimate - Thu, 06/11/2015 - 12:45pm

Self-Representation in Girard’s System U, by Matt Brown and Jens Palsberg:

In 1991, Pfenning and Lee studied whether System F could support a typed self-interpreter. They concluded that typed self-representation for System F “seems to be impossible”, but were able to represent System F in Fω. Further, they found that the representation of Fω requires kind polymorphism, which is outside Fω. In 2009, Rendel, Ostermann and Hofer conjectured that the representation of kind-polymorphic terms would require another, higher form of polymorphism. Is this a case of infinite regress?

We show that it is not and present a typed self-representation for Girard’s System U, the first for a λ-calculus with decidable type checking. System U extends System Fω with kind polymorphic terms and types. We show that kind polymorphic types (i.e. types that depend on kinds) are sufficient to “tie the knot” – they enable representations of kind polymorphic terms without introducing another form of polymorphism. Our self-representation supports operations that iterate over a term, each of which can be applied to a representation of itself. We present three typed self-applicable operations: a self-interpreter that recovers a term from its representation, a predicate that tests the intensional structure of a term, and a typed continuation-passing-style (CPS) transformation – the first typed self-applicable CPS transformation. Our techniques could have applications from verifiably type-preserving metaprograms, to growable typed languages, to more efficient self-interpreters.

Typed self-representation has come up here on LtU in the past. I believe the best self-interpreter available prior to this work was a variant of Barry Jay's SF-calculus, covered in the paper Typed Self-Interpretation by Pattern Matching (and more fully developed in Structural Types for the Factorisation Calculus). These covered statically typed self-interpreters without resorting to undecidable type:type rules.

However, being combinator calculi, they're not very similar to most of our programming languages, and so self-interpretation was still an active problem. Enter Girard's System U, which features a more familiar type system with only kind * and kind-polymorphic types. However, System U is not strongly normalizing and is inconsistent as a logic. Whether self-interpretation can be achieved in a strongly normalizing language with decidable type checking is still an open problem.

Categories: Offsite Discussion

Benchmarking two versions of the same package?

haskell-cafe - Thu, 06/11/2015 - 12:41pm
Hi -cafe, While we can easily benchmark different functions or libraries easily with criterion, I can't think of a reasonably easy (and accurate!) way of benchmarking two versions of the same package. And not necessarily version as in cabal version -- one of the use cases I have in mind would be running a benchmark suite whenever a PR gets merged to the main branch of a library, so the benchmark would need to compare the performance of the library's-code-before-merging and after. This definitely can't be accomplished with something like criterion because we can't have two different instances of a package in scope for a module, even with -XPackageImports. If we separately build the same program against two instances of the same library and run the benchmarks separately, this might happen far apart enough that the machine running this might be under a different load. This does however seem to be the only actual solution? Run separately at two different commits, diff the numbers, report. I have felt the nee
Categories: Offsite Discussion

Questions about concurrency and laziness

haskell-cafe - Thu, 06/11/2015 - 12:35pm
Hi, First of all, apologies if this is not the right place to ask this question. I'm reading the book "Parallel and concurrent programming in Haskell" and I'm having some issues reasoning about the impact of laziness. Looking at the first example in chapter 8 [1] main = do m1 <- newEmptyMVar m2 <- newEmptyMVar forkIO $ do r <- getURL "" putMVar m1 r forkIO $ do r <- getURL "" putMVar m2 r r1 <- takeMVar m1 r2 <- takeMVar m2 print (B.length r1, B.length r2) I don't understand why this function is not just putting an unevaluated thunk in the MVar. Well, I assume that getURL is an eager function, but looking at its code [2] or at the documentation of Network.Browser [3] I don't see why... Am I looking at this wrong? Is there any rule of thumb to be used in these cases? I have the impression that it's really easy to end up creating thunks in parallel threads and evaluating them in the main one... Thanks
Categories: Offsite Discussion

Is there a way to ensure I can't call a function with arguments in the wrong order?

Haskell on Reddit - Thu, 06/11/2015 - 10:44am

I mean when all its parameters are the same type.

So if you have this:

createUser :: String -> String -> String -> User createUser firstName lastName aboutMe = fail

What are the best modern techniques for ensuring I don't pass the arguments in the wrong order?

P.S. I'm aware that functions technically only have one argument, but I hope you know what I mean.

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

TH to generate imports?

haskell-cafe - Thu, 06/11/2015 - 10:12am
Hi guys, I wanted to know if it's possible to use TH on an "import" statement. What I want to do is to generate the names of the packages I need to import. For example: import $(genImport "MyPackage") genImport :: String -> Q TH.Exp genImport s = ... Is that possible? Thanks! Corentin _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >
Categories: Offsite Discussion

What are the best modern options for writing a Haskell web app?

Haskell on Reddit - Thu, 06/11/2015 - 10:08am

I guess I mean both a build tool and a framework. Something that be be bootstrapped pretty quickly.

Ideally all configuration would have sane, modern defaults, and I wouldn't touch any configuration files until I absolutely need to override something. Probably the only thing I'll ever configure is my database.

I'm a fan of rapid development, TDD, and BDD. I only want to worry about the business logic of my app, how I structure my model, and how I render things to the browser (oh, I guess that's MVC, isn't it?).

Everything else should be automatic and something I don't have to think about. I'm okay with "opinionated" tools if they allow for rapid development.

Are there any modern Haskell frameworks and build tools to let me do this?

submitted by almost_haskeller
[link] [9 comments]
Categories: Incoming News