I'm trying to learn Haskell, but I'm stumped on something. So far, I've come to understand that functions signatures conform to this convention:
<name> :: <type constraint A> => <input type A> -> <input type B> -> .. <input type X> -> <return type>
So, some examples with my current understanding are:
-- Returns input + 2
add2 :: Int -> Int
add2 x = x + 2
-- Returns the result of applying a function that takes an int and returns an int on an input int
adds2 :: (Int -> Int) -> Int -> Int
adds2 func x = func x
-- Returns a String with "Hello" prepended to the front
sayHello :: String -> String
sayHello name = "Hello " ++ name
Then I came across this which is what stumped me:
mate :: RandomGen g => Gene -> Gene -> Rand g Gene
I understand that the functions name is mate, and it has a type constraint where the g must be of type RandomGen, it then takes as input two values of type Gene.
However, it is the return type that is really confusing me. How do you interpret this and could anyone explain it to a novice Haskeller?