Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
ivory/ivory-examples/examples/FibTutorial.hs
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
28 lines (21 sloc)
590 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE TypeOperators #-} | |
module FibTutorial where | |
import Ivory.Language | |
import qualified Ivory.Compile.C.CmdlineFrontend as C (compile) | |
fib_loop :: Def ('[Ix 1000] ':-> Uint32) | |
fib_loop = proc "fib_loop" $ \ n -> body $ do | |
a <- local (ival 0) | |
b <- local (ival 1) | |
n `times` \ _ -> do | |
a' <- deref a | |
b' <- deref b | |
store a b' | |
store b (a' + b') | |
result <- deref a | |
ret result | |
fib_tutorial_module :: Module | |
fib_tutorial_module = package "fib_tutorial" $ do | |
incl fib_loop | |
main :: IO () | |
main = C.compile [ fib_tutorial_module ] [] |