How do I declare the type of a variable inside a function in Haskell? -
this reframe of question asked @ defining variables inside function haskell
i have function beginning of looks this:
recursivels :: filepath -> io [filepath] recursivels dir = folderexists <- doesdirectoryexist dir if folderexists ...
the question is, how can explicitly declare type of folderexists
before assign in action?
well, let's try want in ghci
:
> (a :: integer) <- return 10 <interactive>:2:7: illegal type signature: `integer' perhaps intended use -xscopedtypevariables in pattern type-signature
so, should enable pragma.
> :set -xscopedtypevariables
and try again
> (a :: integer) <- return 10 :: integer
now have a
equal 10
, integer
:
> 10 :: integer
also, believe you've forgot =
in recursivels
function, there should recursivels dir = ...
Comments
Post a Comment