Haskell forall error

163 Views Asked by At

Eclipse show error in editor at explicit forall, though I can run the script without errors. How can I fix this? (This also happens when I run it in cmd, think I need a flag here!?)

enter image description here


Also warnings about defaulting to integer type are annoying is there a way to stop them?

enter image description here

1

There are 1 best solutions below

2
On BEST ANSWER

You need to explicitly declare the language extension in each file like this

{-# LANGUAGE FOO #-}

where FOO is either, ExplicitForall which just let's you write forall, ScopedTypeVariables which means that you can write

 foo :: forall a. a -> [a]
 foo a = [a] :: [a]

and have the explicit signature work as expected. Or RankNTypes which let's you write types of a higher rank like

 foo :: (forall a. a -> a) -> Int -> Int

In this case it looks like you just want ExplicitForall.