1
1
mirror of https://github.com/github/semantic.git synced 2024-11-24 08:54:07 +03:00

Fix Analysis.Eval.

This commit is contained in:
Rob Rix 2019-10-04 18:27:53 -04:00
parent 09ec150aea
commit 2c4d23dcb6
No known key found for this signature in database
GPG Key ID: F188A01508EA1CF7

View File

@ -12,7 +12,7 @@ module Analysis.Eval
) where
import Control.Applicative (Alternative (..))
import Control.Effect.Carrier
import Control.Carrier
import Control.Effect.Fail
import Control.Effect.Reader
import Control.Monad ((>=>))
@ -28,8 +28,7 @@ import Data.Text (Text)
import GHC.Stack
import Prelude hiding (fail)
eval :: ( Carrier sig m
, Member (Reader Loc) sig
eval :: ( Has (Reader Loc) sig m
, MonadFail m
, Semigroup value
)
@ -93,30 +92,30 @@ eval Analysis{..} eval = \case
Term (L (Ann loc c)) -> local (const loc) (ref c)
prog1 :: (Carrier sig t, Member Core sig) => File (t Name)
prog1 :: Has Core sig t => File (t Name)
prog1 = fromBody $ lam (named' "foo")
( named' "bar" :<- pure "foo"
>>>= Core.if' (pure "bar")
(Core.bool False)
(Core.bool True))
prog2 :: (Carrier sig t, Member Core sig) => File (t Name)
prog2 :: Has Core sig t => File (t Name)
prog2 = fromBody $ fileBody prog1 $$ Core.bool True
prog3 :: (Carrier sig t, Member Core sig) => File (t Name)
prog3 :: Has Core sig t => File (t Name)
prog3 = fromBody $ lams [named' "foo", named' "bar", named' "quux"]
(Core.if' (pure "quux")
(pure "bar")
(pure "foo"))
prog4 :: (Carrier sig t, Member Core sig) => File (t Name)
prog4 :: Has Core sig t => File (t Name)
prog4 = fromBody
( named' "foo" :<- Core.bool True
>>>= Core.if' (pure "foo")
(Core.bool True)
(Core.bool False))
prog5 :: (Carrier sig t, Member Ann sig, Member Core sig) => File (t Name)
prog5 :: (Has Ann sig t, Has Core sig t) => File (t Name)
prog5 = fromBody $ ann (do'
[ Just (named' "mkPoint") :<- lams [named' "_x", named' "_y"] (ann (Core.record
[ ("x", ann (pure "_x"))
@ -127,7 +126,7 @@ prog5 = fromBody $ ann (do'
, Nothing :<- ann (ann (pure "point") Core.... "y") .= ann (ann (pure "point") Core.... "x")
])
prog6 :: (Carrier sig t, Member Core sig) => [File (t Name)]
prog6 :: Has Core sig t => [File (t Name)]
prog6 =
[ File (Loc "dep" (locSpan (fromJust here))) $ Core.record
[ ("dep", Core.record [ ("var", Core.bool True) ]) ]
@ -137,7 +136,7 @@ prog6 =
])
]
ruby :: (Carrier sig t, Member Ann sig, Member Core sig) => File (t Name)
ruby :: (Has Ann sig t, Has Core sig t) => File (t Name)
ruby = fromBody $ annWith callStack (rec (named' __semantic_global) (do' statements))
where statements =
[ Just "Class" :<- record