Arrows in Elm's method signature

Neeraj Singh

By Neeraj Singh

on July 11, 2017

Let's look at the documentation of length function of String in Elm.

It's here and it looks like this.

1length : String -> Int
3> String.length "Hello World"
411 : Int

If we look at the similar feature in Ruby world then we get length method.

1length -> integer

Methos signature in ruby's documentation and Elm's documentation is quite similar. Both return an integer.

In Elm's world method definitions are called "Type Annotations". Going forward that's what I'm going to use in this blog.

Now let's look at method definition of slice method in Ruby.

It looks like this.

1slice(start, length) -> new_str or nil
3irb(main):006:0> "snakes on a plane!".slice(0,6)
4=> "snakes"

In Elm world it looks like this.

1slice : Int -> Int -> String -> String
3> String.slice  0  6 "snakes on a plane!"
4"snakes" : String

Questions is what's up with all those arrows.

Stay up to date with our blogs. Sign up for our newsletter.

We write about Ruby on Rails, ReactJS, React Native, remote work,open source, engineering & design.