Re: Determining if an instance is provided by the environment

2016-05-06 Thread Edward Z. Yang
Well, I have to write the new variant of this function :)

Simon, I ran into a minor complication: if my instance is
something like:

instance Show a => Show [a]

I think I need to pass in a 'CtGiven' for 'Show a'.  However,
I don't know what to pass as the evidence to the 'CtGiven'
constraints.  My guess is that it doesn't matter?

Edward

Excerpts from David Fox's message of 2016-05-06 17:06:41 -0700:
> Is there a way to connect this to template-haskell or haskell-src-exts code?
> 
> On Fri, May 6, 2016 at 4:40 PM, Edward Z. Yang  wrote:
> 
> > Thanks Simon, that has all the ingredients I need.
> >
> > I wrote some more docs for the function:
> > https://phabricator.haskell.org/D2180
> >
> > Edward
> >
> > Excerpts from Simon Peyton Jones's message of 2016-05-06 02:05:31 -0700:
> > > You probably want a variant on TcDeriv.simplifyDeriv, shorn of its
> > complex error reporting.
> > >
> > > Simon
> > >
> > > |  -Original Message-
> > > |  From: ghc-devs [mailto:ghc-devs-boun...@haskell.org] On Behalf Of
> > > |  Edward Z. Yang
> > > |  Sent: 06 May 2016 00:21
> > > |  To: ghc-devs 
> > > |  Subject: Determining if an instance is provided by the environment
> > > |
> > > |  Hello all,
> > > |
> > > |  Suppose I have a ClsInst from typechecking the following instance
> > > |  declaration:
> > > |
> > > |  instance Show [Char] -- i.e. String
> > > |
> > > |  I'd now like to answer the question: "Is this instance 'provided'
> > > |  by the instance environment?"  For example, this instance is provided
> > > |  given that I have these two instances in the environment:
> > > |
> > > |  instance Show a => Show [a] -- (1)
> > > |  instance Show Char  -- (2)
> > > |
> > > |  However, if I have just instance (1) in the environment, it's not
> > > |  provided (and if you tried to use show "foo", you'd get the error that
> > > |  Char is not an instance of Show.)
> > > |
> > > |  Is there are convenient way to do this from TcM?  With 'tcMatchTys'
> > > |  and I can easily test if there is some instance in the environment
> > > |  which *matches* my instance head (e.g., Show [a] matches Show [Char])
> > > |  but this doesn't tell me if all the resulting constraints are
> > solvable.
> > > |
> > > |  Thanks,
> > > |  Edward
> > > |  ___
> > > |  ghc-devs mailing list
> > > |  ghc-devs@haskell.org
> > > |
> > https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2fmail.ha
> > > |  skell.org%2fcgi-bin%2fmailman%2flistinfo%2fghc-
> > > |  devs=01%7c01%7csimonpj%40064d.mgd.microsoft.com
> > %7c8c304d9b355244c6
> > > |
> > ee7208d3753be740%7c72f988bf86f141af91ab2d7cd011db47%7c1=iWdrnb6hC
> > > |  8pexyVkWNG22G%2fgdO10tCBy8nuCxhnO0M8%3d
> > ___
> > ghc-devs mailing list
> > ghc-devs@haskell.org
> > http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
> >
___
ghc-devs mailing list
ghc-devs@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs


Re: Determining if an instance is provided by the environment

2016-05-06 Thread David Fox
Is there a way to connect this to template-haskell or haskell-src-exts code?

On Fri, May 6, 2016 at 4:40 PM, Edward Z. Yang  wrote:

> Thanks Simon, that has all the ingredients I need.
>
> I wrote some more docs for the function:
> https://phabricator.haskell.org/D2180
>
> Edward
>
> Excerpts from Simon Peyton Jones's message of 2016-05-06 02:05:31 -0700:
> > You probably want a variant on TcDeriv.simplifyDeriv, shorn of its
> complex error reporting.
> >
> > Simon
> >
> > |  -Original Message-
> > |  From: ghc-devs [mailto:ghc-devs-boun...@haskell.org] On Behalf Of
> > |  Edward Z. Yang
> > |  Sent: 06 May 2016 00:21
> > |  To: ghc-devs 
> > |  Subject: Determining if an instance is provided by the environment
> > |
> > |  Hello all,
> > |
> > |  Suppose I have a ClsInst from typechecking the following instance
> > |  declaration:
> > |
> > |  instance Show [Char] -- i.e. String
> > |
> > |  I'd now like to answer the question: "Is this instance 'provided'
> > |  by the instance environment?"  For example, this instance is provided
> > |  given that I have these two instances in the environment:
> > |
> > |  instance Show a => Show [a] -- (1)
> > |  instance Show Char  -- (2)
> > |
> > |  However, if I have just instance (1) in the environment, it's not
> > |  provided (and if you tried to use show "foo", you'd get the error that
> > |  Char is not an instance of Show.)
> > |
> > |  Is there are convenient way to do this from TcM?  With 'tcMatchTys'
> > |  and I can easily test if there is some instance in the environment
> > |  which *matches* my instance head (e.g., Show [a] matches Show [Char])
> > |  but this doesn't tell me if all the resulting constraints are
> solvable.
> > |
> > |  Thanks,
> > |  Edward
> > |  ___
> > |  ghc-devs mailing list
> > |  ghc-devs@haskell.org
> > |
> https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2fmail.ha
> > |  skell.org%2fcgi-bin%2fmailman%2flistinfo%2fghc-
> > |  devs=01%7c01%7csimonpj%40064d.mgd.microsoft.com
> %7c8c304d9b355244c6
> > |
> ee7208d3753be740%7c72f988bf86f141af91ab2d7cd011db47%7c1=iWdrnb6hC
> > |  8pexyVkWNG22G%2fgdO10tCBy8nuCxhnO0M8%3d
> ___
> ghc-devs mailing list
> ghc-devs@haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
>
___
ghc-devs mailing list
ghc-devs@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs


