    module Data.XCB.Utils where

    -- random utility functions

    import Data.Char
    import Control.Applicative

    ensureUpper :: String -> String
    ensureUpper :: String -> String
    ensureUpper [] = []
    ensureUpper (Char
    x:String
    xs) = (Char -> Char
    toUpper Char
    x) Char -> String -> String
    forall a. a -> [a] -> [a]
    : String
    xs

    -- |Like mapMaybe, but for any Alternative.
    -- Never returns 'empty', instead returns 'pure []'
    mapAlt :: Alternative f => (a -> f b) -> [a] -> f [b]
    mapAlt :: forall (f :: * -> *) a b.
    Alternative f =>
    (a -> f b) -> [a] -> f [b]
    mapAlt a -> f b
    f [a]
    xs = [a] -> f [b]
    go [a]
    xs
     where go :: [a] -> f [b]
    go [] = [b] -> f [b]
    forall a. a -> f a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure []
           go (a
    y:[a]
    ys) = (b -> [b] -> [b]) -> f (b -> [b] -> [b])
    forall a. a -> f a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure (:) f (b -> [b] -> [b]) -> f b -> f ([b] -> [b])
    forall a b. f (a -> b) -> f a -> f b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> a -> f b
    f a
    y f ([b] -> [b]) -> f [b] -> f [b]
    forall a b. f (a -> b) -> f a -> f b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> [a] -> f [b]
    go [a]
    ys
                   f [b] -> f [b] -> f [b]
    forall a. f a -> f a -> f a
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> [a] -> f [b]
    go [a]
    ys