Haskell - How can I use pure functions inside IO functions?

前端 未结 4 1842
清歌不尽
清歌不尽 2021-01-19 00:14

How can I use pure functions inside IO functions? :-/

For example: I\'m reading a file (IO function) and I want to parse its context, a string, by using a pure funct

4条回答
  •  悲&欢浪女
    2021-01-19 00:37

    The actual answer is as follows:

    main = do
      val <- return (purefunc ...arguments...)
      ...more..actions...

    return wraps it in the appropriate monad so that do can assign it to val.

提交回复
热议问题