Coder Social home page Coder Social logo

hask-monkey's Introduction

This is an early version of hask-monkey. Hask-monkey is a tool for exploring which types are reachable from just using function application with a user- provided set of functions. As the name "*-monkey" suggests, this is done quite stupidly by just repeatedly asking GHC for types. Currently, this search only consists of one iteration.

A practical example of this would be figuring out if you can derive "unsafeCoerce" from a library that implements some of its functions in terms of it. In other words, attempting to see if your usage of "unsafeCoerce" was valid or not. This use-case was the inspiration for this, however a good implementation would also be useful for type-driven code completion.

TODO:

  • Improve ruling out types due to clearly uninhabited constraints (will always just be sound and not complete)

  • Replace expressions with single variables, that use "undefined :: T"

  • See if tupling the entire generation yields a faster result

  • Options to disable ruling out types based on uninhabited constraints

  • Options for an upper bound on the size of the resulting types

Current output looks like:

hask-monkey, version 0.0.1

Enter expressions to speculate on
---------------------------------

:t (+)
  (Num a) => a -> a -> a
:t 1
  (Num a) => a
:t 

Results of speculation:

((+)) ((+))
  :: GHC.Num.Num is not implementable;

((+)) (1))
  ::   (Num a) => a -> a

(1) ((+))
  ::   (Num ((a -> a -> a) -> t), Num a) => t

(1) (1)
  ::   (Num (a -> t), Num a) => t

hask-monkey's People

Contributors

mgsloan avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.