I try to get the word-count example from real-world Haskell running in Frege:
main _ = interact wordCount
where wordCount input = show (length (lines input)) ++ "\n"
but I get
can't resolve `interact`
Is there a Frege-idiomatic way to do this?
It is not in the standard library but you can define something like this:
Update (for the comment on Groovy's
eachLine
):Frege has
try
,catch
,finally
andBufferedReader.getLine
that we can use to create such a function:try
,catch
andfinally
are functions with the following types:And we can just use
catch
andfinally
withouttry
as we have done ineachLine
above. Please see this note from Frege source on whentry
is necessary.