import Html
import List

ten : Int
ten = 10

-- Takes a function that takes an "a" and a "b" and returns a "c"
-- ... then a "b"
-- ... then an "a"
-- ... and it returns a "c"
-- It's a reimplementation of Basics.flip http://package.elm-lang.org/packages/elm-lang/core/5.1.1/Basics#flip
flip : (a -> b -> c) -> b -> a -> c
flip f x y = f y x

minus : Int -> Int -> Int
minus x y = x - y

unminus : Int -> Int -> Int
unminus = flip minus

fiveMinus : Int -> Int
fiveMinus = minus 5

minus5 : Int -> Int
minus5 = unminus 5
-- or
-- minus5 = (flip minus) 5

-- Takes a value of type "a"
-- ... then an Int
-- ... and it returns an List of the given length filled with that value
-- List.repeat is documented here: http://package.elm-lang.org/packages/elm-lang/core/5.1.1/List#repeat
repeat2 : a -> Int -> List a
repeat2 = flip List.repeat

repeatFrog : Int -> List String
repeatFrog = repeat2 "frog"

repeat5 : Int -> List Int
repeat5 = repeat2 5

-- The <| operator is a handy alternative to a bunch of parentheses.
main : Html.Html msg
main = Html.text <| toString <| repeat5 ten

-- Here are some other "main"s to try out.
-- You can only have one definition of "main" at a time, so you'll have to
-- comment out the ones above.
--
-- main = Html.text (toString (minus 1 2))
-- main = Html.text (toString (minus ten 12))
-- main = Html.text (toString (minus5 ten))