RE: Determining if an instance is provided by the environment

2016-05-06 Thread Edward Z. Yang
Thanks Simon, that has all the ingredients I need.

I wrote some more docs for the function: https://phabricator.haskell.org/D2180

Edward

Excerpts from Simon Peyton Jones's message of 2016-05-06 02:05:31 -0700:
> You probably want a variant on TcDeriv.simplifyDeriv, shorn of its complex 
> error reporting.
> 
> Simon
> 
> |  -Original Message-
> |  From: ghc-devs [mailto:ghc-devs-boun...@haskell.org] On Behalf Of
> |  Edward Z. Yang
> |  Sent: 06 May 2016 00:21
> |  To: ghc-devs 
> |  Subject: Determining if an instance is provided by the environment
> |  
> |  Hello all,
> |  
> |  Suppose I have a ClsInst from typechecking the following instance
> |  declaration:
> |  
> |  instance Show [Char] -- i.e. String
> |  
> |  I'd now like to answer the question: "Is this instance 'provided'
> |  by the instance environment?"  For example, this instance is provided
> |  given that I have these two instances in the environment:
> |  
> |  instance Show a => Show [a] -- (1)
> |  instance Show Char  -- (2)
> |  
> |  However, if I have just instance (1) in the environment, it's not
> |  provided (and if you tried to use show "foo", you'd get the error that
> |  Char is not an instance of Show.)
> |  
> |  Is there are convenient way to do this from TcM?  With 'tcMatchTys'
> |  and I can easily test if there is some instance in the environment
> |  which *matches* my instance head (e.g., Show [a] matches Show [Char])
> |  but this doesn't tell me if all the resulting constraints are solvable.
> |  
> |  Thanks,
> |  Edward
> |  ___
> |  ghc-devs mailing list
> |  ghc-devs@haskell.org
> |  https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2fmail.ha
> |  skell.org%2fcgi-bin%2fmailman%2flistinfo%2fghc-
> |  devs=01%7c01%7csimonpj%40064d.mgd.microsoft.com%7c8c304d9b355244c6
> |  ee7208d3753be740%7c72f988bf86f141af91ab2d7cd011db47%7c1=iWdrnb6hC
> |  8pexyVkWNG22G%2fgdO10tCBy8nuCxhnO0M8%3d
___
ghc-devs mailing list
ghc-devs@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs


Re: Mentor for a JVM backend for GHC

2016-05-06 Thread Alois Cochard
Hi Rahul,

Exicting to see other folks interested into doing this!

I did started an exprimental project on this at the end of last year, sadly
I did not had much time to work on it and it was closed sources, I just
opened it, so maybe we can share/reuse stuff?

Please take a look at this repository: https://github.com/aloiscochard/kuna

The most useful part is probaly the java assembly, I was not so happy of
hs-java so I rewrote an assembler from scratch.

To be honest I have not yet looked in your code, but I'll definitely will.

Let's keep in touch!

Cheers

On 2 May 2016 at 17:26, Rahul Muttineni  wrote:

