Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Haskell: define list over multiple lines

Tags:

haskell

I'm defining a TestList (HUnit) and want to spread the definition over multiple lines. I came to the following solution:

tests = TestList ([TestLabel "test1" test1] ++
                  [TestLabel "test2" test2] ++
                  [TestLabel "test3" test3] ++
                  [TestLabel "test4" test4] ++
                  [TestLabel "test5" test5])
  • Is the use of the ++ operator the proper way to do such things?
  • Are there better or more elegant ways to do this?
like image 413
Scolytus Avatar asked Nov 03 '11 22:11

Scolytus


1 Answers

I'd write

tests = TestList
    [ TestLabel "test1" test1
    , TestLabel "test2" test2
    , TestLabel "test3" test3
    , TestLabel "test4" test4
    , TestLabel "test5" test5 ]
like image 97
ephemient Avatar answered Sep 23 '22 12:09

ephemient