haskell / unix

POSIX functionality
https://hackage.haskell.org/package/unix
Other
107 stars 92 forks source link

System.Posix.User stopped exporting UserEntry #281

Closed joeyh closed 1 year ago

joeyh commented 1 year ago

Prior to unix-2.8.0.0, System.Posix.User exported UserEntry. It no longer does, and it's only available from System.Poxis.User.ByteString. Necessitating some ugly cpp to handle both versions in code that uses the type. I suspect this was an accident, and System.Posix.User should re-export UserEntry.

hasufell commented 1 year ago

It is exported as a pattern synonym: https://hackage.haskell.org/package/unix-2.8.1.1/docs/System-Posix-User.html#v:UserEntry

joeyh commented 1 year ago

I had wrapper function like this, which checked an environment variable like HOME and fell back to getting the value from the UserEntry:

foo :: String -> (UserEntry -> String) -> IO String

The pattern synonym prevents that from compiling.

hasufell commented 1 year ago

You probably want https://hackage.haskell.org/package/unix-2.8.1.1/docs/System-Posix-User.html#v:homeDirectory

Yes, pattere Synonyms are not 100% like record data types. So if you matched with record syntax, it won't compile. If you match with positional arguments or just use the function above, it'll work.