On Mon, Oct 31, 2011 at 5:33 PM, Ryan Ingram
For example, I would love to be able to use the arrow syntax to define objects of this type:
data Circuit a b where Const :: Bool -> Circuit () Bool Wire :: Circuit a a Delay :: Circuit a a And :: Circuit (Bool,Bool) Bool Or :: Circuit (Bool,Bool) Bool Not :: Circuit Bool Bool Then :: Circuit a b -> Circuit b c -> Circuit a c Pair :: Circuit a c -> Circuit b d -> Circuit (a,b) (c,d) First :: Circuit a b -> Circuit (a,c) (b,c) Swap :: Circuit (a,b) (b,a) AssocL :: Circuit ((a,b),c) (a,(b,c)) AssocR :: Circuit (a,(b,c)) ((a,b),c) Loop :: Circuit (a,b) (a,c) -> Circuit b c etc.
Then we can have code that examines this concrete data representation, converts it to VHDL, optimizes it, etc.
As mentioned by others, Adam Megacz's generalized arrow (and its syntax) could accomplish this. But if all you want is VHDL and the like, consider Conal Elliott's work on Vertigo, Pan, Compiling Embedded Languages [1], and the similar work on the Haskell GPipe package. [1] http://conal.net/papers/jfp-saig/ Regards, Dave
However, due to the presence of the opaque 'arr', there's no way to make this type an arrow without adding an 'escape hatch' Arr :: (a -> b) -> Circuit a b which breaks the abstraction: circuit is supposed to represent an actual boolean circuit; (Arr not) is not a valid circuit because we've lost the information about the existence of a 'Not' gate.
The arrow syntax translation uses arr to do plumbing of variables. I think a promising project would be to figure out exactly what plumbing is needed, and add those functions to a sort of 'PrimitiveArrow' class. All of these plumbing functions are trivially implemented in terms of 'arr', when it exists, but if it doesn't, it should be possible to use the arrow syntax regardless.
-- ryan
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe