Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/Agda2Hs/Compile/ClassInstance.hs
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,14 @@ compileInstRule xs cs ty = do
pars t@(Hs.TyCon () _) = t
pars t = Hs.TyParen () t
Pi a b -> compileDomType (absName b) a >>= \case
DomDropped -> underAbstr a b (compileInstRule xs cs . unEl)
DomDropped -> underAbstr a b skip
DomConstraint hsA ->
underAbstraction a b (compileInstRule xs (cs ++ [hsA]) . unEl)
DomType _ t -> __IMPOSSIBLE__
DomForall x ->
DomForall Nothing -> underAbstr a b skip
DomForall (Just x) ->
underAbstraction a b (compileInstRule (xs ++ [x]) cs . unEl)
where skip = compileInstRule xs cs . unEl
_ -> __IMPOSSIBLE__


Expand Down
10 changes: 6 additions & 4 deletions src/Agda2Hs/Compile/Data.hs
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,14 @@ compileConstructor params c = do
compileConstructorArgs :: Telescope -> C [Hs.Type ()]
compileConstructorArgs EmptyTel = return []
compileConstructorArgs (ExtendTel a tel) = compileDomType (absName tel) a >>= \case
DomType s hsA -> do
DomType s hsA -> do
ty <- addTyBang s hsA
(ty :) <$> underAbstraction a tel compileConstructorArgs
DomConstraint hsA -> agda2hsError "Not supported: constructors with class constraints"
DomDropped -> underAbstraction a tel compileConstructorArgs
DomForall{} -> __IMPOSSIBLE__
DomConstraint hsA -> agda2hsError "Not supported: constructors with class constraints"
DomDropped -> skip
DomForall Nothing -> skip
DomForall (Just _) -> __IMPOSSIBLE__
where skip = underAbstraction a tel compileConstructorArgs

checkCompileToDataPragma :: Definition -> String -> C ()
checkCompileToDataPragma def s = noCheckNames $ do
Expand Down
3 changes: 2 additions & 1 deletion src/Agda2Hs/Compile/Function.hs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ compileModuleParams (ExtendTel a tel) = do
(f , p) <- compileDomType (absName tel) a >>= \case
DomDropped -> return (id, [])
DomConstraint c -> return (constrainType c, [])
DomForall a -> return (qualifyType a, [])
DomForall Nothing -> return (id, [])
DomForall (Just a) -> return (qualifyType a, [])
DomType s a -> do
let n = hsName $ absName tel
checkValidVarName n
Expand Down
3 changes: 2 additions & 1 deletion src/Agda2Hs/Compile/Record.hs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ compileRecord target def = do
ToRecord{} -> agda2hsError $
"Not supported: record/class with constraint fields"
DomDropped -> return (hsAssts , hsFields)
DomForall{} -> __IMPOSSIBLE__
DomForall Nothing -> return (hsAssts , hsFields)
DomForall (Just _) -> __IMPOSSIBLE__
(_, _) -> __IMPOSSIBLE__

compileDataRecord
Expand Down
10 changes: 6 additions & 4 deletions src/Agda2Hs/Compile/Type.hs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ compileType t = do
DomType _ hsA -> Hs.TyFun () hsA <$> compileB
DomConstraint hsA -> constrainType hsA <$> compileB
DomDropped -> compileB
DomForall hsA -> qualifyType hsA <$> compileB
DomForall Nothing -> compileB
DomForall (Just hsA) -> qualifyType hsA <$> compileB

Def f es -> maybeUnfoldCopy f es compileType $ \f es -> do
def <- getConstInfo f
Expand Down Expand Up @@ -243,11 +244,12 @@ compileDomType x a =
| isNested -> do
tellExtension Hs.RankNTypes
-- tellExtension Hs.ExistentialQuantification
return $ DomForall $ Hs.UnkindedVar () $ Hs.Ident () x
return $ DomForall $ Just $ Hs.UnkindedVar () $ Hs.Ident () x
| ctx < npars -> do
tellExtension Hs.ScopedTypeVariables
return $ DomForall $ Hs.UnkindedVar () $ Hs.Ident () x
| otherwise -> return DomDropped
return $ DomForall $ Just $ Hs.UnkindedVar () $ Hs.Ident () x
-- Return an implicit forall.
| otherwise -> return $ DomForall Nothing
DOTerm -> fmap (uncurry DomType) . withNestedType . compileTypeWithStrictness . unEl $ unDom a

compileTeleBinds :: Bool -> Telescope -> C [Hs.TyVarBind ()]
Expand Down
4 changes: 2 additions & 2 deletions src/Agda2Hs/Compile/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ data CompiledDom
-- ^ To a Haskell type (with perhaps a strictness annotation)
| DomConstraint (Hs.Asst ())
-- ^ To a typeclass constraint
| DomForall (Hs.TyVarBind ())
-- ^ To an explicit forall
| DomForall (Maybe (Hs.TyVarBind ()))
-- ^ To a forall, with an optional type variable declaration. If Nothing, this is an implicit forall; otherwise, explicit.
| DomDropped
-- ^ To nothing (e.g. erased proofs)

Expand Down
1 change: 1 addition & 0 deletions test/AllFailTests.agda
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import Fail.NonCanonicalSuperclass
import Fail.Issue125
import Fail.Issue357a
import Fail.Issue357b
import Fail.Issue437
import Fail.DerivingParseFailure
import Fail.Issue306a
import Fail.Issue306b
Expand Down
5 changes: 5 additions & 0 deletions test/Fail/Issue437.agda
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module Fail.Issue437 where

data Indexed : (a : Set) → Set₁ where
MkIndexed : { a : Set } → Indexed a
{-# COMPILE AGDA2HS Indexed #-}
2 changes: 2 additions & 0 deletions test/golden/Issue437.err
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
test/Fail/Issue437.agda:3.6-13: error: [CustomBackendError]
agda2hs: Not supported: indexed datatypes
Loading