agda2hs
agda2hs copied to clipboard
Postulates are not exported
If a type is postulated, but aliased via the COMPILE
pragma, it is not exported for other modules to use.
In the example below, ByteString
is not accessible from Haskell modules that import the module with this postulate.
postulate
ByteString : Set
emptyBS : ByteString
concatBS : List ByteString → ByteString
eqBS : ByteString → ByteString → Bool
{-# COMPILE GHC ByteString = type BS.ByteString #-}
{-# COMPILE GHC emptyBS = BS.empty #-}
{-# COMPILE GHC concatBS = BS.concat #-}
{-# COMPILE GHC eqBS = (==) #-}
{-# FOREIGN AGDA2HS
emptyBS :: ByteString
emptyBS = BS.empty
concatBS :: [ByteString] -> ByteString
concatBS = BS.concat
eqBS :: ByteString -> ByteString -> Bool
eqBS = (==)
#-}
That's probably because Agda2hs ignores {-# COMPILE GHC … #-}
pragmas? If you want Agda2hs to do something, I would expect a {-# COMPILE AGDA2HS … #-}
pragma. 😅
To support this properly we would need to have a dedicated pragma for indicating that an Agda postulate corresponds to an existing Haskell function, which we do not have at the moment (see https://github.com/agda/agda2hs/issues/119).
To support this properly we would need to have a dedicated pragma for indicating that an Agda postulate corresponds to an existing Haskell function, which we do not have at the moment (see https://github.com/agda/agda2hs/issues/119).
Alternatively we could use the presence of a rewrite rule as an indicator that a symbol exists on the Haskell side.
The rewrite-rule resolves the issue for the example above:
rewrites:
- from: "<Module>.ByteString"
to: "ByteString"
importing: "Data.ByteString"
Since we already have a supported way to do this, I'm closing this issue.