hsdev 0.3.2.3 → 0.3.3.0
raw patch · 13 files changed
+327/−316 lines, 13 filesdep +http-clientdep +network-uridep −HTTPdep −traverse-with-classdep ~networkPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies added: http-client, network-uri
Dependencies removed: HTTP, traverse-with-class
Dependency ranges changed: network
API changes (from Hackage documentation)
+ HsDev.Database.Update.Types: [sessionHTTPManager] :: Session -> Manager
+ HsDev.Server.Types: [sessionHTTPManager] :: Session -> Manager
+ HsDev.Symbols.Name: pattern Name :: Maybe Text -> Text -> Name
- HsDev.Database.Update.Types: Session :: Connection -> String -> SessionLog -> Maybe Watcher -> (Path -> Maybe Text -> IO ()) -> GhcWorker -> Worker (ServerM IO) -> LookupTable (Maybe Path) (Environment, FixitiesTable) -> IO () -> IO () -> Chan (IO ()) -> [(String, String)] -> Session
+ HsDev.Database.Update.Types: Session :: Connection -> String -> SessionLog -> Maybe Watcher -> (Path -> Maybe Text -> IO ()) -> GhcWorker -> Worker (ServerM IO) -> LookupTable (Maybe Path) (Environment, FixitiesTable) -> Manager -> IO () -> IO () -> Chan (IO ()) -> [(String, String)] -> Session
- HsDev.Project.Types: entity :: forall a_a1rM9 a_a1td3. Lens (Extensions a_a1rM9) (Extensions a_a1td3) a_a1rM9 a_a1td3
+ HsDev.Project.Types: entity :: forall a_a1stu a_a1tUo. Lens (Extensions a_a1stu) (Extensions a_a1tUo) a_a1stu a_a1tUo
- HsDev.Project.Types: extensions :: forall a_a1rM9. Lens' (Extensions a_a1rM9) [Extension]
+ HsDev.Project.Types: extensions :: forall a_a1stu. Lens' (Extensions a_a1stu) [Extension]
- HsDev.Project.Types: ghcOptions :: forall a_a1rM9. Lens' (Extensions a_a1rM9) [Text]
+ HsDev.Project.Types: ghcOptions :: forall a_a1stu. Lens' (Extensions a_a1stu) [Text]
- HsDev.Server.Message: message :: forall a_a1S0r a_a1S5P. Lens (Message a_a1S0r) (Message a_a1S5P) a_a1S0r a_a1S5P
+ HsDev.Server.Message: message :: forall a_a1SHM a_a1SNa. Lens (Message a_a1SHM) (Message a_a1SNa) a_a1SHM a_a1SNa
- HsDev.Server.Message: messageId :: forall a_a1S0r. Lens' (Message a_a1S0r) (Maybe String)
+ HsDev.Server.Message: messageId :: forall a_a1SHM. Lens' (Message a_a1SHM) (Maybe String)
- HsDev.Server.Types: Session :: Connection -> String -> SessionLog -> Maybe Watcher -> (Path -> Maybe Text -> IO ()) -> GhcWorker -> Worker (ServerM IO) -> LookupTable (Maybe Path) (Environment, FixitiesTable) -> IO () -> IO () -> Chan (IO ()) -> [(String, String)] -> Session
+ HsDev.Server.Types: Session :: Connection -> String -> SessionLog -> Maybe Watcher -> (Path -> Maybe Text -> IO ()) -> GhcWorker -> Worker (ServerM IO) -> LookupTable (Maybe Path) (Environment, FixitiesTable) -> Manager -> IO () -> IO () -> Chan (IO ()) -> [(String, String)] -> Session
- HsDev.Symbols.Types: inspectedKey :: forall k_a2uPd t_a2uPe a_a2uPf k_a2y4B. Lens (Inspected k_a2uPd t_a2uPe a_a2uPf) (Inspected k_a2y4B t_a2uPe a_a2uPf) k_a2uPd k_a2y4B
+ HsDev.Symbols.Types: inspectedKey :: forall k_a2vww t_a2vwx a_a2vwy k_a2yLU. Lens (Inspected k_a2vww t_a2vwx a_a2vwy) (Inspected k_a2yLU t_a2vwx a_a2vwy) k_a2vww k_a2yLU
- HsDev.Symbols.Types: inspection :: forall k_a2uPd t_a2uPe a_a2uPf. Lens' (Inspected k_a2uPd t_a2uPe a_a2uPf) Inspection
+ HsDev.Symbols.Types: inspection :: forall k_a2vww t_a2vwx a_a2vwy. Lens' (Inspected k_a2vww t_a2vwx a_a2vwy) Inspection
- HsDev.Symbols.Types: inspectionResult :: forall k_a2uPd t_a2uPe a_a2uPf a_a2y4C. Lens (Inspected k_a2uPd t_a2uPe a_a2uPf) (Inspected k_a2uPd t_a2uPe a_a2y4C) (Either HsDevError a_a2uPf) (Either HsDevError a_a2y4C)
+ HsDev.Symbols.Types: inspectionResult :: forall k_a2vww t_a2vwx a_a2vwy a_a2yLV. Lens (Inspected k_a2vww t_a2vwx a_a2vwy) (Inspected k_a2vww t_a2vwx a_a2yLV) (Either HsDevError a_a2vwy) (Either HsDevError a_a2yLV)
- HsDev.Symbols.Types: inspectionTags :: forall k_a2uPd t_a2uPe a_a2uPf t_a2y4D. Lens (Inspected k_a2uPd t_a2uPe a_a2uPf) (Inspected k_a2uPd t_a2y4D a_a2uPf) (Set t_a2uPe) (Set t_a2y4D)
+ HsDev.Symbols.Types: inspectionTags :: forall k_a2vww t_a2vwx a_a2vwy t_a2yLW. Lens (Inspected k_a2vww t_a2vwx a_a2vwy) (Inspected k_a2vww t_a2yLW a_a2vwy) (Set t_a2vwx) (Set t_a2yLW)
- HsDev.Symbols.Types: scopeQualifier :: forall a_a2uPg. Lens' (Scoped a_a2uPg) (Maybe Text)
+ HsDev.Symbols.Types: scopeQualifier :: forall a_a2vwz. Lens' (Scoped a_a2vwz) (Maybe Text)
- HsDev.Symbols.Types: scoped :: forall a_a2uPg a_a2xZt. Lens (Scoped a_a2uPg) (Scoped a_a2xZt) a_a2uPg a_a2xZt
+ HsDev.Symbols.Types: scoped :: forall a_a2vwz a_a2yGM. Lens (Scoped a_a2vwz) (Scoped a_a2yGM) a_a2vwz a_a2yGM
- HsDev.Tools.Hayoo: hayoo :: String -> Maybe Int -> ExceptT String IO HayooResult
+ HsDev.Tools.Hayoo: hayoo :: Manager -> String -> Maybe Int -> ExceptT String IO HayooResult
- HsDev.Tools.Types: note :: forall a_a1VfE a_a1Vry. Lens (Note a_a1VfE) (Note a_a1Vry) a_a1VfE a_a1Vry
+ HsDev.Tools.Types: note :: forall a_a1VWZ a_a1W8T. Lens (Note a_a1VWZ) (Note a_a1W8T) a_a1VWZ a_a1W8T
- HsDev.Tools.Types: noteLevel :: forall a_a1VfE. Lens' (Note a_a1VfE) (Maybe Severity)
+ HsDev.Tools.Types: noteLevel :: forall a_a1VWZ. Lens' (Note a_a1VWZ) (Maybe Severity)
- HsDev.Tools.Types: noteRegion :: forall a_a1VfE. Lens' (Note a_a1VfE) Region
+ HsDev.Tools.Types: noteRegion :: forall a_a1VWZ. Lens' (Note a_a1VWZ) Region
- HsDev.Tools.Types: noteSource :: forall a_a1VfE. Lens' (Note a_a1VfE) ModuleLocation
+ HsDev.Tools.Types: noteSource :: forall a_a1VWZ. Lens' (Note a_a1VWZ) ModuleLocation
Files
- LICENSE +30/−30
- hsdev.cabal +5/−5
- src/Data/Lisp.hs +126/−126
- src/HsDev/Client/Commands.hs +5/−3
- src/HsDev/Server/Base.hs +5/−2
- src/HsDev/Server/Commands.hs +4/−4
- src/HsDev/Server/Types.hs +2/−0
- src/HsDev/Tools/Hayoo.hs +9/−5
- src/HsDev/Version.hs +17/−17
- src/HsDev/Watcher/Types.hs +14/−14
- src/System/Win32/FileMapping/Memory.hs +53/−53
- tests/test-package/ModuleTwo.hs +21/−21
- tools/hsdev.hs +36/−36
LICENSE view
@@ -1,30 +1,30 @@-Copyright (c) 2013, Alexandr `Voidex` Ruchkin - -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of Alexandr `Voidex` Ruchkin nor the names of other - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +Copyright (c) 2013, Alexandr `Voidex` Ruchkin++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++ * Redistributions in binary form must reproduce the above+ copyright notice, this list of conditions and the following+ disclaimer in the documentation and/or other materials provided+ with the distribution.++ * Neither the name of Alexandr `Voidex` Ruchkin nor the names of other+ contributors may be used to endorse or promote products derived+ from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
hsdev.cabal view
@@ -1,5 +1,5 @@ name: hsdev-version: 0.3.2.3+version: 0.3.3.0 synopsis: Haskell development library description: Haskell development library and tool with support of autocompletion, symbol info, go to declaration, find references, hayoo search etc.@@ -165,7 +165,6 @@ -- Upper bound is set for GHC 8.4 build-depends: base >= 4.9 && < 5,- HTTP >= 4000.3.7 && < 4000.4, aeson >= 1.2.4.0 && < 1.5, aeson-pretty >= 0.8.2 && < 0.9, array >= 0.5.1.1 && < 0.6,@@ -187,13 +186,15 @@ haskell-src-exts >= 1.19.1 && < 1.22.0, hformat >= 0.1.0.1 && < 0.4, hlint >= 2.0.11 && < 2.2,+ http-client >= 0.5 && < 0.7, lens >= 4.14 && < 4.18, lifted-base >= 0.2.3.10 && < 0.3, mmorph >= 1.0.9 && < 1.2, monad-control >= 1.0.1.0 && < 1.1, monad-loops >= 0.4.3 && < 0.5, mtl >= 2.2.1 && < 2.3,- network >= 2.6.3.1 && < 2.9,+ network >= 3.0 && < 3.1,+ network-uri >= 2.6 && < 2.7, optparse-applicative >= 0.12.1.0 && < 0.15, process >= 1.4.2.0 && < 1.7, regex-pcre-builtin >= 0.94.4 && < 0.95,@@ -208,7 +209,6 @@ time >= 1.6.0.1 && < 1.9, transformers >= 0.5.2.0 && < 0.6, transformers-base >= 0.4.4 && < 0.5,- traverse-with-class >= 1.0.0.0 && < 1.1, uniplate >= 1.6.12 && < 1.7, unordered-containers >= 0.2.8.0 && < 0.3, vector >= 0.11.0.0 && < 0.13@@ -231,7 +231,7 @@ filepath >= 1.4.1.0 && < 1.5, monad-loops >= 0.4.3 && < 0.5, mtl >= 2.2.1 && < 2.3,- network >= 2.6.3.1 && < 2.9,+ network >= 3.0 && < 3.1, optparse-applicative >= 0.12.1.0 && < 0.15, process >= 1.4.2.0 && < 1.7, text >= 1.2.2.2 && < 1.3,
src/Data/Lisp.hs view
@@ -1,126 +1,126 @@-module Data.Lisp ( - Lisp(..), - lisp, - encodeLisp, decodeLisp - ) where - -import Prelude hiding (String, Bool) -import qualified Prelude as P (String, Bool) - -import Data.Aeson (ToJSON(..), FromJSON(..), (.=)) -import qualified Data.Aeson as A -import Data.Aeson.Types (parseMaybe, parseEither) -import Data.ByteString.Lazy (ByteString) -import Data.Char (isAlpha, isDigit) -import Data.Either (partitionEithers) -import qualified Data.HashMap.Strict as HM -import Data.List (unfoldr) -import Data.Scientific -import Data.String (fromString) -import qualified Data.Text as T (unpack) -import qualified Data.Text.Lazy as LT (pack, unpack) -import qualified Data.Text.Lazy.Encoding as LT (encodeUtf8, decodeUtf8) -import qualified Text.ParserCombinators.ReadP as R -import Text.Read (readMaybe) -import qualified Data.Vector as V - -data Lisp = - Null | - Bool P.Bool | - Symbol P.String | - String P.String | - Number Scientific | - List [Lisp] - deriving (Eq) - -readable :: Read a => Int -> R.ReadP a -readable = R.readS_to_P . readsPrec - -lisp :: Int -> R.ReadP Lisp -lisp n = R.choice [ - do - s <- symbol - return $ case s of - "null" -> Null - "true" -> Bool True - "false" -> Bool False - _ -> Symbol s, - fmap String string, - fmap Number number, - fmap List list] - where - symbol :: R.ReadP P.String - symbol = concat <$> sequence [ - R.option [] (pure <$> R.char ':'), - pure <$> R.satisfy isAlpha, - R.munch (\ch -> isAlpha ch || isDigit ch || ch == '-')] - - string :: R.ReadP P.String - string = (R.<++ R.pfail) $ do - ('\"':_) <- R.look - readable n - - number :: R.ReadP Scientific - number = do - s <- R.munch1 (\ch -> isDigit ch || ch `elem` ['e', 'E', '.', '+', '-']) - maybe R.pfail return $ readMaybe s - - list :: R.ReadP [Lisp] - list = R.between (R.char '(') (R.char ')') $ R.sepBy (lisp n) R.skipSpaces - -instance Read Lisp where - readsPrec = R.readP_to_S . lisp - -instance Show Lisp where - show Null = "null" - show (Bool b) - | b = "true" - | otherwise = "false" - show (Symbol s) = s - show (String s) = show s - show (Number n) = either show show (floatingOrInteger n :: Either Double Integer) - show (List vs) = "(" ++ unwords (map show vs) ++ ")" - -instance ToJSON Lisp where - toJSON Null = toJSON A.Null - toJSON (Bool b) = toJSON b - toJSON (Symbol s) = toJSON s - toJSON (String s) = toJSON s - toJSON (Number n) = toJSON n - toJSON (List vs) - | null keywords = toJSON $ map toJSON vals - | null vals = keywordsObject - | otherwise = toJSON $ map toJSON vals ++ [keywordsObject] - where - (vals, keywords) = partitionEithers $ unfoldr cutKeyword vs - keywordsObject = A.object [fromString (dropColon k) .= v | (k, v) <- keywords] - - dropColon :: P.String -> P.String - dropColon (':' : s) = s - dropColon s = s - - cutKeyword :: [Lisp] -> Maybe (Either Lisp (P.String, Lisp), [Lisp]) - cutKeyword [] = Nothing - cutKeyword (Symbol s : []) = Just (Right (s, Null), []) - cutKeyword (Symbol s : Symbol h : hs) = Just (Right (s, Null), Symbol h : hs) - cutKeyword (Symbol s : h : hs) = Just (Right (s, h), hs) - cutKeyword (h : hs) = Just (Left h, hs) - -instance FromJSON Lisp where - parseJSON A.Null = return Null - parseJSON (A.Bool b) = return $ Bool b - parseJSON (A.String s) = return $ String $ T.unpack s - parseJSON (A.Number n) = return $ Number n - parseJSON (A.Array vs) = fmap List $ mapM parseJSON $ V.toList vs - parseJSON (A.Object obj) = fmap (List . concat) $ mapM (\(k, v) -> sequence [pure $ Symbol (':' : T.unpack k), parseJSON v]) $ HM.toList obj - -decodeLisp :: FromJSON a => ByteString -> Either P.String a -decodeLisp str = do - sexp <- maybe (Left "Not a s-exp") Right . readMaybe . LT.unpack . LT.decodeUtf8 $ str - parseEither parseJSON $ toJSON (sexp :: Lisp) - -encodeLisp :: ToJSON a => a -> ByteString -encodeLisp r = LT.encodeUtf8 . LT.pack $ maybe - "(:error \"can't convert to s-exp\")" - (show :: Lisp -> P.String) - (parseMaybe parseJSON (toJSON r)) +module Data.Lisp (+ Lisp(..),+ lisp,+ encodeLisp, decodeLisp+ ) where++import Prelude hiding (String, Bool)+import qualified Prelude as P (String, Bool)++import Data.Aeson (ToJSON(..), FromJSON(..), (.=))+import qualified Data.Aeson as A+import Data.Aeson.Types (parseMaybe, parseEither)+import Data.ByteString.Lazy (ByteString)+import Data.Char (isAlpha, isDigit)+import Data.Either (partitionEithers)+import qualified Data.HashMap.Strict as HM+import Data.List (unfoldr)+import Data.Scientific+import Data.String (fromString)+import qualified Data.Text as T (unpack)+import qualified Data.Text.Lazy as LT (pack, unpack)+import qualified Data.Text.Lazy.Encoding as LT (encodeUtf8, decodeUtf8)+import qualified Text.ParserCombinators.ReadP as R+import Text.Read (readMaybe)+import qualified Data.Vector as V++data Lisp =+ Null |+ Bool P.Bool |+ Symbol P.String |+ String P.String |+ Number Scientific |+ List [Lisp]+ deriving (Eq)++readable :: Read a => Int -> R.ReadP a+readable = R.readS_to_P . readsPrec++lisp :: Int -> R.ReadP Lisp+lisp n = R.choice [+ do+ s <- symbol+ return $ case s of+ "null" -> Null+ "true" -> Bool True+ "false" -> Bool False+ _ -> Symbol s,+ fmap String string,+ fmap Number number,+ fmap List list]+ where+ symbol :: R.ReadP P.String+ symbol = concat <$> sequence [+ R.option [] (pure <$> R.char ':'),+ pure <$> R.satisfy isAlpha,+ R.munch (\ch -> isAlpha ch || isDigit ch || ch == '-')]++ string :: R.ReadP P.String+ string = (R.<++ R.pfail) $ do+ ('\"':_) <- R.look+ readable n++ number :: R.ReadP Scientific+ number = do+ s <- R.munch1 (\ch -> isDigit ch || ch `elem` ['e', 'E', '.', '+', '-'])+ maybe R.pfail return $ readMaybe s++ list :: R.ReadP [Lisp]+ list = R.between (R.char '(') (R.char ')') $ R.sepBy (lisp n) R.skipSpaces++instance Read Lisp where+ readsPrec = R.readP_to_S . lisp++instance Show Lisp where+ show Null = "null"+ show (Bool b)+ | b = "true"+ | otherwise = "false"+ show (Symbol s) = s+ show (String s) = show s+ show (Number n) = either show show (floatingOrInteger n :: Either Double Integer)+ show (List vs) = "(" ++ unwords (map show vs) ++ ")"++instance ToJSON Lisp where+ toJSON Null = toJSON A.Null+ toJSON (Bool b) = toJSON b+ toJSON (Symbol s) = toJSON s+ toJSON (String s) = toJSON s+ toJSON (Number n) = toJSON n+ toJSON (List vs)+ | null keywords = toJSON $ map toJSON vals+ | null vals = keywordsObject+ | otherwise = toJSON $ map toJSON vals ++ [keywordsObject]+ where+ (vals, keywords) = partitionEithers $ unfoldr cutKeyword vs+ keywordsObject = A.object [fromString (dropColon k) .= v | (k, v) <- keywords]++ dropColon :: P.String -> P.String+ dropColon (':' : s) = s+ dropColon s = s++ cutKeyword :: [Lisp] -> Maybe (Either Lisp (P.String, Lisp), [Lisp])+ cutKeyword [] = Nothing+ cutKeyword (Symbol s : []) = Just (Right (s, Null), [])+ cutKeyword (Symbol s : Symbol h : hs) = Just (Right (s, Null), Symbol h : hs)+ cutKeyword (Symbol s : h : hs) = Just (Right (s, h), hs)+ cutKeyword (h : hs) = Just (Left h, hs)++instance FromJSON Lisp where+ parseJSON A.Null = return Null+ parseJSON (A.Bool b) = return $ Bool b+ parseJSON (A.String s) = return $ String $ T.unpack s+ parseJSON (A.Number n) = return $ Number n+ parseJSON (A.Array vs) = fmap List $ mapM parseJSON $ V.toList vs+ parseJSON (A.Object obj) = fmap (List . concat) $ mapM (\(k, v) -> sequence [pure $ Symbol (':' : T.unpack k), parseJSON v]) $ HM.toList obj++decodeLisp :: FromJSON a => ByteString -> Either P.String a+decodeLisp str = do+ sexp <- maybe (Left "Not a s-exp") Right . readMaybe . LT.unpack . LT.decodeUtf8 $ str+ parseEither parseJSON $ toJSON (sexp :: Lisp)++encodeLisp :: ToJSON a => a -> ByteString+encodeLisp r = LT.encodeUtf8 . LT.pack $ maybe+ "(:error \"can't convert to s-exp\")"+ (show :: Lisp -> P.String)+ (parseMaybe parseJSON (toJSON r))
src/HsDev/Client/Commands.hs view
@@ -388,9 +388,11 @@ "srcm.file == ?", "c.completion like ? escape '\\'"]]) (fpath ^. path, likePattern (SearchQuery input SearchPrefix))-runCommand (Hayoo hq p ps) = toValue $ liftM concat $ forM [p .. p + pred ps] $ \i -> liftM- (mapMaybe Hayoo.hayooAsSymbol . Hayoo.resultResult) $- liftIO $ hsdevLift $ Hayoo.hayoo hq (Just i)+runCommand (Hayoo hq p ps) = do+ m <- askSession sessionHTTPManager+ toValue $ liftM concat $ forM [p .. p + pred ps] $ \i -> liftM+ (mapMaybe Hayoo.hayooAsSymbol . Hayoo.resultResult) $+ liftIO $ hsdevLift $ Hayoo.hayoo m hq (Just i) runCommand (CabalList packages') = toValue $ liftIO $ hsdevLift $ Cabal.cabalList $ map unpack packages' runCommand (UnresolvedSymbols fs) = toValue $ liftM concat $ forM fs $ \f -> do rs <- query @_ @(Maybe String, String, Int, Int) "select n.qualifier, n.name, n.line, n.column from modules as m, names as n where (m.id == n.module_id) and (m.file == ?) and (n.resolve_error is not null);"
src/HsDev/Server/Base.hs view
@@ -37,6 +37,7 @@ import System.Log.Simple hiding (Level(..), Message) import qualified System.Log.Simple.Base as Log (level_) import qualified System.Log.Simple as Log+import qualified Network.HTTP.Client as HTTP import Network.Socket import qualified Network.Socket.ByteString.Lazy as Net (getContents, sendAll) import System.FilePath@@ -118,6 +119,7 @@ uw <- startWorker (withSession sess . withSqlConnection) id logAll resolveEnvTable <- newLookupTable+ httpManager <- HTTP.newManager HTTP.defaultManagerSettings return $ Session sqlDb@@ -131,6 +133,7 @@ ghcw uw resolveEnvTable+ httpManager (do withLog (sessionLogger slog) $ Log.sendLog Log.Trace "stopping server" signalQSem waitSem)@@ -182,8 +185,8 @@ bracket (liftIO $ makeSocket (serverPort sopts)) (liftIO . close) $ \s -> do liftIO $ do setSocketOption s ReuseAddr 1- addr' <- inet_addr "127.0.0.1"- bind s (sockAddr (serverPort sopts) addr')+ sockAddr':_ <- getAddrInfo (Just defaultHints) (Just "127.0.0.1") (Just $ show $ serverPort sopts)+ bind s (addrAddress sockAddr') listen s maxListenQueue forever $ logAsync (Log.sendLog Log.Fatal . fromString) $ logIO "exception: " (Log.sendLog Log.Error . fromString) $ do Log.sendLog Log.Trace "accepting connection..."
src/HsDev/Server/Commands.hs view
@@ -73,8 +73,8 @@ _ <- traverse parseData input -- FIXME: Not used! s <- makeSocket (clientPort copts)- addr' <- inet_addr "127.0.0.1"- Net.connect s (sockAddr (clientPort copts) addr')+ sockAddr':_ <- getAddrInfo (Just defaultHints) (Just "127.0.0.1") (Just $ show $ clientPort copts)+ Net.connect s (addrAddress sockAddr') bracket (socketToHandle s ReadWriteMode) hClose $ \h -> do L.hPutStrLn h $ encode $ Message Nothing $ Request c curDir noFile (clientTimeout copts) (clientSilent copts) hFlush h@@ -152,8 +152,8 @@ runServerCommand (Connect copts) = do curDir <- getCurrentDirectory s <- makeSocket $ clientPort copts- addr' <- inet_addr "127.0.0.1"- Net.connect s $ sockAddr (clientPort copts) addr'+ sockAddr':_ <- getAddrInfo (Just defaultHints) (Just "127.0.0.1") (Just $ show $ clientPort copts)+ Net.connect s (addrAddress sockAddr') bracket (socketToHandle s ReadWriteMode) hClose $ \h -> forM_ [(1 :: Integer)..] $ \i -> ignoreIO $ do input' <- hGetLineBS stdin case decodeMsg input' of
src/HsDev/Server/Types.hs view
@@ -37,6 +37,7 @@ import Data.Text (Text) import Data.String (fromString) import qualified Database.SQLite.Simple as SQL+import qualified Network.HTTP.Client as HTTP import Options.Applicative import System.Log.Simple as Log @@ -80,6 +81,7 @@ sessionGhc :: GhcWorker, sessionUpdater :: Worker (ServerM IO), sessionResolveEnvironment :: LookupTable (Maybe Path) (Environment, FixitiesTable),+ sessionHTTPManager :: HTTP.Manager, sessionExit :: IO (), sessionWait :: IO (), sessionClients :: F.Chan (IO ()),
src/HsDev/Tools/Hayoo.hs view
@@ -22,7 +22,8 @@ import qualified Data.ByteString.Lazy.Char8 as L import Data.Either import Data.Maybe (listToMaybe, fromJust)-import Network.HTTP+import Network.HTTP.Client+import Network.URI (escapeURIString, isUnescapedInURIComponent) import Data.String (fromString) import qualified Data.Text as T (unpack, unlines) @@ -126,10 +127,13 @@ ctors = [("type", Type), ("newtype", NewType), ("data", Data), ("class", Class)] -- | Search hayoo-hayoo :: String -> Maybe Int -> ExceptT String IO HayooResult-hayoo q page = do- resp <- ExceptT $ (show +++ rspBody) <$> simpleHTTP (getRequest $ maybe id addPage page $ "http://hayoo.fh-wedel.de/json/?query=" ++ urlEncode q)- ExceptT $ return $ eitherDecode $ L.pack resp+hayoo :: Manager -> String -> Maybe Int -> ExceptT String IO HayooResult+hayoo m q page = do+ resp <- liftIO $ do+ req <- parseRequest $ maybe id addPage page $ "http://hayoo.fh-wedel.de/json/?query=" ++ escapeURIString isUnescapedInURIComponent q+ resp <- httpLbs req m+ return $ responseBody resp+ ExceptT $ return $ eitherDecode resp where addPage :: Int -> String -> String addPage p s = s ++ "&page=" ++ show p
src/HsDev/Version.hs view
@@ -1,17 +1,17 @@-{-# LANGUAGE TemplateHaskell #-} - -module HsDev.Version ( - cabalVersion - ) where - -import Data.Char -import Data.List -import Data.Maybe -import Language.Haskell.TH - -cabalVersion :: ExpQ -cabalVersion = do - s <- runIO (readFile "hsdev.cabal") - let - version = listToMaybe $ map (dropWhile isSpace) $ mapMaybe (stripPrefix "version:") $ lines s - maybe (fail "Can't detect version") (\v -> [e| v |]) version +{-# LANGUAGE TemplateHaskell #-}++module HsDev.Version (+ cabalVersion+ ) where++import Data.Char+import Data.List+import Data.Maybe+import Language.Haskell.TH++cabalVersion :: ExpQ+cabalVersion = do+ s <- runIO (readFile "hsdev.cabal")+ let+ version = listToMaybe $ map (dropWhile isSpace) $ mapMaybe (stripPrefix "version:") $ lines s+ maybe (fail "Can't detect version") (\v -> [e| v |]) version
src/HsDev/Watcher/Types.hs view
@@ -1,14 +1,14 @@-module HsDev.Watcher.Types ( - Watched(..), - Watcher, - - PackageDbStack, Project - ) where - -import qualified System.Directory.Watcher as W -import HsDev.Project (Project) -import HsDev.PackageDb (PackageDbStack) - -data Watched = WatchedProject Project [String] | WatchedPackageDb PackageDbStack [String] | WatchedModule - -type Watcher = W.Watcher Watched +module HsDev.Watcher.Types (+ Watched(..),+ Watcher,++ PackageDbStack, Project+ ) where++import qualified System.Directory.Watcher as W+import HsDev.Project (Project)+import HsDev.PackageDb (PackageDbStack)++data Watched = WatchedProject Project [String] | WatchedPackageDb PackageDbStack [String] | WatchedModule++type Watcher = W.Watcher Watched
src/System/Win32/FileMapping/Memory.hs view
@@ -1,53 +1,53 @@-module System.Win32.FileMapping.Memory ( - createMap, openMap, mapFile, - withMapFile, readMapFile - ) where - -import Control.Monad.Catch -import Control.Monad.Cont -import Control.Monad.Except -import Data.ByteString.Char8 -import qualified Data.ByteString.Char8 as BS -import Foreign.Ptr -import System.Win32.File (closeHandle) -import System.Win32.FileMapping hiding (mapFile) -import System.Win32.Types -import System.Win32.Mem - -createMap :: Maybe HANDLE -> ProtectFlags -> DDWORD -> Maybe String -> ExceptT String (ContT r IO) HANDLE -createMap mh pf sz mn = verify (/= iNVALID_HANDLE_VALUE) "Invalid handle" $ ContT $ bracket - (createFileMapping mh pf sz mn) - closeHandle - -openMap :: FileMapAccess -> Bool -> Maybe String -> ExceptT String (ContT r IO) HANDLE -openMap f i mn = verify (/= iNVALID_HANDLE_VALUE) "Invalid handle" $ ContT $ bracket - (openFileMapping f i mn) - closeHandle - -mapFile :: HANDLE -> FileMapAccess -> DDWORD -> SIZE_T -> ExceptT String IO (Ptr a) -mapFile h f off sz = verify (/= nullPtr) "null pointer" $ mapViewOfFile h f off sz - --- | Write data to named map view of file -withMapFile :: String -> ByteString -> IO a -> ExceptT String IO a -withMapFile name str act = mapExceptT (`runContT` return) $ do - p <- lift $ ContT $ BS.useAsCString str - h <- createMap Nothing pAGE_READWRITE (fromIntegral len) (Just name) - ptr <- mapExceptT lift $ mapFile h fILE_MAP_ALL_ACCESS 0 0 - liftIO $ do - copyMemory ptr p (fromIntegral len) - unmapViewOfFile ptr - act - where - len = BS.length str + 1 - --- | Read data from named map view of file -readMapFile :: String -> ExceptT String IO ByteString -readMapFile name = mapExceptT (`runContT` return) $ do - h <- openMap fILE_MAP_ALL_ACCESS True (Just name) - ptr <- mapExceptT lift $ mapFile h fILE_MAP_ALL_ACCESS 0 0 - liftIO $ BS.packCString ptr - -verify :: Monad m => (a -> Bool) -> String -> m a -> ExceptT String m a -verify p str act = do - x <- lift act - if p x then return x else throwError str +module System.Win32.FileMapping.Memory (+ createMap, openMap, mapFile,+ withMapFile, readMapFile+ ) where++import Control.Monad.Catch+import Control.Monad.Cont+import Control.Monad.Except+import Data.ByteString.Char8+import qualified Data.ByteString.Char8 as BS+import Foreign.Ptr+import System.Win32.File (closeHandle)+import System.Win32.FileMapping hiding (mapFile)+import System.Win32.Types+import System.Win32.Mem++createMap :: Maybe HANDLE -> ProtectFlags -> DDWORD -> Maybe String -> ExceptT String (ContT r IO) HANDLE+createMap mh pf sz mn = verify (/= iNVALID_HANDLE_VALUE) "Invalid handle" $ ContT $ bracket+ (createFileMapping mh pf sz mn)+ closeHandle++openMap :: FileMapAccess -> Bool -> Maybe String -> ExceptT String (ContT r IO) HANDLE+openMap f i mn = verify (/= iNVALID_HANDLE_VALUE) "Invalid handle" $ ContT $ bracket+ (openFileMapping f i mn)+ closeHandle++mapFile :: HANDLE -> FileMapAccess -> DDWORD -> SIZE_T -> ExceptT String IO (Ptr a)+mapFile h f off sz = verify (/= nullPtr) "null pointer" $ mapViewOfFile h f off sz++-- | Write data to named map view of file+withMapFile :: String -> ByteString -> IO a -> ExceptT String IO a+withMapFile name str act = mapExceptT (`runContT` return) $ do+ p <- lift $ ContT $ BS.useAsCString str+ h <- createMap Nothing pAGE_READWRITE (fromIntegral len) (Just name)+ ptr <- mapExceptT lift $ mapFile h fILE_MAP_ALL_ACCESS 0 0+ liftIO $ do+ copyMemory ptr p (fromIntegral len)+ unmapViewOfFile ptr+ act+ where+ len = BS.length str + 1++-- | Read data from named map view of file+readMapFile :: String -> ExceptT String IO ByteString+readMapFile name = mapExceptT (`runContT` return) $ do+ h <- openMap fILE_MAP_ALL_ACCESS True (Just name)+ ptr <- mapExceptT lift $ mapFile h fILE_MAP_ALL_ACCESS 0 0+ liftIO $ BS.packCString ptr++verify :: Monad m => (a -> Bool) -> String -> m a -> ExceptT String m a+verify p str act = do+ x <- lift act+ if p x then return x else throwError str
tests/test-package/ModuleTwo.hs view
@@ -1,21 +1,21 @@-module ModuleTwo ( - untypedFoo, - twice, - overloadedStrings - ) where - -import ModuleOne (untypedFoo) - -import Data.String - --- | Apply function twice -twice :: (a -> a) -> a -> a -twice f = f . f - -data MyString = MyString String - -instance IsString MyString where - fromString = MyString - -overloadedStrings :: MyString -overloadedStrings = "Hello" +module ModuleTwo (+ untypedFoo,+ twice,+ overloadedStrings+ ) where++import ModuleOne (untypedFoo)++import Data.String++-- | Apply function twice+twice :: (a -> a) -> a -> a+twice f = f . f++data MyString = MyString String++instance IsString MyString where+ fromString = MyString++overloadedStrings :: MyString+overloadedStrings = "Hello"
tools/hsdev.hs view
@@ -1,36 +1,36 @@-module Main ( - main - ) where - -import Control.Exception -import Data.List -import Network.Socket (withSocketsDo) -import Options.Applicative -import System.Environment (getArgs) -import System.IO - -import HsDev.Server.Commands (runServerCommand) -import HsDev.Server.Types -import HsDev.Util - -main :: IO () -main = handle logErr' $ withSocketsDo $ do - hSetBuffering stdout LineBuffering - hSetEncoding stdout utf8 - as <- prepareArgs - case parseArgs "hsdev" (info cmdP (progDesc "hsdev tool")) as of - Left e -> putStrLn e - Right scmd -> runServerCommand scmd - where - logErr' (SomeException e) = putStrLn $ "exception " ++ show e - --- | Get args with '--stdin' flag replaced and 'help' command changed to flag -prepareArgs :: IO [String] -prepareArgs = getArgs >>= prepare where - prepare [] = return [] - prepare ("help" : as) = prepare $ as ++ ["-?"] - prepare as - | "--stdin" `elem` as = do - input <- getContents - return $ delete "--stdin" as ++ ["--data", input] - | otherwise = return as +module Main (+ main+ ) where++import Control.Exception+import Data.List+import Network.Socket (withSocketsDo)+import Options.Applicative+import System.Environment (getArgs)+import System.IO++import HsDev.Server.Commands (runServerCommand)+import HsDev.Server.Types+import HsDev.Util++main :: IO ()+main = handle logErr' $ withSocketsDo $ do+ hSetBuffering stdout LineBuffering+ hSetEncoding stdout utf8+ as <- prepareArgs+ case parseArgs "hsdev" (info cmdP (progDesc "hsdev tool")) as of+ Left e -> putStrLn e+ Right scmd -> runServerCommand scmd+ where+ logErr' (SomeException e) = putStrLn $ "exception " ++ show e++-- | Get args with '--stdin' flag replaced and 'help' command changed to flag+prepareArgs :: IO [String]+prepareArgs = getArgs >>= prepare where+ prepare [] = return []+ prepare ("help" : as) = prepare $ as ++ ["-?"]+ prepare as+ | "--stdin" `elem` as = do+ input <- getContents+ return $ delete "--stdin" as ++ ["--data", input]+ | otherwise = return as