On 09/10/2013 09:30 AM, Niklas Hambüchen wrote:
Impressed by the productivity of my Ruby-writing friends, I have
recently come across Cucumber: http://cukes.info


It is a great tool for specifying tests and programs in natural
language, and especially easy to learn for beginners.

I propose that we add a Cucumber syntax for Haskell, with the extension
".chs", next to .hs and .lhs.


Code written in cucumber syntax is concise and easy to read: You can
find some example code in https://gist.github.com/nh2/6505995. Quoting
from that:

   Feature: The Data.List module

     In order to be able to use lists
     As a programmer
     I want a module that defines list functions

     Scenario: Defining the function foldl
       Given I want do define foldl
       Which has the type (in brackets) a to b to a (end of brackets),
                          to a, to list of b, to a
       And my arguments are called f, acc, and l
       When l is empty
       Then the result better be acc
       Otherwise l is x cons xs
       Then the result should be foldl f (in brackets) f acc x
                                 (end of brackets) xs


PS: People even already started a testing framework for Haskell in it:
https://github.com/sol/cucumber-haskell#cucumber-for-haskell


The above hardly is an acceptable state of affairs. While I appreciate the effort, clearly Cucumber is a rather limited tool and should be replaced by something more sophisticated that actually delivers the promises of conciseness and being easy to read.

My first shot (this can probably be made even more concise and/or easier to read):

Feature: The Data.List module

In order to be able to use lists more conveniently
As a programmer
I want a module that defines some common operations on lists

Scenario: Defining the function 'foldl'
  Given I want to define 'foldl'
Which whenever given a thing that whenever given a thing of some first kind will give a thing that whenever given a thing of some second kind will give a thing of the first kind again, will give something that whenever given a thing of the first kind will give something that whenever given a list containing things of the second kind will give something of the first kind.
  When the list is empty
  Then the result better be the aforementioned thing of the first kind
Otherwise the list has a first thing in it and the remaining things form a list again. Then we get the result by giving to 'foldl' the first thing mentioned and to the result we give the result we get by giving the first thing in the list to the thing we get by giving the thing of the first kind to the thing we already gave to 'foldl' and then give to what we get the list of remaining things.




_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to