Aelve Codesearch

grep over package repositories
Please provide a string to search for.
3+ characters are required.
Index updated 2 hours ago

total matches: 94

computational-geometry-0.1.0.3
1 matches
src/Geometry/SetOperations/BSP.hs
denormalizeBSP :: Ord n => BSP n -> (BSP Int, IntMap n)
denormalizeBSP bsp = (fmap f bsp, fsMap)
    where
    fs    = ordNub $ destructBinaryTree bsp
    isMap = Map.fromList $ zip fs [0..]
    fsMap = IntMap.fromList $ zip [0..] fs

    f p = Map.findWithDefault (-1) p isMap


            
graphql-api-0.4.0
5 matches
src/GraphQL/Internal/OrderedMap.hs
-- return an 'OrderedMap', preserving the order.
orderedMap :: forall key value. Ord key => [(key, value)] -> Maybe (OrderedMap key value)
orderedMap entries
  | ks == ordNub ks = Just (OrderedMap ks (Map.fromList entries))
  | otherwise = Nothing
  where
    ks = map fst entries

            
src/GraphQL/Internal/Validation.hs
-- | Return a list of all the elements with duplicates. The list of duplicates
-- itself will not contain duplicates.
--
-- prop> \xs -> findDuplicates @Int xs == ordNub (findDuplicates @Int xs)
findDuplicates :: Ord a => [a] -> [a]
findDuplicates xs = findDups (sort xs)
  where
    findDups [] = []
    findDups [_] = []

            
tests/OrderedMapSpec.hs
    prop "keys == map fst . Map.toList" $ do
      forAll orderedMaps (\x -> OrderedMap.keys x == map fst (OrderedMap.toList x))
    prop "has unique keys" $ do
      forAll orderedMaps (\x -> let ks = OrderedMap.keys x in ks == ordNub ks)
    prop "all keys can be looked up" $ do
      forAll orderedMaps (\x -> let keys = OrderedMap.keys x
                                    values = OrderedMap.values x
                                in mapMaybe (flip OrderedMap.lookup x) keys == values)
    it "empty is orderedMap []" $ do

            
tests/ValidationSpec.hs

  describe "findDuplicates" $ do
    prop "returns empty on unique lists" $ do
      \xs -> findDuplicates @Int (ordNub xs) === []
    prop "finds only duplicates" $ \xs -> do
      all (>1) (count xs <$> findDuplicates @Int xs)
    prop "finds all duplicates" $ \xs -> do
      (sort . findDuplicates @Int) xs === (ordNub . sort . filter ((> 1) . count xs)) xs


-- | Count the number of times 'x' occurs in 'xs'.
count :: Eq a => [a] -> a -> Int
count xs x = (length . filter (== x)) xs

            
tests/ValueSpec.hs
-- | All of the fields in an object should have unique names.
prop_fieldsUnique :: Object -> Bool
prop_fieldsUnique object =
  fieldNames == ordNub fieldNames
  where
    fieldNames = [name | ObjectField name _ <- objectFields object]

            
interlude-l-0.5.0.0
1 matches
src/Interlude.hs
                 , pshow, perror, pread, noWarnUndefined, perrorToFile ) where

import qualified Prelude
import Protolude as X hiding ( (&), catch, try, (<.>), wait, filter, ordNub
                             , catMaybes, mapMaybe, handle, catches
                             , (<$!>), (<&>) )
import Prelude as X (error)
import Control.Monad.Catch as X ( MonadThrow, MonadCatch, catch, throwM, try, handle, catches
                                , Handler(..), handleIf, catchIf )

            
pandoc-2.2.1
10 matches
src/Text/Pandoc/App.hs
import Text.Pandoc.PDF (makePDF)
import Text.Pandoc.SelfContained (makeDataURI, makeSelfContained)
import Text.Pandoc.Shared (eastAsianLineBreakFilter, stripEmptyParagraphs,
         headerShift, isURI, ordNub, safeRead, tabFilter, uriPathToPath)
import qualified Text.Pandoc.UTF8 as UTF8
import Text.Pandoc.Writers.Math (defaultKaTeXURL, defaultMathJaxURL)
import Text.Pandoc.XML (toEntities)
import Text.Printf
#ifndef _WINDOWS

            
src/Text/Pandoc/App.hs
          ]

pdfEngines :: [String]
pdfEngines = ordNub $ map snd engines

pdfWriterAndProg :: Maybe String              -- ^ user-specified writer name
                 -> Maybe String              -- ^ user-specified pdf-engine
                 -> IO (String, Maybe String) -- ^ IO (writerName, maybePdfEngineProg)
