{"id":21874152,"url":"https://github.com/eeue56/haskell-to-elm","last_synced_at":"2025-10-11T12:18:05.263Z","repository":{"id":36146105,"uuid":"40450119","full_name":"eeue56/haskell-to-elm","owner":"eeue56","description":null,"archived":false,"fork":false,"pushed_at":"2017-02-05T22:53:46.000Z","size":12,"stargazers_count":66,"open_issues_count":0,"forks_count":10,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-10-11T12:18:03.688Z","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":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eeue56.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-08-09T20:51:41.000Z","updated_at":"2025-07-07T22:44:21.000Z","dependencies_parsed_at":"2022-09-05T18:30:17.676Z","dependency_job_id":null,"html_url":"https://github.com/eeue56/haskell-to-elm","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/eeue56/haskell-to-elm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eeue56%2Fhaskell-to-elm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eeue56%2Fhaskell-to-elm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eeue56%2Fhaskell-to-elm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eeue56%2Fhaskell-to-elm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eeue56","download_url":"https://codeload.github.com/eeue56/haskell-to-elm/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eeue56%2Fhaskell-to-elm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279007145,"owners_count":26084247,"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","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-28T07:11:14.518Z","updated_at":"2025-10-11T12:18:05.224Z","avatar_url":"https://github.com/eeue56.png","language":null,"funding_links":[],"categories":["Resources","Misc","Learning Guides"],"sub_categories":["[Elm](http://elm-lang.org)"],"readme":"# haskell-to-elm\n\nCollection of examples on places where Elm is different to Haskell.\n\nUsed for helping beginners moving from Haskell to Elm. Non-exhaustive list, only to be used alongside the documentation on the [Elm](http://elm-lang.org) site.\n\n* [Functional Programming](#functional-programming)\n\t* [Type signatures](#type-signatures)\n\t* [Function application](#function-application)\n\t* [Function composition](#function-composition)\n\t* [List comprehensions](#list-comprenhensions)\n\t* [Lenses](#lenses)\n\t* [Where](#where-vs-let)\n\t* [Purity](#purity)\n* [Prelude functions](#built-in-prelude-methods)\n\t* [id](#id)\n\t* [cons](#cons)\n\t* [head](#head)\n\t* [tail](#tail)\n\t* [zip](#zip)\n\t* [show](#show)\n\t* [mod](#mod)\n\t* [unwords](#unwords)\n\t* [cycle](#cycle)\n\t* [foldl](#foldl)\n* [Modules](#module-syntax)\n\t* [Importing](#importing-names)\n\t* [Exporting](#defining-exportable-names)\n\n# Functional programming \n\n## Type signatures\n\nElm uses a [single colon `(:)`](http://elm-lang.org/docs/syntax#type-annotations) for type signatures. Double colons `(::)` is used for [cons](http://package.elm-lang.org/packages/elm-lang/core/2.1.0/List#::).\n\nExample\n\n```\n\tadd :: Int -\u003e Int\n```\n\nbecomes\n```\n\tadd : Int -\u003e Int\n```\n\n## Function application\n\nInstead of using the dollar symbol `$` elm uses `\u003c|` and `|\u003e`  for [application in different directions](http://package.elm-lang.org/packages/elm-lang/core/2.1.0/Basics#|\u003e). \n\nExample:\n\n```\n    collage (round board.width) (round board.height) $ map (genRect board) board.pieces\n```\nbecomes\n```\n    collage (round board.width) (round board.height) \u003c| List.map (genRect board) board.pieces\n    --\n    List.map (genRect board) board.pieces |\u003e collage (round board.width) (round board.height)\n```\n\n## Function composition\n\nInstead of using the `(.)` symbol Elm uses `\u003c\u003c` and `\u003e\u003e` for [composition in different directions](http://package.elm-lang.org/packages/elm-lang/core/2.1.0/Basics#\u003e\u003e)\n\nExample:\n```\n    isEvenSquareRoot = isEven . sqrt\n```\nbecomes\n```\n    isEvenSquareRoot = sqrt \u003e\u003e isEven\n    -- or\n    isEvenSquareRoot = isEven \u003c\u003c sqrt\n```\n\n## List comprenhensions\n\nThere are [no list comprehensions](https://github.com/elm-lang/elm-compiler/issues/147#issuecomment-17439271) in Elm.\n\n## Lenses\n\nElm has the package [focus](http://package.elm-lang.org/packages/evancz/focus/1.0.1) for lense-like accessors. Due to a lack of template-haskell like functionality, you must always [manually create your own focus](http://package.elm-lang.org/packages/evancz/focus/1.0.1/Focus#create)\n\n\n\nExample:\n``` \n    data Patch = Patch {\n\t\t_colour :: Colour,\n\t\t_size :: Double, \n\t\t_coord :: Coordinate\n\t} deriving (Show, Eq, Ord)\n\t\n\tmkLabels[''Patch]\n```\nbecomes\n```\n    type alias Patch = {\n        colour: Colour,\n        size: Float,\n        coord: Coordinate\n    }\n    \n    colour = create .colour (\\f r -\u003e { r | colour = f r.colour })\n    coord = create .coord (\\f r -\u003e { r | coord = f r.coord })\n    size = create .size (\\f r -\u003e { r | size = f r.size })\n```\n\n## where vs let\n\nElm has no where binding - instead use [let](http://elm-lang.org/docs/syntax#let-expressions)\n\n## Pattern matching\n\nElm doesn't support multiple body declarations for functions, so instead you have to use [case..of](http://elm-lang.org/docs/syntax#conditionals)\n\nExample:\n```\n\thead [] = error\n\thead (X:xs) = x\n```\nbecomes\n```\n\thead xs = case xs of\n  \t\tx::xs -\u003e Just x\n  \t\t[] -\u003e Nothing\n```\n\n## Purity\n\nFunctions in Elm as of 0.15.1 have pure type signatures. However, as they are actually implented in JS, it's possible that the underlying code you're calling isn't pure. This gives the effect of Elm the language being pure, but the things it can be used to do can be impure (eg, drawing to screen). Native functions can also produce runtime errors, though there is a drive to rid these from Elm entirely.\n\n# Built-in (Prelude) methods\n\n## id\n\nElm has renamed id to [identity](http://package.elm-lang.org/packages/elm-lang/core/2.1.0/Basics#identity)\n\nExample:\n```\n\tid xs\n```\nbecomes\n```\n\tidentity xs\n```\n\n## cons\n\nElm uses [double colons `(::)`](http://package.elm-lang.org/packages/elm-lang/core/2.1.0/List#::) for cons.\n\nExample\n```\n\t5 : 6 : [7, 8]\n```\nbecomes\n```\n\t5 :: 6 :: [7, 8]\n```\n\n## head\n\nInstead of throwing errors for empty lists, Elm uses Maybe for [head](http://package.elm-lang.org/packages/elm-lang/core/2.1.0/List#head)\n\nExample\n```\n\thead [4, 5] == 4\n```\nbecomes\n```\n\tcase head [4, 5] of\n\t\tJust x -\u003e x == 4\n\t\tNothing -\u003e False\n```\n\n## tail\n\nInstead of throwing errors for empty lists, Elm uses Maybe for [tail](http://package.elm-lang.org/packages/elm-lang/core/2.1.0/List#tail)\n\nExample\n```\n\ttail [4, 5] == [5]\n```\nbecomes\n```\n\tcase tail [4, 5] of\n\t\tJust x -\u003e x == [5]\n\t\tNothing -\u003e False\n```\n\n## zip\n\nElm has [no built-in zip](http://elm-lang.org/examples/zip) method - instead it provides a [map2](http://package.elm-lang.org/packages/elm-lang/core/2.1.0/List#map2) function that can be used with the tuple creator `(,)` to make a list of size 2 tuples from two lists.\n\nExample:\n\n```\n    zip xs ys\n```\nbecomes\n```\n    map2 (,) xs ys\n```\n\n\n## show\n\nElm renamed [show](http://zvon.org/other/haskell/Outputprelude/show_f.html) to [toString](http://package.elm-lang.org/packages/elm-lang/core/2.1.0/Basics#toString). Confusingly, there is also a [method called show](http://package.elm-lang.org/packages/elm-lang/core/2.1.0/Graphics-Element#show) in Elm - this generates a HTML element containing a textual representation of the data.\n\nExample:\n```\n    show [1, 2, 3]\n```\nbecomes\n```\n    toString [1, 2, 3]\n```\n\n## mod\n\nmod in Elm uses the [`(%)` symbol](http://package.elm-lang.org/packages/elm-lang/core/2.1.0/Basics#%).\n\nExample:\n```\n    isEven x = x `mod` 2 == 0\n```\nbecomes\n```\n    isEven x = x % 2 == 0\n```\n\n## unwords\n\nunwords is replaced by the [join function](http://package.elm-lang.org/packages/elm-lang/core/2.1.0/String#join)\n\nExample:\n```\n\tunwords $ words \"Hello Dave and Jeremy\"\n```\nbecomes\n```\n\tjoin \" \" \u003c| words \"Hello Dave and Jeremy\"\n```\n\n## cycle\n\nElm has no cycle built in. \n\n\nTODO: find documentation for this\n\n## foldl\n\nThe order of the accumalator function arguments are [swapped in Elm](http://package.elm-lang.org/packages/elm-lang/core/2.1.0/Set#foldl).\n\nExample:\n```\n\tidx xs = foldl (\\x y -\u003e y : x) [] xs\n```\nbecomes\n```\n\tid xs = List.foldl (\\x y -\u003e x :: y) xs [] \n```\n\n# Module syntax\n\n## Importing names\n\nElm uses the [`exposing` keyword](http://elm-lang.org/docs/syntax#modules) to import names into the current namespace.\n\nExample:\n```\n    import List (map, foldl)\n```\nbecomes\n```\n    import List exposing (map, foldl)\n```\n\n## Defining exportable names\n\nTODO: find documentation on elm site for this\n\nFollowing the module declaration, you must have *no* identnation level.\n\nExample:\n```\n    module Coords (pos) where\n        pos x y = (x, y)\n```\nbecomes\n```\n    module Coords exposing (pos)\n    pos x y = (x, y)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feeue56%2Fhaskell-to-elm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feeue56%2Fhaskell-to-elm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feeue56%2Fhaskell-to-elm/lists"}