Mind the following Haskell term:
callNTimes :: forall a . Int -> (a -> a) -> a -> a
callNTimes n f 0 = x
callNTimes n f x = f (callNTimes (n-1) f x)
firstOf :: ??????
firstOf n = callNTimes n (\ x y -> x)
If we ignore the types and normalize the functions by hand, firstOf
is a function that receives an N
, then N
arguments, discards all but the first and returns it. firstOf 3 10 20 30
returns 3
. Is it possible to type that function in GHC 8.0 with the new dependent typing features?