Skip to content

Instantly share code, notes, and snippets.

Commit Message Guidelines

Short (72 chars or less) summary

More detailed explanatory text. Wrap it to 72 characters. The blank
line separating the summary from the body is critical (unless you omit
the body entirely).

Write your commit message in the imperative: "Fix bug" and not "Fixed
bug" or "Fixes bug." This convention matches up with commit messages
@vvv
vvv / OrdEq.hs
Created September 7, 2017 10:54 — forked from mssawant/ordeq.hs
import Data.Foldable (foldl')
import Debug.Trace (trace)
prnEqual :: (Eq a) => a -> a -> IO ()
prnEqual a b = if a == b then print "True" else print "False"
-- Note the absence of parentheses around `Eq a` and having exactly one `print`.
prnEqual' :: Eq a => a -> a -> IO ()
prnEqual' a b = print $ if a == b then "True" else "False"
@vvv
vvv / misc.hs
Last active August 24, 2017 16:50 — forked from mssawant/misc.hs
Haskell exercise
{-- XXX Your definition of `checkChar` is okay, but the abstraction itself
-- is very odd. It is fine as an exercise of using "do" notation and
-- `return`. In real code though explicit statements are both short and
-- expressive (see lines 21-22).
checkChar :: IO Bool
checkChar = do
c <- getChar
return (c == 'y')
--}
listsum :: Num a => [a] -> a
listsum [] = 0
listsum (x:xs) = x + listsum xs
main :: IO ()
main = print $ listsum [1..5]