[Haskell] ANN: syntactic-0.1

Heinrich Apfelmus apfelmus at quantentunnel.de
Tue May 10 15:31:12 CEST 2011


Emil Axelsson wrote:
> Hello Heinrich! Thanks for your interest!
> 
> In principle, this is exactly the kind of thing you can do with 
> syntactic -- if you can make your data type fit into the framework, that 
> is. A compilation phase would then look something like this:
> 
>   phase :: AST (C1 :+: TheRest) -> AST (C2 :+: C3 :+: TheRest)
> 
> This phase destroys the constructor C1 and introduces C2 and C3.
> 
> Now, the question is whether your data type can be made to fit into the 
> framework. The only problem I can see (but there may be more!) is that 
> you'd have to treat EventD and BehaviorD as parts of the same data 
> structure. I've pasted an example of how to do that here:
> 
>   http://hpaste.org/46525/
> 
> Here, the difference between Event and Behavior is denoted by the type 
> constructors E and B respectively:
> 
>   type Event a = ASTF (Never :+: B2E :+: Pure :+: E2B) (E a)
> 
>   type Behavior a = ASTF (Never :+: B2E :+: Pure :+: E2B) (B a)
> 
> You decide if this seems like an acceptable solution...

Ah, interesting trick. I think it's ok because none of the data types 
contains superfluous constructors.

>> I'm also unhappy about some of the boilerplate. For instance, have a
>> look at the function  goE  in  compileAccumB  (line 210), it's just a
>> generic applicative traversal through the data type.
> 
> Most likely, this boilerplate could be simplified using syntactic.

Hm, does the boilerplate get removed or only simplified? I was hoping 
that one could use a completely generic traversal; but is that actually 
the case?

>> Would your library make me happier? Note that I have an additional
>> complication: I need to observe sharing and I need to support 
>> recursive AST.
> 
> I plan to add observable sharing soon. Once that's is in place, it 
> should -- I think/hope -- be easy to support cycles. This is not 
> something we need in Feldspar, so it might take a while before I get 
> around to supporting cycles, though.
> 
> I'd be happy to give more assistance should you choose to try out 
> syntactic for your library!

Thanks for your offer!

On closer inspection, I'm discovering another issue, namely the need for 
the  Typeable  class. This is quite unfortunate, because it would mean 
that I won't be able to make an API built on type classes like Functor 
or Applicative. Some discussion on that can be found at the end of

http://apfelmus.nfshost.com/blog/2011/04/24-frp-push-driven-sharing.html


So, it looks like I can't make use of  syntactic  at the moment. Then 
again, my library is probably one of the strongest tests of expressivity 
for  endeavors like  syntactic , so that's fine. Another example of 
similar difficulty would be D. Swierstra's recent parser/grammar 
combinators that can handle left-recursive grammars. Once  syntactic 
can deal with those, you're the king! :)


Best regards,
Heinrich Apfelmus

--
http://apfelmus.nfshost.com




More information about the Haskell mailing list