mirror of
https://github.com/github/semantic.git
synced 2024-12-19 12:51:52 +03:00
Merge remote-tracking branch 'origin/master' into quiet-parsing
This commit is contained in:
commit
070c15a947
@ -189,7 +189,6 @@ library
|
||||
, Semantic.Parse
|
||||
, Semantic.REPL
|
||||
, Semantic.Resolution
|
||||
, Semantic.Resource
|
||||
, Semantic.Task
|
||||
, Semantic.Telemetry
|
||||
, Semantic.Telemetry.AsyncQueue
|
||||
|
@ -8,6 +8,7 @@ import Prologue hiding (bracket)
|
||||
|
||||
import qualified Control.Exception as Exc (bracket)
|
||||
import Control.Monad.Effect
|
||||
import Control.Monad.Effect.Resource
|
||||
import Control.Monad.Effect.Trace
|
||||
import Control.Monad.IO.Class
|
||||
import Data.ByteString.Unsafe (unsafeUseAsCStringLen)
|
||||
@ -22,7 +23,6 @@ import Data.Location
|
||||
import Data.Source
|
||||
import Data.Span
|
||||
import Data.Term
|
||||
import Semantic.Resource
|
||||
import Semantic.Timeout
|
||||
|
||||
import qualified TreeSitter.Language as TS
|
||||
|
@ -5,6 +5,7 @@ module Semantic.REPL
|
||||
) where
|
||||
|
||||
import Control.Abstract hiding (Continue, List, string)
|
||||
import Control.Monad.Effect.Resource
|
||||
import Control.Monad.IO.Class
|
||||
import Data.Abstract.Address.Precise as Precise
|
||||
import Data.Abstract.Environment as Env
|
||||
@ -31,7 +32,6 @@ import Semantic.Distribute
|
||||
import Semantic.Graph
|
||||
import Semantic.IO as IO
|
||||
import Semantic.Resolution
|
||||
import Semantic.Resource
|
||||
import Semantic.Task hiding (Error)
|
||||
import Semantic.Telemetry
|
||||
import Semantic.Timeout
|
||||
|
@ -1,36 +0,0 @@
|
||||
{-# LANGUAGE GADTs, TypeOperators, RankNTypes #-}
|
||||
|
||||
module Semantic.Resource
|
||||
( Resource (..)
|
||||
, bracket
|
||||
, runResource
|
||||
) where
|
||||
|
||||
import Control.Monad.Effect
|
||||
import Control.Monad.IO.Class
|
||||
import qualified Control.Exception as Exc
|
||||
|
||||
data Resource m output where
|
||||
Resource :: m res -> (res -> m any) -> (res -> m output) -> Resource m output
|
||||
|
||||
instance PureEffect Resource
|
||||
instance Effect Resource where
|
||||
handleState c dist (Request (Resource fore aft go) k)
|
||||
= Request (Resource (dist (fore <$ c)) (dist . fmap aft) (dist . fmap go)) (dist . fmap k)
|
||||
|
||||
bracket :: (Member Resource effs, Effectful m)
|
||||
=> m effs res
|
||||
-> (res -> m effs any)
|
||||
-> (res -> m effs b)
|
||||
-> m effs b
|
||||
bracket fore aft go = send (Resource (lowerEff fore) (lowerEff . aft) (lowerEff . go))
|
||||
|
||||
runResource :: (Member (Lift IO) effects, PureEffects effects)
|
||||
=> (forall x . Eff effects x -> IO x)
|
||||
-> Eff (Resource ': effects) a
|
||||
-> Eff effects a
|
||||
runResource handler = interpret (\(Resource fore aft go)
|
||||
-> liftIO (Exc.bracket
|
||||
(handler (runResource handler fore))
|
||||
(handler . runResource handler . aft)
|
||||
(handler . runResource handler . go)))
|
@ -62,6 +62,7 @@ import Control.Monad
|
||||
import Control.Monad.Effect
|
||||
import Control.Monad.Effect.Exception
|
||||
import Control.Monad.Effect.Reader
|
||||
import Control.Monad.Effect.Resource
|
||||
import Control.Monad.Effect.Trace
|
||||
import Data.Blob
|
||||
import Data.Bool
|
||||
@ -86,7 +87,6 @@ import Semantic.Distribute
|
||||
import Semantic.Timeout
|
||||
import qualified Semantic.IO as IO
|
||||
import Semantic.Resolution
|
||||
import Semantic.Resource
|
||||
import Semantic.Telemetry
|
||||
import Serializing.Format hiding (Options)
|
||||
import System.Exit (die)
|
||||
|
@ -16,7 +16,7 @@ import Data.Sum
|
||||
import Data.Term
|
||||
import Data.Text (Text)
|
||||
import Data.Text.Encoding (encodeUtf8)
|
||||
import Data.Union
|
||||
import Data.Union hiding (forAll)
|
||||
import Diffing.Algorithm
|
||||
import Diffing.Interpreter
|
||||
import Prelude
|
||||
|
2
vendor/effects
vendored
2
vendor/effects
vendored
@ -1 +1 @@
|
||||
Subproject commit 8ded4a64133ce77ddd2fc734f455753e62af0ad3
|
||||
Subproject commit e7858dacce6fbb43e76a49e4dbeff1f1815aa290
|
Loading…
Reference in New Issue
Block a user