2 kyu

Finally tagless interpreter

297 of 309tel

Description:

Write a typed interpreter for the finally tagless style language given. The language will use de Bruijn style names and includes a fixed point and functions for manipulating integers and booleans.

An example expression would be

\a -> \b -> a + b

which, rendered as a Term is

ex :: Term (Int -> Int -> Int)
ex = lambda (lambda (add (before here) here))

The use of de Bruijn indices means that instead of denoting variables by name they are denote by position instead. So, here is the variable most recently bound, and before here is the variable bound just prior to here.

Hint: This technique is discussed in a lecture from Oleg Kiselyov.

Interpreters
Algorithms

More By Author:

Check out these other kata created by tel

Stats:

CreatedSep 26, 2014
PublishedSep 26, 2014
Warriors Trained1046
Total Skips273
Total Code Submissions1180
Total Times Completed309
Haskell Completions297
Agda Completions18
Scala Completions5
Total Stars125
% of votes with a positive feedback rating97% of 73
Total "Very Satisfied" Votes68
Total "Somewhat Satisfied" Votes5
Total "Not Satisfied" Votes0
Ad
Contributors
  • tel Avatar
  • xcthulhu Avatar
  • Voile Avatar
  • lwoo1999 Avatar
  • crow-fff Avatar
Ad