diff --git a/Sym/Internal/CLongArray.hs b/Sym/Internal/CLongArray.hs
--- a/Sym/Internal/CLongArray.hs
+++ b/Sym/Internal/CLongArray.hs
@@ -21,6 +21,7 @@
     , size
     , at
     , unsafeAt
+    , elemIndices
 
     -- * Map
     , imap
@@ -120,6 +121,18 @@
 unsafeAt :: CLongArray -> Int -> Int
 unsafeAt w = fromIntegral . inlinePerformIO . unsafeWith w . flip peekElemOff
 {-# INLINE unsafeAt #-}
+
+-- | The indices of all elements equal to the query element, in
+-- ascending order.
+elemIndices :: CLong -> CLongArray -> [Int]
+elemIndices x w = inlinePerformIO $ unsafeWith w (go 0)
+  where
+    n = size w
+    go i p
+      | i >= n = return []
+      | otherwise = do
+          y <- peek p
+          ([ i | y == x ] ++) `fmap` go (i+1) (advancePtr p 1)
 
 
 -- Map and Zip
diff --git a/Sym/Internal/Util.hs b/Sym/Internal/Util.hs
--- a/Sym/Internal/Util.hs
+++ b/Sym/Internal/Util.hs
@@ -17,14 +17,14 @@
 import Data.Set (Set)
 import qualified Data.Set as S
 
--- | The set of minimal elements with respect to inclusion.
+-- | The list of minimal sets with respect to inclusion.
 minima :: Ord a => [Set a] -> [Set a]
 minima = minima' . sortBy (comparing S.size)
   where
     minima' [] = []
     minima' (x:xs) = x : minima' [ y | y<-xs, not (x `S.isSubsetOf` y) ]
 
--- | The set of maximal elements with respect to the given order.
+-- | The list of maximal sets with respect to inclusion.
 maxima :: Ord a => [Set a] -> [Set a]
 maxima = maxima' . sortBy (comparing $ \x -> -S.size x)
   where
diff --git a/Sym/Perm/MeshPattern.hs b/Sym/Perm/MeshPattern.hs
--- a/Sym/Perm/MeshPattern.hs
+++ b/Sym/Perm/MeshPattern.hs
@@ -9,7 +9,6 @@
     ( MeshPattern (..)
     , Mesh
     , Box
-    , Point
     , mkPattern
     , pattern
     , mesh
@@ -37,9 +36,13 @@
 import qualified Data.Set as Set
 import Sym.Internal.Util
 
+-- | A mesh is a, possibly empty, set of shaded boxes.
+type Mesh = Set Box
+
+-- | A box is represented by the coordinates of its southwest corner.
+type Box  = (Int, Int)
+
 type Point = (Int, Int)
-type Box   = (Int, Int)
-type Mesh  = Set Box
 type PermTwoLine = [Point]
 
 data MeshPattern = MP
@@ -76,7 +79,6 @@
 
 kVincular :: Int -> Perm -> [MeshPattern]
 kVincular k w = (flip cols (pattern w) . toList) `fmap` ((1+size w) `choose` k)
--- kVincular k w = (\xs -> cols (toList xs) (pattern w)) `fmap` ((1+size w) `choose` k)
 
 vincular :: Perm -> [MeshPattern]
 vincular w = [0..1+size w] >>= flip kVincular w
diff --git a/Sym/Perm/Stat.hs b/Sym/Perm/Stat.hs
--- a/Sym/Perm/Stat.hs
+++ b/Sym/Perm/Stat.hs
@@ -47,7 +47,6 @@
     ) where
 
 import Prelude hiding (head, last)
-import qualified Prelude
 import Sym.Perm
 import qualified Sym.Perm.SSYT as Y
 import qualified Sym.Perm.D8 as D8
diff --git a/Sym/Permgram.hs b/Sym/Permgram.hs
--- a/Sym/Permgram.hs
+++ b/Sym/Permgram.hs
@@ -22,6 +22,8 @@
 
 import Data.Ord
 import Data.List
+import Control.Monad
+import Control.Applicative
 import Sym.Perm (Perm)
 import qualified Sym.Perm as P
 import Data.Array.Unboxed
@@ -79,6 +81,10 @@
 instance Monad Permgram where
     return x = permgram (P.fromList [0]) [x]
     w >>= f  = joinPermgram $ fmap f w
+
+instance Applicative Permgram where
+    pure  = return
+    (<*>) = ap
 
 joinPermgram :: Permgram (Permgram a) -> Permgram a
 joinPermgram w@(PGram u f) = PGram (P.fromList xs) (listArray (0,m-1) ys)
diff --git a/sym.cabal b/sym.cabal
--- a/sym.cabal
+++ b/sym.cabal
@@ -1,5 +1,5 @@
 name:                sym
-version:             0.11
+version:             0.11.1
 synopsis:            Permutations, patterns, and statistics
 description:
   Definitions for permutations with an emphasis on permutation
@@ -40,7 +40,7 @@
                        Sym.Internal.Size
                        Sym.Internal.Util
 
-  build-depends:       base >= 3 && <= 4.7,
+  build-depends:       base >= 3 && <= 5,
                        array >=0.4,
                        hashable >=1.1,
                        containers,
