language originally designed for working with the LCF theorem prover. Today, there are quite a few ML dialects, as well as several languages that have been influenced by ML 4
S. get " / " d e f a u l t F i l e S. post " / : render " $ do outputFormat <− param " render " inputFormat <− param " format " toConvert <− getPostBody case convertDoc inputFormat outputFormat toConvert of Left errMsg −> do status status500 f i n i s h Right r e s u l t −> t e x t r e s u l t 19
errors for us that we might miss in other languages. This can be a big help when we’re prototyping because it can save us from having to write a lot of tests or spending a lot of time debugging. 21
great way to write many test cases very quickly and easily. test_wordWrap : : Spec test_wordWrap = do i t " returns words in the r i g h t order " $ property $ \ str ’ ( Positive width ) −> l e t s t r = BS. pack str ’ words = concatMap BS. words $ HCat . wordWrap width s t r in words ‘ shouldBe ‘ (BS. words s t r ) i t " does not break a word " $ property $ \ ( Positive width ) −> l e t width ’ = width + 5 s t r = BS. pack $ replicate width ’ ’a ’ wrapped = HCat . wordWrap width s t r in do ( length wrapped ) ‘ shouldBe ‘ 1 (head wrapped ) ‘ shouldBe ‘ s t r i t " breaks l i n e s to the appropriate length " $ property $ \ str ’ ( Positive width ) −> l e t s t r = BS. pack str ’ lines = HCat . wordWrap width s t r in shouldSatisfy lines $ a l l $ \ l i n e −> (BS. length l i n e ) <= width | | ( length . BS. words $ l i n e ) == 1 22
that elm applications follow. Elm applications are functional reactive event loops that should look familiar to you if you’ve worked with frameworks like react.js 25
language that is focused on ease of use, approachability, and cohesiveness. It’s less flexible, and offers fewer features than Haskell, but makes up for that with a consistent and coherent sandbox for developing SPAs. 26