Skip to content

Instantly share code, notes, and snippets.

@Tarrasch
Created August 23, 2011 12:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tarrasch/1164962 to your computer and use it in GitHub Desktop.
Save Tarrasch/1164962 to your computer and use it in GitHub Desktop.
Module for checking users in mailman list group
module Mailman where
import System.Process (readProcessWithExitCode)
import System.Exit (ExitCode(..))
import Data.List
type MailingList = String
-- Before using this module:
-- Make sure you have `list_members` command available, and that you don't
-- get any permission denied errors when using it with any user.
-- > listsToCids "kalle@anka.se\nrarash@student.chalmers.se\nolle@gmail.com"
-- ["rarash"]
listsToCids :: String -> [String]
listsToCids = map (takeWhile (/='@'))
. filter (isSuffixOf "@student.chalmers.se")
. lines
getMembers :: MailingList -> IO(Either String [String])
getMembers maillist = do
(exitCode, sout, serr) <- readProcessWithExitCode "list_members" [maillist] ""
case exitCode of
ExitSuccess -> return $ Right $ listsToCids sout
_ -> return $ Left $ show exitCode ++ ":\n\n" ++ serr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment