Hardware Design with Generalized Arrows Adam Megacz [email protected] 03.Oct.2011 1/51 This Project (cid:73) First nontrivial application of generalized arrows. (cid:73) Not (even close to) a complete circuit-design solution. 3/51 Metaprogramming and the Milner Property (cid:73) A metaprogram is a program which produces a program (called the object program). (cid:73) Metaprogramming is the act of writing metaprograms. (cid:73) The Milner Property: “well-typed programs don’t go wrong.” (cid:73) When one is metaprogramming, we want something stronger: well-typed metaprograms should not be able to produce ill-typed object programs (therefore the object programs can’t go wrong). 5/51 Metaprogramming and the Milner Property (cid:73) A metaprogram is a program which produces a program (called the object program). (cid:73) Metaprogramming is the act of writing metaprograms. (cid:73) The Milner Property: “well-typed programs don’t go wrong.” (cid:73) When one is metaprogramming, we want something stronger: well-typed metaprograms should not be able to produce ill-typed object programs (therefore the object programs can’t go wrong). 5/51 Metaprogramming and the Milner Property (cid:73) A metaprogram is a program which produces a program (called the object program). (cid:73) Metaprogramming is the act of writing metaprograms. (cid:73) The Milner Property: “well-typed programs don’t go wrong.” (cid:73) When one is metaprogramming, we want something stronger: well-typed metaprograms should not be able to produce ill-typed object programs (therefore the object programs can’t go wrong). 5/51 Metaprogramming and the Milner Property (cid:73) A metaprogram is a program which produces a program (called the object program). (cid:73) Metaprogramming is the act of writing metaprograms. (cid:73) The Milner Property: “well-typed programs don’t go wrong.” (cid:73) When one is metaprogramming, we want something stronger: well-typed metaprograms should not be able to produce ill-typed object programs (therefore the object programs can’t go wrong). 5/51 What Problem Do Generalized Arrows Solve? Generalized arrows are a representation for object programs which: (cid:73) Has the “Milner property for metaprograms” (cid:73) Does not assume that the object language’s expressions are a superset of the metalanguage (like Monads and classic Arrows do). (cid:73) A monad’s return lifts arbitrary Haskell functions into the monad (cid:73) An arrow’s arr lifts arbitrary Haskell functions into the arrow (cid:73) Does not assume that the object language’s typing judgments are a superset of the metalanguage’s typing judgments (like Monads and classic Arrows do). (cid:73) Monadic metaprogramming cannot handle object languages with: (cid:73) affinetypes,becauseof(return $ \ -> ()) (cid:73) lineartypes,becauseof(return $ \x -> (x,x)) (cid:73) orderedtypes,becauseof(return $ \(x,y) -> (y,x)) (cid:73) Likewise for arrows. 7/51 What Problem Do Generalized Arrows Solve? Generalized arrows are a representation for object programs which: (cid:73) Has the “Milner property for metaprograms” (cid:73) Does not assume that the object language’s expressions are a superset of the metalanguage (like Monads and classic Arrows do). (cid:73) A monad’s return lifts arbitrary Haskell functions into the monad (cid:73) An arrow’s arr lifts arbitrary Haskell functions into the arrow (cid:73) Does not assume that the object language’s typing judgments are a superset of the metalanguage’s typing judgments (like Monads and classic Arrows do). (cid:73) Monadic metaprogramming cannot handle object languages with: (cid:73) affinetypes,becauseof(return $ \ -> ()) (cid:73) lineartypes,becauseof(return $ \x -> (x,x)) (cid:73) orderedtypes,becauseof(return $ \(x,y) -> (y,x)) (cid:73) Likewise for arrows. 7/51 What Problem Do Generalized Arrows Solve? Generalized arrows are a representation for object programs which: (cid:73) Has the “Milner property for metaprograms” (cid:73) Does not assume that the object language’s expressions are a superset of the metalanguage (like Monads and classic Arrows do). (cid:73) A monad’s return lifts arbitrary Haskell functions into the monad (cid:73) An arrow’s arr lifts arbitrary Haskell functions into the arrow (cid:73) Does not assume that the object language’s typing judgments are a superset of the metalanguage’s typing judgments (like Monads and classic Arrows do). (cid:73) Monadic metaprogramming cannot handle object languages with: (cid:73) affinetypes,becauseof(return $ \ -> ()) (cid:73) lineartypes,becauseof(return $ \x -> (x,x)) (cid:73) orderedtypes,becauseof(return $ \(x,y) -> (y,x)) (cid:73) Likewise for arrows. 7/51 What Problem Do Generalized Arrows Solve? Generalized arrows are a representation for object programs which: (cid:73) Has the “Milner property for metaprograms” (cid:73) Does not assume that the object language’s expressions are a superset of the metalanguage (like Monads and classic Arrows do). (cid:73) A monad’s return lifts arbitrary Haskell functions into the monad (cid:73) An arrow’s arr lifts arbitrary Haskell functions into the arrow (cid:73) Does not assume that the object language’s typing judgments are a superset of the metalanguage’s typing judgments (like Monads and classic Arrows do). (cid:73) Monadic metaprogramming cannot handle object languages with: (cid:73) affinetypes,becauseof(return $ \ -> ()) (cid:73) lineartypes,becauseof(return $ \x -> (x,x)) (cid:73) orderedtypes,becauseof(return $ \(x,y) -> (y,x)) (cid:73) Likewise for arrows. 7/51
Description: