blob: 4f4d2f3d7f25fa3bb15697b8242182bf7df82cc6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
{-# LANGUAGE LambdaCase #-}
module Lib
( fromJotter
) where
import Term
data State = L | R
s :: Term
s = Abs (Abs (Abs (App (App (Idx 2) (Idx 0)) (App (Idx 1) (Idx 0)))))
k :: Term
k = Abs (Abs (Idx 1))
i :: Term
i = Abs (Idx 0)
-- reverse wouldn't be needed if [0F] instead of [F0]
fromJotter :: String -> Term
fromJotter = go L . reverse
where
go L ('0' : xs) = App s (go R xs)
go R ('0' : xs) = App (go L xs) s
go L ('1' : xs) = App k (go R xs)
go R ('1' : xs) = App (go L xs) k
go d (_ : xs) = go d xs
go _ [] = i
|