- 이건 왜 HfM에서 표시가 안 되지?
let notNull x = not (null x) in filter notNull [[1,2,3],[],[3,4,5],[2,2],[],[],[]]
import Data.List let (a,b) = splitAt 3 "foobar" in b ++ a
There is no String "inside" an IO String
Many new Haskell users end up at some point asking a question like "I have an
IO String
, how do I turn it into a String
?", or, "How do I get the String
out of an IO String
?". Give the above intuition, it should be clear that these are nonsensical questions: a value of type IO String
is a description of some computation a recipe, for generating a String
. There is no String
"inside" an IO String
, any more than there is a cake "inside" a cake recipe. To produce a String
(or a delicious cake) requires actually executing the computation (or recipe). And the only way to do that is to give it (perhaps as part of some larger IO
value) to the Haskell runtime system, via main.