Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

TH fibs

  • Loading branch information...
commit 3784d5df64285fcef2cc59b35e17ae904fe6f889 1 parent cb7e8d6
@maloi maloi authored
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
8 Main.hs
@@ -0,0 +1,8 @@
+{-# LANGUAGE TemplateHaskell #-}
+
+module Main where
+import Language.Haskell.TH
+import Fibs
+
+
+main = print $(fibQ 100000)
View
BIN  architecture.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Please sign in to comment.
Something went wrong with that request. Please try again.