Aelve Codesearch

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

total matches: 73

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 )

            
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
21 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

            
src/Language/PureScript/CoreImp/Optimizer/MagicDo.hs
  -- If all STRefs are used in the scope of the same runST, only using { read, write, modify }STRef then
  -- we can be more aggressive about inlining, and actually turn STRefs into local variables.
  convertBlock (App s1 f [arg]) | isSTFunc C.runST f =
    let refs = ordNub . findSTRefsIn $ arg
        usages = findAllSTUsagesIn arg
        allUsagesAreLocalVars = all (\u -> let v = toVar u in isJust v && fromJust v `elem` refs) usages
        localVarsDoNotEscape = all (\r -> length (r `appearingIn` arg) == length (filter (\u -> let v = toVar u in v == Just r) usages)) refs
    in App s1 (everywhere (convert (allUsagesAreLocalVars && localVarsDoNotEscape)) arg) []
  convertBlock other = other

            
src/Language/PureScript/Docs/Convert/Single.hs
  Just (Left ((classNameString, AugmentClass) : map (, AugmentType) typeNameStrings, AugmentChild childDecl))
  where
  classNameString = unQual className
  typeNameStrings = ordNub (concatMap (P.everythingOnTypes (++) extractProperNames) tys)
  unQual x = let (P.Qualified _ y) = x in P.runProperName y

  extractProperNames (P.TypeConstructor _ n) = [unQual n]
  extractProperNames _ = []


            
src/Language/PureScript/Environment.hs
module Language.PureScript.Environment where

import           Prelude.Compat
import           Protolude (ordNub)

import           GHC.Generics (Generic)
import           Control.DeepSeq (NFData)
import           Data.Aeson ((.=), (.:))
import qualified Data.Aeson as A

            
src/Language/PureScript/Environment.hs
      (src, fdDetermined fd) : map (, []) (fdDetermined fd)

    -- build a graph of which arguments determine other arguments
    (depGraph, fromVertex, fromKey) = G.graphFromEdges ((\(n, v) -> (n, n, ordNub v)) <$> M.toList contributingDeps)

    -- do there exist any arguments that contribute to `arg` that `arg` doesn't contribute to
    isFunDepDetermined :: Int -> Bool
    isFunDepDetermined arg = case fromKey arg of
      Nothing -> internalError "Unknown argument index in makeTypeClassData"

            
src/Language/PureScript/Errors.hs
  ) where

import           Prelude.Compat
import           Protolude (ordNub)

import           Control.Arrow ((&&&))
import           Control.Exception (displayException)
import           Control.Monad
import           Control.Monad.Error.Class (MonadError(..))

            
src/Language/PureScript/Errors.hs
  separate   _ [m]    = m
  separate sep (m:ms) = m ++ sep ++ separate sep ms

  clean             = ordNub . filter (not . null)

-- | Indent to the right, and pad on top and bottom.
indent :: Box.Box -> Box.Box
indent = Box.moveUp 1 . Box.moveDown 1 . Box.moveRight 2


            
src/Language/PureScript/Hierarchy.hs
module Language.PureScript.Hierarchy where

import           Prelude.Compat
import           Protolude (ordNub)

import           Data.List (sort)
import qualified Data.Text as T
import qualified Language.PureScript as P


            
src/Language/PureScript/Hierarchy.hs
  if null supers then Nothing else Just (Graph name graph)
    where
      name = runModuleName moduleName
      supers = sort . ordNub $ concatMap superClasses decls
      graph = Digraph $ typeClassPrologue name <> typeClassBody supers <> typeClassEpilogue

typeClassPrologue :: GraphName -> T.Text
typeClassPrologue (GraphName name) = "digraph " <> name <> " {\n"


            
src/Language/PureScript/Ide/Error.hs
      Aeson.Object
        (HM.insert "pursIde"
         (object [ "name" .= name
                 , "completions" .= (ordNub (map identCompletion idents ++ map fieldCompletion fields))
                 ]) value)
    insertTSCompletions _ _ _ v = v

    identCompletion (P.Qualified mn i, ty) =
      Completion (maybe "" P.runModuleName mn) i (prettyPrintTypeSingleLine ty) (prettyPrintTypeSingleLine ty) Nothing Nothing (maybe [] (\x -> [x]) mn)

            
src/Language/PureScript/Interactive/Completion.hs
  ) where

import Prelude.Compat
import Protolude (ordNub)

import           Control.Monad.IO.Class (MonadIO(..))
import           Control.Monad.State.Class (MonadState(..))
import           Control.Monad.Trans.Reader (asks, runReaderT, ReaderT)
import           Data.List (nub, isPrefixOf, isInfixOf, isSuffixOf, sortBy, stripPrefix)

            
src/Language/PureScript/Interactive/Completion.hs
              ++ map (T.unpack . P.runOpName) exportedTypeOps

moduleNames :: [P.Module] -> [String]
moduleNames = ordNub . map (T.unpack . P.runModuleName . P.getModuleName)

            
src/Language/PureScript/Interactive.hs

import           Prelude ()
import           Prelude.Compat
import           Protolude (ordNub)

import           Data.List (sort, find, foldl')
import           Data.Maybe (fromMaybe, mapMaybe)
import qualified Data.Map as M
import qualified Data.Set as S

            
src/Language/PureScript/Interactive.hs
    loadedModules <- gets psciLoadedExterns
    print' $ readModules loadedModules
  where
    readModules = unlines . sort . ordNub . map (T.unpack . P.runModuleName . P.getModuleName . fst)

-- | Show the imported modules in psci.
handleShowImportedModules
  :: (MonadState PSCiState m, MonadIO m)
  => (String -> m ())

            
src/Language/PureScript/Linter/Exhaustive.hs
  ) where

import Prelude.Compat
import Protolude (ordNub)

import Control.Applicative
import Control.Arrow (first, second)
import Control.Monad (unless)
import Control.Monad.Writer.Class