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

ghcmod.vim should support the split, sig, and refine commands #68

Open
cdepillabout opened this issue Jan 4, 2015 · 4 comments
Open

Comments

@cdepillabout
Copy link
Contributor

ghcmod added support for split, sig, and refine commands. This is similar to the functionality available in Idris and Agda plugins.

split:
DanielG/ghc-mod#274

    - split FILE [MODULE] LINE COL
        Split a function case by examining a type's constructors.

        For example given the following code snippet:

            f :: [a] -> a
            f x = _body

        would be replaced by:

            f :: [a] -> a
            f [] = _body
            f (x:xs) = _body

sig:
DanielG/ghc-mod#274

    - sig FILE MODULE LINE COL
        Generate initial code given a signature.

        For example when (LINE,COL) is on the signature in the following
        code snippet:

            func :: [a] -> Maybe b -> (a -> b) -> (a,b)

        ghc-mod would add the following on the next line:

            func x y z f = _func_body

refine:
DanielG/ghc-mod#311

    - refine FILE MODULE LINE COL EXPR
        Refine the typed hole at (LINE,COL) given EXPR.

        For example if EXPR is `filter', which has type `(a -> Bool) -> [a]
          -> [a]' and (LINE,COL) is on the hole `_body' in the following
        code snippet:

            filterNothing :: [Maybe a] -> [a]
            filterNothing xs = _body

        ghc-mod changes the code to get a value of type `[a]', which   
        results in:

            filterNothing xs = filter _body_1 _body_2
@ches
Copy link

ches commented Feb 16, 2015

FYI there is work for split on #69.

eagletmt added a commit that referenced this issue Jul 26, 2015
@eagletmt
Copy link
Owner

Added support for ghc-mod sig .
I also tried to support ghc-mod refine, but I couldn't find how to use it.

module Refine where

filterNothing :: [Maybe a] -> [a]
filterNothing xs = _body

ghc-mod refine Refine.hs Refine 4 20 filter outputs nothing. Could you show me a working example?

I'm using https://github.com/kazu-yamamoto/ghc-mod/tree/4b2be9c9edbd377c3d95b6685ab53e7c5270edea compiled with GHC 7.10.1.

@albertnetymk
Copy link

I think your usage is correct. Using this hello-world like repo, and ghc-mod refine src/main.hs Main 4 20 filter, I get this:

4 20 4 25 "filter _body_1 _body_2"

@DanielG
Copy link

DanielG commented Aug 7, 2015

All that stuff is broken with 7.10 ATM. See DanielG/ghc-mod#438

expipiplus1 pushed a commit to expipiplus1/ghcmod-vim that referenced this issue Oct 26, 2015
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

5 participants