Skip to content

Commit

Permalink
Merge pull request #528 from hackworthltd/brprice/inline-expranyfresh
Browse files Browse the repository at this point in the history
refactor: inline ExprAnyFresh
  • Loading branch information
brprice authored Jun 20, 2022
2 parents de76266 + df441ff commit 256214e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
5 changes: 1 addition & 4 deletions primer/src/Primer/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ module Primer.Core (
primConName,
PrimFun (..),
primFunType,
ExprAnyFresh,
PrimFunError (..),
ValCon (..),
valConType,
Expand Down Expand Up @@ -539,7 +538,7 @@ primConName = \case
data PrimFun = PrimFun
{ primFunTypes :: forall m. MonadFresh ID m => m ([Type], Type)
-- ^ the function's arguments and return type
, primFunDef :: [Expr' () ()] -> Either PrimFunError ExprAnyFresh
, primFunDef :: [Expr' () ()] -> Either PrimFunError (forall m. MonadFresh ID m => m Expr)
}

primFunType :: forall m. MonadFresh ID m => PrimFun -> m Type
Expand All @@ -551,8 +550,6 @@ primFunType pf = do
id <- fresh
pure $ TFun (Meta id Nothing Nothing) x y

type ExprAnyFresh = forall m. MonadFresh ID m => m Expr

data PrimFunError
= -- | We have attempted to apply a primitive function to invalid args.
PrimFunError
Expand Down
3 changes: 1 addition & 2 deletions primer/src/Primer/Eval.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ import Primer.Core (
DefMap,
Expr,
Expr' (..),
ExprAnyFresh,
GVarName,
HasID (_id),
ID,
Expand Down Expand Up @@ -983,7 +982,7 @@ munless x b = if b then mempty else x

-- | If this node is a reducible application of a primitive, return the name of the primitive, the arguments, and
-- (a computation for building) the result.
tryPrimFun :: Map GVarName PrimDef -> Expr -> Maybe (GVarName, [Expr], ExprAnyFresh)
tryPrimFun :: Map GVarName PrimDef -> Expr -> Maybe (GVarName, [Expr], forall m. MonadFresh ID m => m Expr)
tryPrimFun primDefs expr
| -- Since no primitive functions are polymorphic, there is no need to unfoldAPP
(Var _ (GlobalVarRef name), args) <- bimap stripAnns (map stripAnns) $ unfoldApp expr
Expand Down
3 changes: 1 addition & 2 deletions primer/src/Primer/EvalFull.hs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ import Primer.Core (
Letrec,
Var
),
ExprAnyFresh,
ExprMeta,
GVarName,
ID,
Expand Down Expand Up @@ -155,7 +154,7 @@ data Redex
RenameSelfLet LVarName Expr Expr
| -- As RenameSelfLet, but for LetType. (Note that it is unnecessary for letrec.)
RenameSelfLetType TyVarName Type Expr
| ApplyPrimFun ExprAnyFresh
| ApplyPrimFun (forall m. MonadFresh ID m => m Expr)

-- there are only trivial redexes in types.
-- Note that the let must appear in the surrounding Expr (not in a type itself)
Expand Down

0 comments on commit 256214e

Please sign in to comment.