- Types are declared with
:and not::, and the consing operator conversely is::instead of: - No
whereclauses, onlylet/in - The standard style is different, check http://elm-lang.org/docs/style-guide for reference
- Multiline strings are a thing with
""" - Haskell's
datacorresponds totypein Elm, and also, Haskell'stypecorresponds to Elm'stype alias ($)is(<|), but you don't use it all that much – Elm people like the flipped operator(|>)which lets you build something that reads like a pipeline- Related: Backticks will likely die soon in favour of functions that have an argument order that lends itself to pipelining with
(|>) - Also,
(.)is(<<), and a flipped version(>>)exists, but I don't see it used that much either (>>=)is not an available operator and would not be polymorphic (no typeclasses, see below), and is instead commonly namedSomeType.andThen– e.g.Maybe.andThen : Maybe a -> (a -> Maybe b) -> Maybe b
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module RidiculousFizzBuzz where | |
| divBy :: Int -> Int -> Bool | |
| divBy d x = x `mod` d == 0 | |
| fizzIt :: Int -> (Int, Bool, Bool) | |
| fizzIt = (,,) <$> id <*> divBy 3 <*> divBy 5 | |
| fizzString :: (Int, Bool, Bool) -> String | |
| fizzString (x, False, False) = show x |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function fit80CharsInBody() { | |
| var p = document.createElement('p'); | |
| var chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; | |
| p.textContent = chars; | |
| var s = p.style; | |
| s.position = 'absolute'; | |
| s.visibility = 'hidden'; | |
| s.width = s.height = 'auto'; | |
| s.whiteSpace = 'nowrap'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // after 100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 milliseconds, print 100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 times | |
| for(i=0;i<1e308;i++){setTimeout(console.log.bind(console,1e |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module FocusTree exposing (FocusTree, Tree, Index, init, goUp, goDown, insertAndFocus, unfocus, getCurrentValue) | |
| import Array exposing (Array) | |
| import Maybe exposing (andThen) | |
| type Tree a | |
| = Empty | |
| | Node a (Array (Tree a)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module MonoidMaximum where | |
| safeMaximum :: (Ord a, Monoid a) => [a] -> a | |
| safeMaximum [] = mempty | |
| safeMaximum [x] = x | |
| safeMaximum (x:xs) = max x (safeMaximum xs) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| port module LinkedCounter exposing ( .. ) | |
| import Html exposing (Html, Attribute, button, div, text) | |
| import Html.Attributes exposing (style) | |
| import Html.App as App | |
| import Html.Events exposing (onClick) | |
| -- MODEL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module ChildAges exposing (..) | |
| import Html exposing (..) | |
| import Html.Attributes exposing (..) | |
| import Html.Events exposing (onInput) | |
| import Html.App | |
| import String | |
| import Array | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module DictSelect exposing (..) | |
| import Dict exposing (Dict) | |
| import Set | |
| select : List comparable -> Dict comparable v -> Dict comparable v | |
| select keys dict = | |
| List.foldr (putIfIn dict) Dict.empty keys |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module BorkingElm exposing (..) | |
| undefined : a | |
| undefined = undefined | |
| str : String | |
| str = "hello" ++ undefined | |
| num : Int | |
| num = 1 + undefined |