Skip to content

Instantly share code, notes, and snippets.

@lally
Created December 9, 2010 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lally/734713 to your computer and use it in GitHub Desktop.
Save lally/734713 to your computer and use it in GitHub Desktop.
It should print out its first argument via a call to puts().
type MainFunction = Function (Int32 -> Ptr (Ptr Word8) -> IO Int32)
buildReaderFun :: String -> CodeGenModule (MainFunction)
buildReaderFun nm = do
puts <- newNamedFunction ExternalLinkage "puts" ::
TFunction (Ptr Word8 -> IO Word32)
let callPuts format = (
createNamedFunction ExternalLinkage "main" $
\ argc argv -> do
tmp <- getElementPtr (argv ::Value (Ptr Word8))
(0 :: Int32, ())
call puts tmp -- Throw away return value.
ret (0 :: Int32)) :: CodeGenModule (MainFunction)
withStringNul nm callPuts
@lally
Copy link
Author

lally commented Dec 9, 2010

/research/phd/libmet/Listener.hs:1:0:
Couldn't match expected type Word8' against inferred typePtr Word8'
Expected type: Value (Ptr Word8) -> CodeGenFunction r Terminate
Inferred type: Value (Ptr (Ptr Word8)) -> b'
When using functional dependencies to combine
FunctionArgs (a -> b) (Value a -> b') r,
arising from the dependency f -> g r' in the instance declaration at <no location info> FunctionArgs (Ptr (Ptr Word8) -> IO Int32) (Value (Ptr Word8) -> CodeGenFunction r Terminate) (CodeGenFunction r ()), arising from a use ofcreateNamedFunction'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment