diff --git a/parser-typechecker/src/Unison/Builtin.hs b/parser-typechecker/src/Unison/Builtin.hs index 5c04e9447..33b95199b 100644 --- a/parser-typechecker/src/Unison/Builtin.hs +++ b/parser-typechecker/src/Unison/Builtin.hs @@ -7,12 +7,15 @@ module Unison.Builtin where import Control.Arrow ( first ) -import Control.Applicative ( liftA2 ) +import Control.Applicative ( liftA2 + , (<|>) + ) import qualified Data.Map as Map import Data.Set ( Set ) import qualified Data.Set as Set import qualified Text.Megaparsec.Error as MPE import qualified Unison.ABT as ABT +import Unison.Codebase.CodeLookup ( CodeLookup(..) ) import qualified Unison.ConstructorType as CT import Unison.DataDeclaration ( DataDeclaration' , EffectDeclaration' @@ -140,6 +143,14 @@ builtinDataDecls = l builtinEffectDecls :: Var v => [(v, (R.Reference, EffectDeclaration v))] builtinEffectDecls = [] +codeLookup :: (Applicative m, Var v) => CodeLookup m v Ann +codeLookup = CodeLookup (const $ pure Nothing) $ \r -> + pure + $ lookup r [ (r, Right x) | (R.DerivedId r, x) <- snd <$> builtinDataDecls ] + <|> lookup + r + [ (r, Left x) | (R.DerivedId r, x) <- snd <$> builtinEffectDecls ] + toSymbol :: Var v => R.Reference -> v toSymbol (R.Builtin txt) = Var.named txt toSymbol _ = error "unpossible" diff --git a/parser-typechecker/tests/Unison/Test/Typechecker.hs b/parser-typechecker/tests/Unison/Test/Typechecker.hs index 60ca42e49..f9c6cab46 100644 --- a/parser-typechecker/tests/Unison/Test/Typechecker.hs +++ b/parser-typechecker/tests/Unison/Test/Typechecker.hs @@ -109,9 +109,11 @@ makePassingTest rt how filepath = scope shortName $ do (True, Right file) -> do values <- io $ unpack <$> Data.Text.IO.readFile valueFile let untypedFile = UF.discardTypes file - let term = Parsers.parseTerm values $ UF.toNames untypedFile - watches <- io - $ evaluateWatches mempty (const $ pure Nothing) rt untypedFile + let term = Parsers.parseTerm values $ UF.toNames untypedFile + watches <- io $ evaluateWatches Builtin.codeLookup + (const $ pure Nothing) + rt + untypedFile case term of Right tm -> expect $ (view _4 <$> Map.elems watches) == [amap (const ()) tm]