Skip to content

PureScript source code knowledge extraction and querying support.

License

Notifications You must be signed in to change notification settings

epost/psc-query

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

Intended to translate PureScript programs like this:

module Fnord.Zoink.Test1 where

data Traffic = Red | Green

newtype Sum a = Sum a

f x = x + 1

into fact stores like the following. This initial version uses Prolog / datalog notation for now:

% facts
module("Test1").
module("Zoink").
module("Fnord").
data("Traffic").
newtype("Sum").
value("f").
data_ctor("Red", "Traffic").
data_ctor("Green", "Traffic").
data_ctor("Sum", "Sum").
defined_in("Test1", "Zoink").
defined_in("Zoink", "Fnord").
defined_in("Traffic", "Test1").
defined_in("Sum", "Test1").
defined_in("f", "Test1").

% rules
defined_in_star(X, Y) :- defined_in(X, Y).
defined_in_star(X, Y) :- defined_in(X, Z), defined_in_star(Z, Y).

This can be queried using various tools, for example Prolog or Datalog.js. A query like this:

defined_in_star(X, "Test1")?

would yield:

% defined_in_star(X, "Test1")?
defined_in_star(f, "Test1").
defined_in_star("Sum", "Test1").
defined_in_star("Traffic", "Test1").

The idea is to build tooling on top of this, such as editor support. The same can be done for languages other than PureScript.

Related work