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,finallyandBufferedReader.getLinethat we can use to create such a function:try,catchandfinallyare functions with the following types:And we can just use
catchandfinallywithouttryas we have done ineachLineabove. Please see this note from Frege source on whentryis necessary.