> Hi GHC Developers,
>
> I've started working on a JVM backend for GHC [1] and I'd love to work on
> it as my Summer of Haskell project.
>
> Currently, the build system is setup using a mix of Shake (for the RTS
> build) and Stack (for the main compiler build) and I ensure that most
> commits build successfully. I have ported the core part of the scheduler
> and ported over the fundamental types (Capability, StgTSO, Task,
> StgClosure, etc.) taking advantage of OOP in the implementation when I
> could.
>
> Additionally, I performed a non-trivial refactor of the hs-java package
> adding support for inner classes and fields which was very cumbersome to do
> in the original package. On the frontend, I have tapped into the STG code
> from the GHC 7.10.3 library and setup a CodeGen monad for generating JVM
> bytecode. The main task of generating the actual bytecode, porting the more
> critical parts of the RTS, and adding support for the threaded RTS remain.
>
> The strategy for compilation is as follows:
> - Intercept the STG code in the GHC pipeline
> - Convert from STG->JVM bytecode [2] in a similar manner as STG->Cmm
> preserving semantics as best as possible [3]
> - Port the GHC RTS (normal & threaded) to Java [4]
> - Put all the generated class files + RTS into a single jar to be run
> directly by the JVM.
>
> My objectives for the project during the summer are:
> - To implement the compilation strategy mentioned above
> - Implement the Java FFI for foreign imports. [5]
> - Implement the most important [6] PrimOps that GHC supports.
> - Port the base package replacing the C FFI imports with equivalent Java
> FFI imports. [7]
>
> A little bit about myself: I spent a lot of time studying functional
> language implementation by reading SPJ's famous book and reading research
> papers on related topics last summer as self-study.
>
> I took a break and resumed a couple months ago where I spent a lot of time
> plowing through the STG->Cmm code generator as well as the RTS and going
> back and forth between them to get a clear understanding of how everything
> works.
>
> Moreover, I compiled simple Haskell programs and observed the STG, Cmm,
> and assembly output (by decompiling the final executable with objdump) to
> understand bits of the code generator where the source code wasn't that
> clear.
>
> I also spent a great deal of time studying the JVM internals, reading the
> JVM spec, looking for any new features that could facilitate a high
> performance implementation [8].
>
> It would be great if someone with an understanding of nuances of the RTS
> and code generator could mentor me for this project. It has been a blast so
> far learning all the prerequisites and contemplating the design. I'd be
> very excited to take this on as a summer project.
>
> Also, given that I have hardly 5 days remaining, does anyone have
> suggestions on how I can structure the proposal without getting into too
> many details? There are still some parts of the design I haven't figured
> out, but I know I could find some solution when I get to it during the
> porting process.
>
> Thanks,
> Rahul Muttineni
>
> [1] http://github.com/rahulmutt/ghcvm
>
> [2] I intend to organically derive an IR at a later stage to allow for
> some optimizations by looking at the final working implementation without
> an IR and looking for patterns of repeated sequences of bytecode and
> assigning each sequence its own instruction in the IR.
>
> [3] Obviously, the lack of control of memory layouts (besides allocating
> off the JVM heap using DirectByteBuffers) and lack of general tail calls
> makes it tough to match the semantics of Cmm, but there are many solutions
> around it, as can be found in the few papers on translating STG to Java/JVM
> bytecode.
>
> [4] This is the GHC RTS without GC and profiling since the JVM has great
> support for those already. Also, lots of care must be taken to ensure that
> the lock semantics stays in tact during the port.
>
> [5] foreign exports will be dealt at a later stage, but I am taking care
> of naming the closures nicely so that in the future you don't have to type
> long names like the labels GHC compiles to call a Haskell function in Java.
>
> [6] Basically all the PrimOps that would be required to provide plumbing
> for the Prelude functions that can compile beginner-level programs 

RE: Determining if an instance is provided by the environment

2016-05-06 Thread Simon Peyton Jones
You probably want a variant on TcDeriv.simplifyDeriv, shorn of its complex 
error reporting.

Simon

|  -Original Message-
|  From: ghc-devs [mailto:ghc-devs-boun...@haskell.org] On Behalf Of
|  Edward Z. Yang
|  Sent: 06 May 2016 00:21
|  To: ghc-devs 
|  Subject: Determining if an instance is provided by the environment
|  
|  Hello all,
|  
|  Suppose I have a ClsInst from typechecking the following instance
|  declaration:
|  
|  instance Show [Char] -- i.e. String
|  
|  I'd now like to answer the question: "Is this instance 'provided'
|  by the instance environment?"  For example, this instance is provided
|  given that I have these two instances in the environment:
|  
|  instance Show a => Show [a] -- (1)
|  instance Show Char  -- (2)
|  
|  However, if I have just instance (1) in the environment, it's not
|  provided (and if you tried to use show "foo", you'd get the error that
|  Char is not an instance of Show.)
|  
|  Is there are convenient way to do this from TcM?  With 'tcMatchTys'
|  and I can easily test if there is some instance in the environment
|  which *matches* my instance head (e.g., Show [a] matches Show [Char])
|  but this doesn't tell me if all the resulting constraints are solvable.
|  
|  Thanks,
|  Edward
|  ___
|  ghc-devs mailing list
|  ghc-devs@haskell.org
|  https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2fmail.ha
|  skell.org%2fcgi-bin%2fmailman%2flistinfo%2fghc-
|  devs=01%7c01%7csimonpj%40064d.mgd.microsoft.com%7c8c304d9b355244c6
|  ee7208d3753be740%7c72f988bf86f141af91ab2d7cd011db47%7c1=iWdrnb6hC
|  8pexyVkWNG22G%2fgdO10tCBy8nuCxhnO0M8%3d
___
ghc-devs mailing list
ghc-devs@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs


pmcheck/T11195

2016-05-06 Thread Simon Peyton Jones
Harbourmaster is failing (“Killed”) on pmcheck/should_compile/T11195.
Are others finding this?  What should we do?
SImon
___
ghc-devs mailing list
ghc-devs@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs