Skip to content

Instantly share code, notes, and snippets.

@mpickering
Created Nov 12, 2021
Embed
What would you like to do?
#include "header.h"
int q() {
int e = foo(0);
return(0);
}
#include <HsFFI.h>
int foo(int);
{-# LANGUAGE TemplateHaskell #-}
module Main where
import P
main = $([| return () |])
module P where
foreign export ccall foo :: Int -> IO Int
foo :: Int -> IO Int
foo n = return (length (f n))
f :: Int -> [Int]
f 0 = []
f n = n:(f (n-1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment