News aggregator

ANNOUNCE: hplayground: haskell client-side webframework

haskell-cafe - Sat, 07/26/2014 - 2:34am
hplayground [1] is a haskell framework that compiles to JavaScript with the haste [5] compiler. It handles reactive effects under a applicative-monad that controls the modifications of the user interface. It is quite easy to create dynamic, composable applications using ordinary, beatiful, idiomatic haskell without special constructions. Rather than a framework, it is an EDSL. Full reinversion of control avoid spagetty event handlers and the monad confines the events and their effects to the subtree where they appear avoiding the problems of declarative reactive frameworks. There are examples running[4] the source code is in [1] And there is a todo reference application [3] running [2] too. There is also a blog post about that[7] Additionally, the syntax is almost identical to the formlet widgets in MFlow[6]. So most of the hplaygroud code could run also in a server if javascript is disabled. But MFlow and hplayground are completely independent projects. I hope that you enjoy it as much as I enjo
Categories: Offsite Discussion

Alp Mestanogullari: Write web services around databases with 0 boilerplate: announcing servant 0.1

Planet Haskell - Fri, 07/25/2014 - 6:00pm

At Zalora, we write a lot of web services and web applications in general. We use scotty a lot. And after having written a couple of web-services, despite some small handy abstractions we came up with, it really felt like we could achieve the same thing in a very concise and minimalist manner, by letting the compiler do more work for us so that we would just have to write wrapper for our SQL queries in haskell. All we had to do was to take advantage of a couple of extensions that landed in GHC in the past few years and propagate the right bits of information at the type-level. And this is what we’ve done.

The result is servant (github, hackage), which lets you declare resources, which just represent a bunch of operations (think endpoints) that operate on some type. So you could for example declare a users resource that supports adding, deleting and listing users in the following way:

mkResource "users" ctx exceptions & addWith addUser & deleteWith deleteUser & listAllWith listUsers

where:

  • ctx is just there to specify how to get our hand on our database connection for example, think of it as a withConnection function
  • exceptions is a bunch of functions that catch exceptions of various types and turns them into an error type of yours
  • addUser, deleteUser and listUsers are functions that run the corresponding SQL queries using the connection provided by ctx

And now you can turn this into a JSON-based webservice by simply applying Servant.Scotty.runResource to this simple definition. Then, provided you have written a handful of instances as required by each operation, you’ll have a small REST-y webservice with 3 endpoints that do what you expect.

The more interesting aspect of servant however is that the add, delete and listall operations just happen to be some prelude operations provided by the servant packages. You can define your own in just the same way the standard ones are defined. The same applies to the automatic JSON-based request body/response body handling or to the web-framework backend used (we only have a scotty one for now but you could write your own for any other framework by drawing some inspiration from the scotty one). You can extend servant in basically every possible direction.

If you want to learn more about servant, how it can be used and how it works, you may be interested to check out the README from github which contains some documentation links, that I’ll reproduce here:

  • Getting started with servant, which guides you through building the simple webservice we’ve seen above. There’s an example in the repository with the code covered in this getting started guide, with a cabal file and everything.
  • Tutorial, which dives much more into servant’s packages and modules and its inner workings, with some illustrations of the extensibility of servant.
  • Haddocks for all servant packages

We would of course be glad to hear any kind of feedback, so please do not hesitate to shoot us an email with comments, and report any issue you may encounter on our github.

Posted on July 26, 2014
Categories: Offsite Blogs

Proof that scanl' is fusion-safe

libraries list - Fri, 07/25/2014 - 5:07pm
This proof is horribly inefficient. I imagine it could be fixed by appealing to the universal property of foldr or something like that, but I don't have time to look at that right now, so I'll just show you what I have right now; I'm hoping someone will be willing to verify that I haven't made any major errors. scanl' :: (b -> a -> b) -> b -> [a] -> [b] scanl' f a bs = build $ \c n -> a `seq` a `c` foldr (\b g x -> let b' = f x b in b' `seq` (b' `c` g b')) (\b -> b `seq` n) bs a
Categories: Offsite Discussion

A simple monadic stream library?

Haskell on Reddit - Fri, 07/25/2014 - 12:59pm

I'm looking for an API for lazy streaming of monadic data structures. I.e., I need to convert a datastructure into something that can traverse it partially and accumulate transformations instead of applying them. To be more specific I want to extend the API of the "stm-containers" library, with a function which will stream the elements of a container in such a way.

Now, of course, it could be implemented using a library like "pipes", e.g. with a function having a signature like the following:

producer :: Map k v -> Producer (k, v) STM ()

But it obviously would be an overkill, which would bind the library to a specific IO streaming ecosystem.

What I'm looking for is a simpler streaming API, using which I could implement a function like the following:

stream :: Map k v -> Stream STM (k, v)

And then to be able to lazily manipulate streams (filter, map, join - what not). I guess, this is what the ListT monad transformer is supposed to do, but I never dived into it and I know that it's notorious for being broken. The "pipes" library claims to provide a proper version of this transformer, but then again it binds the user to the "pipes" ecosystem.

So my question is: is there a library that solves this problem or am I missing something evident in the approach to my problem?

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

support request

haskell-cafe - Fri, 07/25/2014 - 12:25pm
Hi All! I need to convince group of managers that Haskell is cool. Could you please share some links, presentations, data and maybe experience? Thanks in advance...
Categories: Offsite Discussion

How come you can incompletely export a typeclass?

Haskell on Reddit - Fri, 07/25/2014 - 9:45am

Lets say you have the type class:

class Foo a where f :: a -> String g :: a -> Int k :: a -> Bool

So none of the functions are defined by default. Yet I can do the following:

module MyMod (Foo(f)) where ...

And it compiles! Not even a warning? People can import this module, make an instance for their types yet only be able to define f. Then when they compile their code, they'll get the warning that k and g are not defined. Yet they can't possibly define k or g!

How come ghc/haskell allows this? Is there any instance where this would be desirable? I would think that it shouldn't allow you to partially export functions in a typeclass if those functions don't have a default implementation.

submitted by Die-Nacht
[link] [10 comments]
Categories: Incoming News

The limitations of Haskell for safety critical applications

Haskell on Reddit - Fri, 07/25/2014 - 7:15am

I've been trying to push management in the Haskell direction for development and while I could address most concerns there were a few that seem like deal breakers (here are the two main ones):

  1. Memory allocation - real time safety critical code usually has significant hardware limitations and it is not an option to allow for the possibility of memory errors: heap, stack

  2. Compiler certification - while verifying the correctness of the application code is one thing, the method of proving the object code generated by the compiler is a whole new bag of worms.

Can anyone help me address these concerns?

Thanks!

Edit: Thanks for the feedback everyone! I have a lot of resources to research, so far:

I've looked at everything at a high level and the resources: COMPCERT and Atom address the issues above and Copilot seems to add nice functionality on top of Atom. I still have to figure out if/what can work together and what projects such as SMACCM add to the above technologies.

submitted by Azsu
[link] [21 comments]
Categories: Incoming News

Would it be a good or bad idea to make dropWhile try to fuse?

libraries list - Fri, 07/25/2014 - 5:35am
As Graham Hutton describes in "A tutorial on the universality and expressiveness of fold", dropWhile p = fst . foldr go ([], []) where go x (ys, xs) = (if p x then ys else x:xs, x:xs) We can write this for real: dropWhile :: forall a . (a -> Bool) -> [a] -> [a] dropWhile p list = build dropWhile' where dropWhile' :: forall b . (a -> b -> b) -> b -> b dropWhile' c n = fst $ foldr go (n, n) list where go x (ys, xs) = let xs' = x `c` xs in (if p x then ys else xs', xs') This is generally awful, because it could copy a large portion of the list with no benefit. However, if it fuses, it will sometimes give good results. For example, compiling f m n = foldr (+) 0 $ dropWhile (<m) $ map (+1) [1..n] yields Core that does not produce a intermediate list. Does anyone have any thoughts about whether this one is worth pursuing? David Feuer
Categories: Offsite Discussion

what is basic Haskell?

haskell-cafe - Thu, 07/24/2014 - 11:44pm
What does a programmer need to know to be proficient in "basic Haskell"? For my money, basic programming skills are those that are required to write programs for simple tasks in the common idioms of the language. This means the practitioner should be able to read input from the terminal or files, select/combine/reformat data, and output a result. At this point, efficiency isn't really the point; only getting to a correct answer without writing anything really weird matters. In LYAH, I'd put the boundary at the end of chapter 9, which covers the IO monad. At that point the reader has studied functions, lists, tuples, types, recursion, higher order functions, four major modules, and algebraic data types. Actually, some of the later topics in chapter 8 (functors, kinds, recursive data structures) seem more like intermediate material. Thoughts?
Categories: Offsite Discussion

Finding a job in Functional Programming

Haskell on Reddit - Thu, 07/24/2014 - 11:09pm

Hey guys, I'm a 21 year old that has been programming in one way or the other since I was 11 and about 6 months ago I found Haskell and fell absolutely in love. I've read 3 books so far, countless academic papers and blog posts and I've been using Project Euler and random 'itches' I find in day to day work to learn the language, and I'm still insatiable for more! I've always liked to program, but Haskell helped me realize that it is my passion, and I would love for this to become more than a hobby.

Here's the problem though: I have no idea where to start. I have little founding in academia or industry as I'm almost entirely self taught. How do I get my name out there, and prove that I'm a viable candidate? I have my High School diploma and no work experience related to programming, but I know that if I get an interview I can prove that I'm worth my salt. I've contributed to many public projects over the years and I have a personal project or two under my belt, but I am in want of experience working in a group setting.

I know Haskell, C, C++, ARM assembly(albeit an older dialect, ARMv4), Bash, Emacs Lisp, GML, bits of Java, Python, LaTeX, and probably more that I'm forgetting. I'm also familiar with Windows, Linux, and Mac OS X development and I am capable of maintaining a cross-platform code base.

I am particularly interested in the realm of gaming and compilers, particularly GHC. I'm learning more about the architecture of GHC currently so as to help port it to Android. I have a working draft, thanks to Neurocyte, but it isn't without its problems yet :)

You can view my Github here: https://github.com/MP2E/

I welcome any criticisms, advise, or even stories of how you got into the industry. At this point, I'm willing to look outside the box and work outside of Functional Programming as well, if need be :P

EDIT: Probably should have mentioned, I live in Las Vegas, NV. I'd prefer to either work locally or remotely, rather than relocate.. Relocation might be an option though :V

submitted by rezb1t
[link] [2 comments]
Categories: Incoming News

Need Help - Bool to identify Palindrome in Haskell program

Haskell on Reddit - Thu, 07/24/2014 - 10:15pm

Hi, I am a newbie to Haskell and do sincerely need help with the following: I want to write a function isPal :: String -> Bool that determines if the argument string is a palindrome.

Eg. "Able was I ere I saw Elba" "A man, a plan, a canal, Panama!"

Where the first argument string is a "pure palindrome", if we ignore case differences, and could be tested with a simple function like:

isPurePal xs = xs == reverse xs

The second argument string will fail the simple test because it has extra punctuation and the spaces fall in different positions when read in different directions.

I need help to write a function that will work for both the above cases, and other cases that involve the inclusion of spaces, punctuation, and case differences.

Note: I am thinking of using the class predicates in the Char library, but this is my first haskell program and am not too sure how to format my arguments.

Please any help would be sincerely appreciated.

Cheers.

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

Proposal: Add a strictly accumulating scanl' to Data.List

libraries list - Thu, 07/24/2014 - 9:55pm
Joachim Breitner wrote, in https://ghc.haskell.org/trac/ghc/ticket/9345#comment:6, a strictly accumulating version of scanl, to be named scanl'. I was initially concerned about its safety for fusion, but am now convinced of its correctness and believe it should be added to Data.List. scanl' :: (b -> a -> b) -> b -> [a] -> [b] scanl' f a bs = build $ \c n -> a `seq` a `c` foldr (\b g x -> (let b' = f x b in b' `seq` (b' `c` g b'))) (\b -> b `seq` n) bs a
Categories: Offsite Discussion

callCC inside expression

haskell-cafe - Thu, 07/24/2014 - 7:41pm
Hello all I recently saw a video on call/cc in Scheme, where call/cc was used inside an expression and call/cc faithfully figured out the rest of the computation. I tried the same in haskell, but was bitten badly. Then I looked at the type signature and learned that call/cc only works inside a continuation monad (if I am not mistaken). Is this correct and why is that so? Are scheme's call/cc and haskell's callCC semantically different?
Categories: Offsite Discussion

HOPE 2014 Call for Participation (with Workshop Program)

General haskell list - Thu, 07/24/2014 - 5:48pm
---------------------------------------------------------------------- CALL FOR PARTICIPATION HOPE 2014 The 3rd ACM SIGPLAN Workshop on Higher-Order Programming with Effects August 31, 2014 Gothenburg, Sweden (the day before ICFP 2014) https://www.mpi-sws.org/~neelk/hope2014/ ---------------------------------------------------------------------- HOPE 2014 aims at bringing together researchers interested in the design, semantics, implementation, and verification of higher-order effectful programs. It will be *informal*, consisting of invited talks, contributed talks on work in progress, and open-ended discussion sessions. ------------ Registration ------------ Deadline for early registration: 3 August 2014 Web site: https://regmaster4.com/2014conf/ICFP14/register.php This is the registration site for ICFP 2014 and all the affiliated workshops in
Categories: Incoming News

Are functional languages (or specifically GHC Haskell) bad at GC?

Haskell on Reddit - Thu, 07/24/2014 - 4:55pm

I've been reading the StackOverflow thread on Hackernews and stubmled upon this comment that says, quote

Functional languages are terrible for garbage collection

I'm pretty sure this isn't the first time I'm seeing this, so I wanted to ask if someone who knows a bit how GC in GHC vs something like .NET or Java works, and if this is actually true?

I'm not looking to start a flame war, but rather asking for some hard facts. It's sort of hard to google information of this type.

Here's a link to the parent discussion.

submitted by progfu
[link] [18 comments]
Categories: Incoming News