Permalink
Browse files

TH fibs

  • Loading branch information...
maloi committed Aug 29, 2012
1 parent cb7e8d6 commit 3784d5df64285fcef2cc59b35e17ae904fe6f889
Showing with 19 additions and 0 deletions.
  1. +11 −0 Fibs.hs
  2. +8 −0 Main.hs
  3. BIN architecture.png
View
11 Fibs.hs
@@ -0,0 +1,11 @@
+{-# LANGUAGE TemplateHaskell #-}
+
+module Fibs where
+import Language.Haskell.TH
+import Language.Haskell.TH.Syntax
+
+fibs :: [Integer]
+fibs = 0 : 1 : zipWith (+) fibs (tail fibs)
+
+fibQ :: Int -> Q Exp
+fibQ n = [| $( lift $ fibs !! n) |]
View
@@ -0,0 +1,8 @@
+{-# LANGUAGE TemplateHaskell #-}
+
+module Main where
+import Language.Haskell.TH
+import Fibs
+
+
+main = print $(fibQ 100000)
View
Binary file not shown.

0 comments on commit 3784d5d

Please sign in to comment.