Verified Commit b6196106 authored by Camil Staps's avatar Camil Staps 🙂

Add toSingleLine; resolves #1

parent 7d55da2f
......@@ -243,6 +243,7 @@ instance < Result
instance == FunctionKind
toSingleLine :: Request -> Maybe String
parseSingleLineRequest :: String -> MaybeErrorString Request
toHTTPRequest :: Request -> HTTPRequest
......
implementation module Cloogle
import StdBool
from StdFunc import o
import StdOverloaded
......@@ -92,6 +93,16 @@ parseSingleLineRequest s = case split "::" s of
[name] -> Ok {zero & name=Just $ trim name }
_ -> Error "Multiple ::s found"
toSingleLine :: Request -> Maybe String
toSingleLine req
| isJust req.typeName && isJust req.className = Nothing
| isJust req.typeName = req.typeName
| isJust req.className = req.className
| isJust req.unify = case req.name of
Nothing -> Just $ ":: " + fromJust req.unify
Just n -> Just $ n + " :: " + fromJust req.unify
| otherwise = req.name
toHTTPRequest :: Request -> HTTPRequest
toHTTPRequest req =
{ newHTTPRequest
......@@ -103,7 +114,7 @@ toHTTPRequest req =
}
where
params = catMaybes
[ Just ("str",searchStr)
[ tuple "str" <$> toSingleLine req
, tuple "lib" o join "," <$> req.libraries
, tuple "mod" o join "," <$> req.modules
, tuple "include_builtins" o printBool <$> req.include_builtins
......@@ -112,15 +123,6 @@ where
]
where printBool b = if b "true" "false"
searchStr
| isJust req.typeName = fromJust req.typeName
| isJust req.className = fromJust req.className
| isJust req.unify = case req.name of
Nothing -> ":: " + fromJust req.unify
Just n -> n + " :: " + fromJust req.unify
| isJust req.name = fromJust req.name
| otherwise = ""
request :: Request *World -> *(MaybeErrorString Response, *World)
request req w = appFst ((=<<) parseResponse) $ doHTTPRequest (toHTTPRequest req) 10000 w
where
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment