Zulip Chat Archive

Stream: general

Topic: How to read file (text or binary) properly


Jihoon Hyun (Mar 18 2025 at 05:29):

How can I read a file in Lean4? Is there a minimal example?

Vlad Tsyrklevich (Mar 18 2025 at 05:54):

ChatGPT generated this working example

def readFileExample (filePath : System.FilePath) : IO String :=
  IO.FS.readFile filePath

#eval do
  let contents  readFileExample "/tmp/foo"
  IO.println contents

Jihoon Hyun (Mar 18 2025 at 06:12):

Thanks! That's one good example.


Last updated: May 02 2025 at 03:31 UTC