Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exposing Haskell macros in Hakaru language #96

Open
GenevaS opened this issue Jul 6, 2017 · 2 comments
Open

Exposing Haskell macros in Hakaru language #96

GenevaS opened this issue Jul 6, 2017 · 2 comments

Comments

@GenevaS
Copy link
Contributor

GenevaS commented Jul 6, 2017

There are some distributions (e.g. Cauchy, Weibull, ...) that exist in the Haskell files, but are not part of the exposed Hakaru syntax. Could these be added so that they can be accessed in Hakaru concrete syntax programs?

@yuriy0
Copy link

yuriy0 commented Jul 7, 2017

The simplest way to deal with this is to inline the definition of each function in each file where it's needed. That would probably get tedious very quickly, so I agree we need something better.

One solution is the import mechanism, which has existed for a while, but has never (?) been used. There was a discussion a while back where it was concluded that the easiest to implement import mechanism is cpp, but for testing purposes that requires calling cpp from Haskell, which doesn't seem too nice to me. To this end, I've (re?)enabled the import mechanism, as well as made it look in the same directory as the source file for the imports (f313a8a). Maybe if people use it, it will have cause to become more elaborate/functional!

Another possible solution is to expose already-typed terms (i.e. those in internal syntax, defined in Haskell) to the typechecker. A very basic implementation is here: a4c6c54, 271fc8f. Although, I'm not sure how useful this is in general. It also creates programs that don't look very nice:

 $ echo "weibull(1,2)" | pretty -
(fn x2 prob:
 fn x1 prob:
 x0 <~ gamma(1/1, 1/1)
 return x2 * x0 ** prob2real(1/ x1))
  (nat2prob(1), nat2prob(2))

@zaxtax
Copy link
Member

zaxtax commented Jul 7, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants