+
+\begin{code}
+compiler_version :: String
+compiler_version =
+ case (show opt_HiVersion) of
+ [x] -> ['0','.',x]
+ ls@[x,y] -> "0." ++ ls
+ ls -> go ls
+ where
+ -- 10232353 => 10232.53
+ go ls@[x,y] = '.':ls
+ go (x:xs) = x:go xs
+
+\end{code}
+
+\begin{code}
+reportCompile :: String -> String -> IO ()
+#if REPORT_TO_MOTHERLODE && __GLASGOW_HASKELL__ >= 303
+reportCompile mod_name info
+ | not opt_ReportCompile = return ()
+ | otherwise = (do
+ sock <- udpSocket 0
+ addr <- motherShip
+ sendTo sock (mod_name++ ';': compiler_version ++ ';': os ++ ';':arch ++ '\n':' ':info ++ "\n") addr
+ return ()) `catch` (\ _ -> return ())
+
+motherShip :: IO SockAddr
+motherShip = do
+ he <- getHostByName "laysan.dcs.gla.ac.uk"
+ case (hostAddresses he) of
+ [] -> fail (userError "No address!")
+ (x:_) -> return (SockAddrInet motherShipPort x)
+
+--magick
+motherShipPort :: PortNumber
+motherShipPort = mkPortNumber 12345
+
+-- creates a socket capable of sending datagrams,
+-- binding it to a port
+-- ( 0 => have the system pick next available port no.)
+udpSocket :: Int -> IO Socket
+udpSocket p = do
+ pr <- getProtocolNumber "udp"
+ s <- socket AF_INET Datagram pr
+ bindSocket s (SockAddrInet (mkPortNumber p) iNADDR_ANY)
+ return s
+#else
+reportCompile _ _ = return ()
+#endif
+
+\end{code}