How to parse a Haskell file without making it a module

I was just starting to write a Haskell golf program for Haskell (to minimize the number of characters), but I ran into the problem of parsing. When I use the function parseModulefrom Language.Haskell.Parser, it adds the module declaration to the file. Obviously, this is not what I want, because it adds extra characters!

So, for a program containing some code presented ..., the output will be like this.

module Main (main) where { main = do {  ...  }}

Is there a simple solution for this, or will I have to change the HsModulereturned from parseModuleto output the file without declaring the module?

+4
source share

Source: https://habr.com/ru/post/1533991/


All Articles