Skip to content

Commit

Permalink
fix tests too
Browse files Browse the repository at this point in the history
  • Loading branch information
bristermitten committed May 3, 2024
1 parent 5d58402 commit 8ac8089
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 63 deletions.
50 changes: 13 additions & 37 deletions src/Elara/AST/Generic/Instances/DataPlated.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import Data.Data
import Data.Generics.Wrapped
import Elara.AST.Generic.Types
import Elara.AST.Generic.Utils
import Elara.AST.Name
import Elara.AST.Region (unlocated)
import Optics (GPlate (..))
import Elara.AST.Name (LowerAlphaName)

-- Some of these 'Plated' instances could be derived with 'template', but I feel like it's more efficient to write them by hand

Expand All @@ -29,12 +27,10 @@ instance
CharPattern a -> pure (CharPattern a)
UnitPattern -> pure UnitPattern

-- instance
-- forall a (ast :: a).
-- Data (Pattern ast) =>
-- Plated (Pattern ast)
-- where
-- plate = gplate @(Pattern ast) @(Pattern ast)
instance
forall a (ast :: a).
GPlate (Pattern ast) (Pattern ast) =>
Plated (Pattern ast)

instance
( RUnlocate ast
Expand Down Expand Up @@ -70,35 +66,15 @@ instance
let e' = dataConAs @(Select "InParens" ast) @(Expr ast) e
in InParens . asDataCon <$> traverseOf traverseExpr f e'

-- instance
-- forall a (ast :: a).
-- Data (Expr ast) =>
-- Plated (Expr ast)
-- where
-- plate = _Unwrapped % _1 % unlocated % gplate @(Expr ast) @(Expr' ast)

-- instance
-- forall a (ast :: a).
-- Data (Type ast) =>
-- Plated (Type ast)
-- where
-- plate = gplate
instance
forall a (ast :: a).
GPlate (Expr ast) (Expr ast) =>
Plated (Expr ast)

-- instance
-- forall a (ast :: a).
-- ( Data (ASTLocate ast (Type' ast))
-- , Data (ASTLocate ast (Select "TypeVar" ast))
-- , Data (Select "TypeVar" ast)
-- , Data (ASTLocate ast (Select "UserDefinedType" ast))
-- , Data (ASTLocate ast LowerAlphaName)
-- , Data (Select "UserDefinedType" ast)
-- , Typeable ast
-- , Typeable a
-- , (Data (Type' ast))
-- ) =>
-- Plated (Type' ast)
-- where
-- plate = gplate
instance
forall a (ast :: a).
GPlate (Type ast) (Type ast) =>
Plated (Type ast)

deriving instance
forall a (ast :: a).
Expand Down
2 changes: 1 addition & 1 deletion src/Elara/Rename.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import Elara.Error (ReportableError (report), runErrorOrReport, writeReport)
import Elara.Error.Codes qualified as Codes (nonExistentModuleDeclaration, unknownModule)
import Elara.Pipeline
import Error.Diagnose (Marker (This, Where), Note (..), Report (Err))
import Optics (A_Traversal, filteredBy, traverseOf_)
import Optics (filteredBy, traverseOf_)
import Polysemy (Member, Members, Sem)
import Polysemy.Error (Error, note, throw)
import Polysemy.Reader hiding (Local)
Expand Down
1 change: 0 additions & 1 deletion src/Elara/TypeInfer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import Elara.TypeInfer.Infer qualified as Infer
import Elara.TypeInfer.Monotype qualified as Mono
import Elara.TypeInfer.Type (Type)
import Elara.TypeInfer.Type qualified as Infer
import Optics (GPlate (..))
import Polysemy hiding (transform)
import Polysemy.Error (Error, mapError, throw)
import Polysemy.State
Expand Down
2 changes: 1 addition & 1 deletion src/Elara/TypeInfer/Infer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ import Polysemy.Error (Error, throw)
import Polysemy.State (State)
import Polysemy.State qualified as State
import Prettyprinter qualified as Pretty
import Print (debugPretty, showPretty)
import Print (showPretty)
import TODO

-- | Type-checking state
Expand Down
2 changes: 1 addition & 1 deletion src/Elara/TypeInfer/Type.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import Elara.TypeInfer.Monotype (
)
import Elara.TypeInfer.Monotype qualified as Monotype
import Elara.TypeInfer.Unique
import Optics (cosmosOf, has, hasn't, only)
import Optics (hasn't)
import Optics qualified as Lens
import Prettyprinter qualified as Pretty
import Print (showPrettyUnannotated)
Expand Down
1 change: 0 additions & 1 deletion test/Common.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module Common where

import Control.Lens.Plated
import Elara.AST.Generic
import Elara.Data.Pretty
import Error.Diagnose (Diagnostic, TabSize (..), WithUnicode (..), hasReports, prettyDiagnostic')
Expand Down
36 changes: 16 additions & 20 deletions test/Infer.hs
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
module Infer where

import Common (diagShouldSucceed)
import Control.Lens (Each (each), Field1 (_1), Prism', filtered, foldOf, folded, mapped, preview, traverseOf, (^.), (^..), (^?))
import Data.Generics.Product (HasField (field))
import Data.Generics.Sum (AsAny (_As), AsConstructor (_Ctor), AsConstructor' (_Ctor'), AsType (_Typed))
import Data.Generics.Sum (AsConstructor' (_Ctor'))
import Data.Generics.Wrapped (_Unwrapped)
import Data.Map ((!))
import Elara.AST.Generic.Common
import Elara.AST.Generic.Types
import Elara.AST.Region (unlocated)
import Elara.AST.Select (LocatedAST (..), UnlocatedAST (UnlocatedTyped))
import Elara.AST.StripLocation
import Elara.AST.Select (LocatedAST (..))
import Elara.TypeInfer.Domain qualified as Domain
import Elara.TypeInfer.Monotype qualified as Scalar
import Elara.TypeInfer.Type (Type (..), structuralEq)
Expand Down Expand Up @@ -107,20 +103,20 @@ functionTypes = describe "Infers function types correctly" $ modifyMaxSuccess (c
let decls =
mod
^.. _Unwrapped
. unlocated
. field @"declarations"
. folded
. _Unwrapped
. unlocated
. field @"body"
. _Unwrapped
. unlocated
. (_Ctor' @"Value" @(DeclarationBody' Typed))
. _1

let idDecl = decls !! 1 ^. _Unwrapped . _1 . unlocated
let id2Decl = decls !! 2 ^. _Unwrapped . _1 . unlocated
let id3Decl = decls !! 3 ^. _Unwrapped . _1 . unlocated
% unlocated
% field @"declarations"
% folded
% _Unwrapped
% unlocated
% field @"body"
% _Unwrapped
% unlocated
% (_Ctor' @"Value" @(DeclarationBody' Typed))
% _1

let idDecl = decls !! 1 ^. _Unwrapped % _1 % unlocated
let id2Decl = decls !! 2 ^. _Unwrapped % _1 % unlocated
let id3Decl = decls !! 3 ^. _Unwrapped % _1 % unlocated

printPretty decls

Expand Down
1 change: 0 additions & 1 deletion test/Lex/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

module Lex.Common where

import Control.Lens (view)
import Elara.AST.Region (unlocated)
import Elara.Lexer.Pipeline (runLexPipeline, runLexPipelinePure)
import Elara.Lexer.Reader
Expand Down

0 comments on commit 8ac8089

Please sign in to comment.