definition:
|
tryParse :: String -> IO (Either String CurryProg)
tryParse fn = do
exists <- doesFileExist fn
if not exists
then cancel $ "AbstractCurry file '" ++ fn ++ "' does not exist"
else do
src <- readFile fn
let (line1, lines) = break (=='\n') src
if line1 /= "{- "++version++" -}"
then cancel $ "Could not parse AbstractCurry file '" ++ fn
++ "': incompatible versions"
else
case readACYString lines of
Just p -> return (Right p)
Nothing -> cancel $ "Could not parse AbstractCurry file '" ++
fn ++ "': no parse"
where cancel str = return (Left str)
|
demand:
|
no demanded arguments
|
deterministic:
|
deterministic operation
|
documentation:
|
--- Try to parse an AbstractCurry file.
--- @param fn - file name of AbstractCurry file
|
failfree:
|
_
|
indeterministic:
|
referentially transparent operation
|
infix:
|
no fixity defined
|
iotype:
|
{(_) |-> _}
|
name:
|
tryParse
|
precedence:
|
no precedence defined
|
result-values:
|
_
|
signature:
|
String -> Prelude.IO (Prelude.Either String AbstractCurry.Types.CurryProg)
|
solution-complete:
|
operation might suspend on free variables
|
terminating:
|
possibly non-terminating
|
totally-defined:
|
possibly non-reducible on same data term
|