ycextra-0.1: Additional utilities to work with Yhc Core.

Yhc.Core.Selector

Synopsis

Documentation

coreSelectorIndex :: Core -> CoreFuncName -> (CoreCtorName, Int)Source

Given an expr (normally a CoreApp) tell if it is an application of a selector function to a data object. Selector functions consist of a single CoreCase statement with the only alternative. Application must be exactly to one argument. The case alternative must be a constructor application to field selectors, and the return value must be one of the selectors. If the analysis condition is satisfied, constructor name and a field index are returned. Otherwise empty string and -1 are returned. The index returned is zero-based.