-- for-loop
nTimes,
+ -- maybe-ish
+ unJust,
+
-- sorting
IF_NOT_GHC(quicksort COMMA stableSortLt COMMA mergesort COMMA)
sortLt,
mapAccumL, mapAccumR, mapAccumB, foldl2, count,
-- comparisons
- thenCmp, cmpList, prefixMatch, postfixMatch,
+ thenCmp, cmpList, prefixMatch, suffixMatch,
-- strictness
seqList, ($!),
#endif
, global
- , myProcessID
+ , myGetProcessID
#if __GLASGOW_HASKELL__ <= 408
, catchJust
#include "HsVersions.h"
-import IO ( hPutStrLn, stderr )
import List ( zipWith4 )
+import Maybe ( Maybe(..) )
import Panic ( panic )
import IOExts ( IORef, newIORef, unsafePerformIO )
import FastTypes
#if __GLASGOW_HASKELL__ <= 408
import Exception ( catchIO, justIoErrors, raiseInThread )
#endif
+#ifndef mingw32_TARGET_OS
+import Posix
+#endif
infixr 9 `thenCmp`
\end{code}
nTimes n f = f . nTimes (n-1) f
\end{code}
+%************************************************************************
+%* *
+\subsection{Maybe-ery}
+%* *
+%************************************************************************
+
+\begin{code}
+unJust :: String -> Maybe a -> a
+unJust who (Just x) = x
+unJust who Nothing = panic ("unJust of Nothing, called by " ++ who)
+\end{code}
%************************************************************************
%* *
prefixMatch (p:ps) (s:ss) | p == s = prefixMatch ps ss
| otherwise = False
-postfixMatch :: Eq a => [a] -> [a] -> Bool
-postfixMatch pat str = prefixMatch (reverse pat) (reverse str)
+suffixMatch :: Eq a => [a] -> [a] -> Bool
+suffixMatch pat str = prefixMatch (reverse pat) (reverse str)
\end{code}
%************************************************************************
#endif
#ifdef mingw32_TARGET_OS
-foreign import "_getpid" myProcessID :: IO Int
+foreign import "_getpid" myGetProcessID :: IO Int
#else
-myProcessID :: IO Int
-myProcessID = do hPutStrLn stderr "Warning:myProcessID"
- return 12345
+myGetProcessID :: IO Int
+myGetProcessID = Posix.getProcessID
#endif
\end{code}