syntactic-0.8: Generic abstract syntax, and utilities for embedded languages

Safe HaskellNone



Reifying the sharing in an AST

This module is based on Type-Safe Observable Sharing in Haskell (Andy Gill, Haskell Symposium, 2009).





:: Typeable a 
=> (forall a. ASTF dom a -> Maybe (SatWit ctx a))

A function that decides whether a given node can be shared. Nothing means "don't share"; Just means "share". Nodes whose result type fulfills (Sat ctx a) can be shared, which is why the function returns a SatWit.

-> ASTF dom a 
-> IO (ASG ctx dom a) 

Convert a syntax tree to a sharing-preserving graph

This function is not referentially transparent (hence the IO). However, it is well-behaved in the sense that the worst thing that could happen is that sharing is lost. It is not possible to get false sharing.