File: Hoogle.hs

package info (click to toggle)
haskell-hoogle 5.0.17.3%2Bdfsg1-5
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 496 kB
  • sloc: haskell: 2,890; ansic: 110; sh: 33; xml: 20; makefile: 3
file content (50 lines) | stat: -rw-r--r-- 1,311 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

-- | High level Hoogle API
module Hoogle(
    Database, withDatabase, searchDatabase, defaultDatabaseLocation,
    Target(..), URL,
    hoogle,
    targetInfo,
    targetResultDisplay
    ) where

import Control.DeepSeq (NFData)

import Query
import Input.Item
import General.Util
import General.Store

import Action.CmdLine
import Action.Generate
import Action.Search
import Action.Server
import Action.Test


-- | Database containing Hoogle search data.
newtype Database = Database StoreRead

-- | Load a database from a file.
withDatabase :: NFData a => FilePath -> (Database -> IO a) -> IO a
withDatabase file act = storeReadFile file $ act . Database

-- | The default location of a database
defaultDatabaseLocation :: IO FilePath
defaultDatabaseLocation = defaultDatabaseLang Haskell

-- | Search a database, given a query string, produces a list of results.
searchDatabase :: Database -> String -> [Target]
searchDatabase (Database db) query = snd $ search db $ parseQuery query


-- | Run a command line Hoogle operation.
hoogle :: [String] -> IO ()
hoogle args = do
    args <- getCmdLine args
    case args of
        Search{} -> actionSearch args
        Generate{} -> actionGenerate args
        Server{} -> actionServer args
        Test{} -> actionTest args
        Replay{} -> actionReplay args