Skip to content

Commit

Permalink
address Orestis' comments
Browse files Browse the repository at this point in the history
  • Loading branch information
flupe authored and omelkonian committed Feb 20, 2024
1 parent 2eb5d5e commit 9bc93a6
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 18 deletions.
2 changes: 1 addition & 1 deletion agda2hs.agda-lib
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: agda2hs
depend:
include: lib
flags: -W noUnsupportedIndexedMatch --erasure --no-projection-like
flags: -W noUnsupportedIndexedMatch --erasure
1 change: 0 additions & 1 deletion src/Agda2Hs/AgdaUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import Agda.TypeChecking.Monad ( topLevelModuleName )
import Agda.TypeChecking.Pretty
import Agda.TypeChecking.Substitute
import Agda.TypeChecking.Reduce ( reduceDefCopy )
import Agda.TypeChecking.Records ( shouldBeProjectible )

import Agda.Utils.Either ( isRight )
import Agda.Utils.List ( initMaybe )
Expand Down
3 changes: 1 addition & 2 deletions src/Agda2Hs/Compile/ClassInstance.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ import Agda.Syntax.Common.Pretty ( prettyShow )
import Agda.TypeChecking.Pretty
import Agda.TypeChecking.Substitute ( Apply(applyE), absBody, absApp )
import Agda.TypeChecking.Records
import Agda.TypeChecking.Reduce ( reduce )
import Agda.TypeChecking.Telescope ( mustBePi )
import Agda.TypeChecking.Telescope ( mustBePi )

import Agda.Utils.Lens
import Agda.Utils.Impossible ( __IMPOSSIBLE__ )
Expand Down
1 change: 0 additions & 1 deletion src/Agda2Hs/Compile/Record.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{-# LANGUAGE NamedFieldPuns #-}
module Agda2Hs.Compile.Record where

import Control.Monad ( unless, when )
Expand Down
14 changes: 6 additions & 8 deletions src/Agda2Hs/Compile/Term.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Agda2Hs.Compile.Term where

import Control.Arrow ( (>>>), (&&&) )
import Control.Monad ( unless, msum )
import Control.Monad ( unless )
import Control.Monad.Reader

import Data.Foldable ( toList )
Expand All @@ -23,7 +23,7 @@ import Agda.TypeChecking.Monad
import Agda.TypeChecking.Pretty
import Agda.TypeChecking.Records ( shouldBeProjectible )
import Agda.TypeChecking.Datatypes ( getConType )
import Agda.TypeChecking.Reduce ( unfoldDefinitionStep, reduce )
import Agda.TypeChecking.Reduce ( unfoldDefinitionStep )
import Agda.TypeChecking.Substitute
import Agda.TypeChecking.Telescope ( telView, mustBePi, piApplyM )
import Agda.TypeChecking.ProjectionLike ( reduceProjectionLike )
Expand All @@ -32,7 +32,6 @@ import Agda.Utils.Lens
import Agda.Utils.Impossible ( __IMPOSSIBLE__ )
import Agda.Utils.Monad
import Agda.Utils.Size
import Agda.Utils.Tuple ( mapSndM )

import Agda2Hs.AgdaUtils
import Agda2Hs.Compile.Name ( compileQName )
Expand Down Expand Up @@ -106,7 +105,7 @@ caseOf ty args = compileArgs ty args >>= \case
let lam [] = id
lam qs = Hs.Lambda () qs
in return $ eApp (Hs.Case () e [Hs.Alt () p (Hs.UnGuardedRhs () $ lam ps b) Nothing]) es'
_ -> genericError "case_of_ must be fully applied to a lambda term."
_ -> genericError "case_of_ must be fully applied to a lambda term"


-- | Compile @the@ to an explicitly-annotated Haskell expression.
Expand All @@ -119,8 +118,8 @@ expTypeSig _ _ = genericError "`the` must be fully applied"


-- should really be named compileVar, TODO: rename compileVar
compileV :: Int -> Type -> [Term] -> C (Hs.Exp ())
compileV i ty es = do
compileVar :: Int -> Type -> [Term] -> C (Hs.Exp ())
compileVar i ty es = do
reportSDoc "agda2hs.compile.term" 10 $ text "Reached variable"
name <- compileDBVar i
compileApp (hsVar name) ty es
Expand All @@ -142,7 +141,7 @@ compileSpined ty tm =

Var i es -> Just $ do
ty <- typeOfBV i
aux (compileV i ty) (Var i) ty es
aux (compileVar i ty) (Var i) ty es

_ -> Nothing
where
Expand Down Expand Up @@ -502,7 +501,6 @@ compileApp' acc ty args = acc <$> compileArgs ty args
-- | Compile a list of arguments applied to a function of the given type.
compileArgs :: Type -> [Term] -> C [Hs.Exp ()]
compileArgs ty [] = pure []
-- TODO(flupe): use mustBePi
compileArgs ty (x:xs) = do
(a, b) <- mustBePi ty
let rest = compileArgs (absApp b x) xs
Expand Down
2 changes: 1 addition & 1 deletion src/Agda2Hs/Compile/Type.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{-# LANGUAGE TypeApplications, NamedFieldPuns #-}
{-# LANGUAGE TypeApplications #-}

-- | Compilation to Haskell types.
module Agda2Hs.Compile.Type where
Expand Down
2 changes: 1 addition & 1 deletion src/Agda2Hs/Compile/Types.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{-# LANGUAGE PatternSynonyms, FlexibleInstances, MultiParamTypeClasses, TypeFamilies #-}
{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses, TypeFamilies #-}
module Agda2Hs.Compile.Types where

import Control.Applicative ( liftA2 )
Expand Down
2 changes: 1 addition & 1 deletion src/Agda2Hs/Compile/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ keepArg x = usableModality x && visible x
keepClause :: Clause -> Bool
keepClause = any keepArg . clauseType

isPropSort :: Sort -> C Bool
isPropSort :: Sort -> C Bool
isPropSort s = reduce s <&> \case
Prop _ -> True
_ -> False
Expand Down
1 change: 1 addition & 0 deletions test/UnboxPragma.agda
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ sort1 xs = xs [ looksfine ]
sort2 : List Int ∃ (List Int) IsSorted
sort2 xs .el = xs
sort2 xs .pf = looksfine

{-# COMPILE AGDA2HS sort2 #-}

sort3 : List Int ∃ (List Int) IsSorted
Expand Down
2 changes: 1 addition & 1 deletion test/golden/PartialCase.err
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
test/Fail/PartialCase.agda:5,1-7
case_of_ must be fully applied to a lambda term.
case_of_ must be fully applied to a lambda term
2 changes: 1 addition & 1 deletion test/golden/PartialCaseNoLambda.err
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
test/Fail/PartialCaseNoLambda.agda:5,1-13
case_of_ must be fully applied to a lambda term.
case_of_ must be fully applied to a lambda term

0 comments on commit 9bc93a6

Please sign in to comment.