pdfWriterAndProg mWriter mEngine = do

            
src/Text/Pandoc/Readers/LaTeX.hs
  guard $ name /= "begin" && name /= "end"
  star <- option "" ("*" <$ symbol '*' <* optional sp)
  let name' = name <> star
  let names = ordNub [name', name] -- check non-starred as fallback
  let raw = do
       guard $ isInlineCommand name || not (isBlockCommand name)
       rawcommand <- getRawCommand name (cmd <> star)
       (guardEnabled Ext_raw_tex >> return (rawInline "latex" rawcommand))
         <|> ignore rawcommand

            
src/Text/Pandoc/Readers/LaTeX.hs
  guard $ name /= "begin" && name /= "end"
  star <- option "" ("*" <$ symbol '*' <* optional sp)
  let name' = name <> star
  let names = ordNub [name', name]
  let rawDefiniteBlock = do
        guard $ isBlockCommand name
        rawBlock "latex" <$> getRawCommand name (txt <> star)
  -- heuristic:  if it could be either block or inline, we
  -- treat it if block if we have a sequence of block

            
src/Text/Pandoc/Readers/LaTeX.hs
                       lookup "lastline" options >>= safeRead
  let codeContents = intercalate "\n" $ take (1 + lastline - firstline) $
                       drop (firstline - 1) codeLines
  return $ codeBlockWith (ident,ordNub (classes ++ language),kvs) codeContents

-- lists

item :: PandocMonad m => LP m Blocks
item = void blocks *> controlSeq "item" *> skipopts *> blocks

            
src/Text/Pandoc/Shared.hs
                     splitByIndices,
                     splitStringByIndices,
                     substitute,
                     ordNub,
                     -- * Text processing
                     backslashEscapes,
                     escapeStringUsing,
                     stripTrailingNewlines,
                     trim,

            
src/Text/Pandoc/Shared.hs
      Just lst' -> replacement ++ substitute target replacement lst'
      Nothing   -> x : substitute target replacement xs

ordNub :: (Ord a) => [a] -> [a]
ordNub l = go Set.empty l
  where
    go _ [] = []
    go s (x:xs) = if x `Set.member` s then go s xs
                                      else x : go (Set.insert x s) xs


            
src/Text/Pandoc/Writers/Docx.hs

mkNumbering :: (PandocMonad m) => [ListMarker] -> m [Element]
mkNumbering lists = do
  elts <- evalStateT (mapM mkAbstractNum (ordNub lists)) (mkStdGen 1848)
  return $ elts ++ zipWith mkNum lists [baseListId..(baseListId + length lists - 1)]

maxListLevel :: Int
maxListLevel = 8


            
src/Text/Pandoc/Writers/LaTeX.hs
  titleMeta <- stringToLaTeX TextString $ stringify $ docTitle meta
  authorsMeta <- mapM (stringToLaTeX TextString . stringify) $ docAuthors meta
  docLangs <- catMaybes <$>
      mapM (toLang . Just) (ordNub (query (extract "lang") blocks))
  let hasStringValue x = isJust (getField x metadata :: Maybe String)
  let geometryFromMargins = intercalate [','] $ mapMaybe (\(x,y) ->
                                ((x ++ "=") ++) <$> getField y metadata)
                              [("lmargin","margin-left")
                              ,("rmargin","margin-right")

            
src/Text/Pandoc/Writers/Ms.hs
        colordefs = map toColorDef allcolors
        toColorDef c = text (".defcolor " ++
            hexColor c ++ " rgb #" ++ hexColor c)
        allcolors = catMaybes $ ordNub $
          [defaultColor sty, backgroundColor sty,
           lineNumberColor sty, lineNumberBackgroundColor sty] ++
           concatMap (colorsForToken. snd) (Map.toList (tokenStyles sty))
        colorsForToken ts = [tokenColor ts, tokenBackground ts]


            
pandoc-citeproc-0.16.3.1
4 matches
src/Text/CSL/Pandoc.hs
import           Text.HTML.TagSoup.Entity (lookupEntity)
import           Text.Pandoc
import           Text.Pandoc.Builder      (deleteMeta, setMeta)
import           Text.Pandoc.Shared       (stringify, ordNub)
import           Text.Pandoc.Walk
import           Text.Parsec              hiding (State, (<|>))

-- | Process a 'Pandoc' document by adding citations formatted
-- according to a CSL style.  Add a bibliography (if one is called

            
src/Text/CSL/Pandoc.hs
   go (Div ("refs",cs,kvs) xs) = do
     put True
     -- refHeader isn't used if you have an explicit references div
     let cs' = ordNub $ cs ++ refclasses
     return $ Div ("refs",cs',kvs) (xs ++ refs)
   go x = return x
   addUnNumbered cs = "unnumbered" : [c | c <- cs, c /= "unnumbered"]
   refHeader = case refTitle meta of
                Just ils ->

            
src/Text/CSL/Proc/Disamb.hs
import           Text.CSL.Reference
import           Text.CSL.Style
import           Text.CSL.Util      (proc, query)
import           Text.Pandoc.Shared (ordNub)

-- | Given the 'Style', the list of references and the citation
-- groups, disambiguate citations according to the style options.
disambCitations :: Style -> [Reference] -> Citations -> [CitationGroup]
                -> ([(String, String)], [CitationGroup])

            
src/Text/CSL/Proc/Disamb.hs
      duplicates = filter (flip elem (getDuplNames g) . collide) nameData

getDuplNames :: [CitationGroup] -> [[Output]]
getDuplNames = ordNub . catMaybes . snd . mapAccumL dupl [] . getData
    where
      getData = concatMap (mapGroupOutput getName)
      dupl a c = if nameCollision c `elem` map nameCollision a
                 then (a,Just $ nameCollision c)
                 else (c:a,Nothing)

            
protolude-0.2.4
2 matches
src/Protolude/List.hs

module Protolude.List (
  head,
  ordNub,
  sortOn,
  list,
  product,
  sum,
  groupBy,

            
src/Protolude/List.hs
sortOn = sortBy . comparing

-- O(n * log n)
ordNub :: (Ord a) => [a] -> [a]
ordNub l = go Set.empty l
  where
    go _ []     = []
    go s (x:xs) =
      if x `Set.member` s
      then go s xs

            
purescript-0.13.5
7 matches
src/Language/PureScript/Bundle.hs
  ) where

import Prelude.Compat
import Protolude (ordNub)

import Control.Monad
import Control.Monad.Error.Class
import Control.Arrow ((&&&))


            
src/Language/PureScript/Bundle.hs

  -- | Calculate dependencies and add them to the current element.
  expandDeps :: ModuleElement -> ModuleElement
  expandDeps (Member n f nm decl _) = Member n f nm decl (ordNub $ dependencies modulePath decl)
  expandDeps (ExportsList exps) = ExportsList (map expand exps)
      where
      expand (ty, nm, n1, _) = (ty, nm, n1, ordNub (dependencies modulePath n1))
  expandDeps other = other

  dependencies :: ModuleIdentifier -> JSExpression -> [Key]
  dependencies m = everythingWithContext boundNames (++) (mkQ (const [] &&& id) toReference)
    where

            
src/Language/PureScript/CodeGen/JS.hs
  ) where

import Prelude.Compat
import Protolude (ordNub)

import Control.Arrow ((&&&))
import Control.Monad (forM, replicateM, void)
import Control.Monad.Except (MonadError, throwError)
import Control.Monad.Reader (MonadReader, asks)

            
src/Language/PureScript/CodeGen/JS.hs
    let usedModuleNames = foldMap (foldMap (findModules mnReverseLookup)) optimized
    jsImports <- traverse (importToJs mnLookup)
      . filter (flip S.member usedModuleNames)
      . (\\ (mn : C.primModules)) $ ordNub $ map snd imps
    F.traverse_ (F.traverse_ checkIntegers) optimized
    comments <- not <$> asks optionsNoComments
    let strict = AST.StringLiteral Nothing "use strict"
    let header = if comments && not (null coms) then AST.Comment Nothing coms strict else strict
    let foreign' = [AST.VariableIntroduction Nothing "$foreign" foreign_ | not $ null foreigns || isNothing foreign_]

            
src/Language/PureScript/CoreFn/Desugar.hs
module Language.PureScript.CoreFn.Desugar (moduleToCoreFn) where

import Prelude.Compat
import Protolude (ordNub)

import Control.Arrow (second)

import Data.Function (on)
import Data.List (sort, sortBy)

            
src/Language/PureScript/CoreFn/Desugar.hs
moduleToCoreFn env (A.Module modSS coms mn decls (Just exps)) =
  let imports = mapMaybe importToCoreFn decls ++ fmap (ssAnn modSS,) (findQualModules decls)
      imports' = dedupeImports imports
      exps' = ordNub $ concatMap exportToCoreFn exps
      externs = ordNub $ mapMaybe externToCoreFn decls
      decls' = concatMap declToCoreFn decls
  in Module modSS coms mn (spanName modSS) imports' exps' externs decls'

  where


            
src/Language/PureScript/CoreImp/Optimizer/MagicDo.hs
module Language.PureScript.CoreImp.Optimizer.MagicDo (magicDoEffect, magicDoEff, magicDoST, inlineST) where

import Prelude.Compat
import Protolude (ordNub)

import Data.Maybe (fromJust, isJust)
import Data.Text (Text)

import Language.PureScript.CoreImp.AST