Skip to content

Commit

Permalink
[ builtins ] Char, String and Float now get COMPILED_TYPE for free
Browse files Browse the repository at this point in the history
  • Loading branch information
UlfNorell committed Oct 28, 2015
1 parent 988141b commit 7997e8e
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 11 deletions.
3 changes: 2 additions & 1 deletion doc/release-notes/2-4-4.txt
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,8 @@ Compiler backends

Since builtin naturals are compiled to Integer you can no longer
give a {-# COMPILED_DATA #-} pragma for Nat. The same goes for
builtin booleans which are now hard-wired to Haskell booleans.
builtin booleans, integers, floats, characters and strings which are now
hard-wired to appropriate Haskell types.


* UHC compiler backend
Expand Down
1 change: 0 additions & 1 deletion examples/simple-lib/Lib/Prelude.agda
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ data Unit : Set where

postulate String : Set

{-# COMPILED_TYPE String String #-}
{-# BUILTIN STRING String #-}

data _×_ (A B : Set) : Set where
Expand Down
2 changes: 1 addition & 1 deletion src/full/Agda/TypeChecking/Monad/Signature.hs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ ensureNoCompiledHaskell :: QName -> TCM ()
ensureNoCompiledHaskell q =
whenM (isJust . compiledHaskell . defCompiledRep <$> getConstInfo q) $
typeError $ GenericError $ "Multiple Haskell bindings for " ++ show q ++ ". " ++
"Note that builtin natural numbers and booleans don't need " ++
"Note that builtin numbers, booleans, chars and strings don't need " ++
"COMPILED pragmas."

addHaskellCode :: QName -> HaskellType -> HaskellCode -> TCM ()
Expand Down
5 changes: 5 additions & 0 deletions src/full/Agda/TypeChecking/Rules/Builtin.hs
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,8 @@ bindBuiltinBool = bindAndSetHaskellType builtinBool "Bool"
bindBuiltinInt :: Term -> TCM ()
bindBuiltinInt = bindAndSetHaskellType builtinInteger "Either Integer Integer"

bindBuiltinString :: Term -> TCM ()
bindBuiltinString = bindAndSetHaskellType builtinString "String"

bindBuiltinNat :: Term -> TCM ()
bindBuiltinNat t = do
Expand Down Expand Up @@ -485,6 +487,9 @@ bindBuiltinInfo (BuiltinInfo s d) e = do
case theDef def of
Axiom {} -> do
builtinSizeHook s q t'
when (s == builtinChar) $ addHaskellType q "Char"
when (s == builtinString) $ addHaskellType q "String"
when (s == builtinFloat) $ addHaskellType q "Double"
bindBuiltinName s e'
_ -> err
_ -> err
Expand Down
2 changes: 1 addition & 1 deletion std-lib
1 change: 0 additions & 1 deletion test/Common/Char.agda
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ postulate
Char : Set

{-# BUILTIN CHAR Char #-}
{-# COMPILED_TYPE Char Char #-}

private
primitive
Expand Down
1 change: 0 additions & 1 deletion test/Common/String.agda
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ postulate
String : Set

{-# BUILTIN STRING String #-}
{-# COMPILED_TYPE String String #-}

primitive
primStringAppend : String String String
Expand Down
3 changes: 2 additions & 1 deletion test/Fail/CompiledBuiltinBool.err
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
CompiledBuiltinBool.agda:12,1-43
Multiple Haskell bindings for CompiledBuiltinBool.Bool. Note that
builtin natural numbers and booleans don't need COMPILED pragmas.
builtin numbers, booleans, chars and strings don't need COMPILED
pragmas.
when checking the pragma COMPILED_DATA Bool Bool True False
5 changes: 3 additions & 2 deletions test/Fail/DuplicateBuiltinBinding.err
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
DuplicateBuiltinBinding.agda:6,1-30
Duplicate binding for built-in thing STRING, previous binding to
String
Multiple Haskell bindings for DuplicateBuiltinBinding.String. Note
that builtin numbers, booleans, chars and strings don't need
COMPILED pragmas.
when checking the pragma BUILTIN STRING String
1 change: 0 additions & 1 deletion test/interaction/Issue373.agda
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ postulate
String : Set

{-# BUILTIN STRING String #-}
{-# COMPILED_TYPE String String #-}

postulate
IO : Set Set
Expand Down
1 change: 0 additions & 1 deletion test/succeed/UniversePolymorphicIO.agda
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ postulate
String : Set

{-# BUILTIN STRING String #-}
{-# COMPILED_TYPE String String #-}

{-# COMPILED return (\_ _ -> return :: a -> IO a) #-}
{-# COMPILED _>>=_ (\_ _ _ _ ->
Expand Down

0 comments on commit 7997e8e

Please sign in to comment.