{"id":19261981,"url":"https://github.com/hacksu/haskell-notes","last_synced_at":"2026-02-27T23:04:07.574Z","repository":{"id":149141462,"uuid":"128993463","full_name":"hacksu/haskell-notes","owner":"hacksu","description":null,"archived":false,"fork":false,"pushed_at":"2018-04-10T20:53:03.000Z","size":1,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-01-05T10:12:26.183Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hacksu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-04-10T20:52:35.000Z","updated_at":"2018-04-10T20:53:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"6894c028-5c28-4805-bb23-e10cae843174","html_url":"https://github.com/hacksu/haskell-notes","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacksu%2Fhaskell-notes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacksu%2Fhaskell-notes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacksu%2Fhaskell-notes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacksu%2Fhaskell-notes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hacksu","download_url":"https://codeload.github.com/hacksu/haskell-notes/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240364295,"owners_count":19789756,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T19:29:16.949Z","updated_at":"2026-02-27T23:04:02.539Z","avatar_url":"https://github.com/hacksu.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# HackSkell\n\n## What is Haskell?\nHaskell is a functional programming language.\n\n## Why use Haskell?\nHaskell removes the ability to have stateful code \nbecause it variables are assign once. This eliminates\nrace conditions making it ideal for multi-threaded\napplications. \n\n## What resources are there?\n- [Learn You a Haskell for Great Good](http://learnyouahaskell.com/introduction)\n- [Real World Haskell](http://book.realworldhaskell.org/read/)\n- [Challenge Problems](https://wiki.haskell.org/H-99:_Ninety-Nine_Haskell_Problems)\n\n## Some Syntax Notes\n\n- Basic types\n    - Int\n    - String\n\n- Defining a function\n```\nfoo :: Int -\u003e Int\nfoo x = \u003cfunction body\u003e\n```\n\n- Lists\n    - Define a list: `let a = [4,5,6]`\n    - Combine two lists: `[1,2,3] ++ [4,5,6]` yields `[1,2,3,4,5,6]`\n    - Append elements:\n        - Front: `3:[4,5]` yields `[3,4,5]`\n        - Back: `[4,5]:6` yields `[4,5,6]`\n    - List Generation `[x*x | x \u003c- [1..10]]`\n    \n## Pattern Matching\nHaskell provides an easy method for matching patterns in your code.\nRather than using a bunch of if-statements, you can instead define patterns in your code!\n\n```\nspellNum :: Int -\u003e String\nspellNum 1 = \"One\"\nspellNum 2 = \"Two\"\nspellNum 3 = \"Three\"\nspellNum 4 = \"Four\"\nspellNum 5 = \"Five\"\nspellNum x = \"This number is too big for my small brain\"\n\nbetterSpellNum :: Int -\u003e String\nbetterSpellNum num\n  | num == 1  = \"One\"\n  | num == 2  = \"Two\"\n  | num == 3  = \"Three\"\n  | num == 4  = \"Four\"\n  | num == 5  = \"Five\"\n  | otherwise = \"This number is too big for my small brain\"\n```\n    \n## A Language without Loops\nIn Haskell there are not for or while loops, so I really \nhope you enjoy recursion. Here are some examples.\n\nSum a list recursively\n```\nprintArr :: [Int] -\u003e Int\nprintArr (x:xs) = x + printArr xs\nprintArr [] = 0\n```\n\n## Interactive TODO List\n```\nputTodo :: (Int, String) -\u003e IO ()\nputTodo (n, todo) = putStrLn (show n ++ \": \" ++ todo)\n\nprompt :: [String] -\u003e IO ()\nprompt todos = do\n    putStrLn \"\"\n    putStrLn \"Current TODO list:\"\n    mapM_ putTodo (zip [0..] todos)\n    command \u003c- getLine\n    interpret command todos\n\ninterpret :: String -\u003e [String] -\u003e IO ()\ninterpret ('+':' ':todo) todos = prompt (todo:todos)\ninterpret ('-':' ':num ) todos =\n    case delete (read num) todos of\n        Nothing -\u003e do\n            putStrLn \"No TODO entry matches the given number\"\n            prompt todos\n        Just todos' -\u003e prompt todos'\ninterpret  \"q\"           todos = return ()\ninterpret  command       todos = do\n    putStrLn (\"Invalid command: `\" ++ command ++ \"`\")\n    prompt todos\n\ndelete :: Int -\u003e [a] -\u003e Maybe [a]\ndelete 0 (_:as) = Just as\ndelete n (a:as) = do\n    as' \u003c- delete (n - 1) as\n    return (a:as')\ndelete _  []    = Nothing\n\nmain = do\n    putStrLn \"Commands:\"\n    putStrLn \"+ \u003cString\u003e - Add a TODO entry\"\n    putStrLn \"- \u003cInt\u003e    - Delete the numbered entry\"\n    putStrLn \"q          - Quit\"\n    prompt []\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhacksu%2Fhaskell-notes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhacksu%2Fhaskell-notes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhacksu%2Fhaskell-notes/lists"}