Haskell Coding Editor for Technical Interviews

Running GHC 8.6 - Autocomplete is not available

Your code is run with runghc solution.hs. Your code runs in interpreted mode, so you don’t need a special entrypoint or anything.

We have a couple testing options available. Simple tests using Hspec are straightforward:

import Test.Hspec import Test.QuickCheck import Control.Exception (evaluate) main :: IO () main = hspec $ do describe "Prelude.head" $ do it "returns the first element of a list" $ do head [23 ..] `shouldBe` (23 :: Int) it "returns the first element of an *arbitrary* list" $ property $ \x xs -> head (x:xs) == (x :: Int) it "throws an exception if used with an empty list" $ do evaluate (head []) `shouldThrow` anyException
Code language: Haskell (haskell)

You can also use QuickCheck’s more powerful test generation framework directly (this test fails):

import Test.QuickCheck prop_revapp :: [Int] -> [Int] -> Bool prop_revapp xs ys = reverse (xs++ys) == reverse xs ++ reverse ys main = quickCheck prop_revapp
Code language: Haskell (haskell)

We install a variety of packages in the Haskell environment (including req for HTTP requests). The output of cabal list --installed --simple is below:

Cabal 2.4.0.1 HUnit 1.6.0.0 QuickCheck 2.13.1 RSA 2.3.1 SHA 1.6.4.4 aeson 1.4.3.0 ansi-terminal 0.9.1 array 0.5.3.0 asn1-encoding 0.9.5 asn1-parse 0.9.4 asn1-types 0.3.2 async 2.2.1 attoparsec 0.13.2.2 attoparsec-iso8601 1.0.1.0 authenticate-oauth 1.6 base 4.12.0.0 base-compat 0.10.5 base-orphans 0.8.1 base64-bytestring 1.0.0.2 basement 0.0.10 binary 0.8.6.0 blaze-builder 0.4.1.0 bytestring 0.10.8.2 cabal-doctest 1.0.6 call-stack 0.1.0 case-insensitive 1.2.1.0 cereal 0.5.8.0 clock 0.8 colour 2.3.5 connection 0.3.0 containers 0.6.0.1 cookie 0.4.4 crypto-api 0.13.3 crypto-pubkey-types 0.4.3 cryptonite 0.25 data-default 0.7.1.1 data-default-class 0.1.2.0 data-default-instances-containers 0.0.1 data-default-instances-dlist 0.0.1 data-default-instances-old-locale 0.0.1 deepseq 1.4.4.0 directory 1.3.3.0 dlist 0.8.0.6 entropy 0.4.1.4 exceptions 0.10.2 filepath 1.4.2.1 ghc 8.6.5 ghc-boot 8.6.5 ghc-boot-th 8.6.5 ghc-compact 0.1.0.0 ghc-heap 8.6.5 ghc-prim 0.5.3 ghci 8.6.5 hashable 1.2.7.0 hashtables 1.2.3.1 haskeline 0.7.4.3 hourglass 0.2.12 hpc 0.6.0.3 hspec 2.7.1 hspec-core 2.7.1 hspec-discover 2.7.1 hspec-expectations 0.8.2 http-api-data 0.4 http-client 0.6.4 http-client-tls 0.3.5.3 http-types 0.12.3 integer-gmp 1.0.2.0 integer-logarithms 1.0.3 libiserv 8.6.3 memory 0.14.18 mime-types 0.1.0.9 monad-control 1.0.2.3 mtl 2.2.2 network 3.1.0.0 network-uri 2.6.1.0 old-locale 1.0.0.7 parsec 3.1.13.0 pem 0.2.4 pretty 1.1.3.6 primitive 0.6.4.0 process 1.6.5.0 quickcheck-io 0.2.0 random 1.1 req 2.0.1 retry 0.8.0.1 rts 1.0 scientific 0.3.6.2 setenv 0.1.1.3 socks 0.6.0 split 0.2.3.3 splitmix 0.0.2 stm 2.5.0.0 streaming-commons 0.2.1.0 tagged 0.8.6 template-haskell 2.14.0.0 terminfo 0.4.1.2 text 1.2.3.1 tf-random 0.5 th-abstraction 0.3.1.0 time 1.8.0.2 time-locale-compat 0.1.1.5 tls 1.4.1 transformers 0.5.6.2 transformers-base 0.4.5.2 transformers-compat 0.6.5 unix 2.7.2.2 unordered-containers 0.2.10.0 uuid-types 1.0.3 vector 0.12.0.3 vector-algorithms 0.8.0.1 x509 1.7.5 x509-store 1.6.7 x509-system 1.6.6 x509-validation 1.6.11 xhtml 3000.2.2.1 zlib 0.6.2
Code language: Haskell (haskell)

Try Our Haskell Editor