1 `b18n-combined`: Combining Syntactic and Semantic Bidirectionalization
2 ======================================================================
7 This program, `b18n-combined`, is a prototype implementation of
8 the paper "Combining Syntactic and Semantic Bidirectionalization"
9 written by Janis Voigtländer, Zhenjiang Hu, Kazutaka Matsuda,
10 and Meng Wang, which is accepted at ICFP'10.
12 The program takes input program describing a view function that constructs a view from a source,
13 and generates a put-back function that reflects updates on the view to the source.
14 Thanks to combination of syntactic and semantic bidirectionalization,
15 the program can generates effective put-back functions in the sense that
16 the generated put-back functions can put back more updates than
17 those obtained by either of syntactic/semantic bidirectionalization.
22 A [CGI version] of the program is provided for your convenience.
24 [CGI version]: http://www.kb.ecei.tohoku.ac.jp/~kztk/b18n-combined/
30 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.shell}
31 $ cat example/init.txt
34 init (a:b:x) = a:initWork b x
36 initWork a (b:x) = a:initWork b x
37 $ ./dist/build/b18n-combined/b18n-combined example/sieve.txt -syn -hs
43 | Csieve_Cmpl_3 t1 (Cmpl t0 t1)
46 sieve (a : (b : x)) = b : sieve (x)
47 sieve_B s v = head (sieve_T_I v (sieve_Cmpl s))
48 sieve_Cmpl ([]) = Csieve_Cmpl_1
49 sieve_Cmpl (a : []) = Csieve_Cmpl_2 a
50 sieve_Cmpl (a : (b : x)) = Csieve_Cmpl_3 a (sieve_Cmpl (x))
51 sieve_T_I x1 x2 = mplus (sieve_T_I_1 x1 x2) (mplus (sieve_T_I_2 x1 x2) (mplus (sieve_T_I_3 x1 x2) mzero))
52 sieve_T_I_1 [] (Csieve_Cmpl_1) = do return ([])
53 sieve_T_I_1 _ _ = mzero
54 sieve_T_I_2 [] (Csieve_Cmpl_2 a) = do return (a : [])
55 sieve_T_I_2 _ _ = mzero
56 sieve_T_I_3 (b : tv1) (Csieve_Cmpl_3 a
57 tc1) = do (x) <- sieve_T_I tv1 tc1
59 sieve_T_I_3 _ _ = mzero
60 $ ./b18n-combined example/sieve.txt -sem
67 sieve (a : (b : x)) = b : sieve (x)
68 $ ./b18n-combined example/sieve.txt -comb
72 = gen_put_bias bias Main.sieve(\x y -> castError $ (sieve_22_B $! x) $! y) s v
73 sieve_Bbd = withDefaultBias sieve_Bb
74 sieve_Bd = withDefault sieve_B
75 sieve_B s v = sieve_Bb rear s v
81 sieve (a : (b : x)) = b : sieve (x)
82 sieve_22_B s v = head (sieve_22_T_I v (sieve_22_Cmpl s))
83 sieve_22_Cmpl (Z) = Csieve_22_Cmpl_1
84 sieve_22_Cmpl (S (Z)) = Csieve_22_Cmpl_2
85 sieve_22_Cmpl (S (S x)) = sieve_22_Cmpl (x)
86 sieve_22_T_I x1 x2 = mplus (sieve_22_T_I_1 x1 x2) (mplus (sieve_22_T_I_2 x1 x2) (mplus (sieve_22_T_I_3 x1 x2) mzero))
87 sieve_22_T_I_1 (Z) (Csieve_22_Cmpl_1) = do return (Z)
88 sieve_22_T_I_1 _ _ = mzero
89 sieve_22_T_I_2 (Z) (Csieve_22_Cmpl_2) = do return (S Z)
90 sieve_22_T_I_2 _ _ = mzero
91 sieve_22_T_I_3 (S tv1) tc1 = do (x) <- sieve_22_T_I tv1 tc1
93 sieve_22_T_I_3 _ _ = mzero
94 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
100 0. Install [GHC] and make sures that following Haskell packages
102 * mtl, template-haskell, containers, pretty, parsec (for web interface: directory, xhtml, cgi, utf8-string, bytestring, unix, hint >= 0.3.2)
103 1. Get the source tarball from
104 [./b18n-combined-0.1.tar.gz](./b18n-combined-0.1.tar.gz).
105 2. Unfold the source tarball
106 * `tar zxvf b18n-combined-0.1.tar.gz`
107 3. Build the executables by
111 Note that the source code is also available via darcs.
113 darcs get http://www.kb.ecei.tohoku.ac.jp/~kztk/darcs/sem_syn/
115 [GHC]: http://www.haskell.org/ghc/
121 Current implementation can handle lists only.
125 ----------------------------------------------------
126 <address>Kazutaka Matsuda: <kztk@kb.ecei.tohoku.ac.jp>.</address>
128 <p>The first version of this page was published in Jul. 29th, 2010.</p>