Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mpickering
Created November 12, 2021 14:33
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 mpickering/457065b6ff777f09d862b2e1378d68ab to your computer and use it in GitHub Desktop.
Save mpickering/457065b6ff777f09d862b2e1378d68ab to your computer and use it in GitHub Desktop.
#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