Re: Quick Q: do all FFI (non-primop) calls involve State# and RealWorld?

2019-11-09 Thread Christopher Done
For anyone interested, here's a complete list of all foreign imports at the STG level from base and integer-simple: https://gist.github.com/chrisdone/24b476862b678a3665fbf9b833a9905f They all have type (# State# RealWorld #) or (# State# RealWorld, #). On Tue, 5 Nov 2019 at 15:18, Christ

Re: Quick Q: do all FFI (non-primop) calls involve State# and RealWorld?

2019-11-05 Thread Christopher Done
Aha, thanks Csaba. So I’m not losing my marbles. The AST has a type signature of the “initial” but implements the “lowered”. So with -ddump-stg we can observe it: The version claimed in the type signature (returning a tuple): Foreign.it :: Foreign.C.Types.CDouble [GblId] = [] \u [] ca

Compiling binaries of bytecode: ever been considered?

2019-11-04 Thread Christopher Done
Hi all, I was just wondering: has a compiler output mode ever been considered that would dump bytecode to a file, dynamic link to the ghc runtime, and then on start-up that program would just interpret the bytecode like ghci does? The purpose would be simply faster compile-and-restart times. Che

Quick Q: do all FFI (non-primop) calls involve State# and RealWorld?

2019-10-28 Thread Christopher Done
Hi all, I tried compiling this file: {-# LANGUAGE NoImplicitPrelude #-}-- | Demonstrate various use of the FFI.module Foreign whereimport Foreign.Cforeign import ccall "math.h sin" sin :: CDouble -> CDoubleit :: CDoubleit = sin 1 And I’ve noticed that the annotated type given for this foreign op

Re: Newtypes in STG

2019-04-01 Thread Christopher Done
On Mon, 1 Apr 2019 at 09:22, Simon Peyton Jones simo...@microsoft.com wrote: That does look odd. Can you explain how to reproduce this with HEAD? That is, are we getting a newtype constructor in the argument position of an StgApp in HEAD too? Newtype “data co

Re: Newtypes in STG

2019-03-30 Thread Christopher Done
this. On Sat, 30 Mar 2019 at 14:05, Christopher Done wrote: > Hi all, > > Could you offer some insight into newtypes at the STG level? Here’s the > context: > >1. > >I’m working on this interpreter for STG >(https://github.com/chrisdone/prana) and I’m trying

Newtypes in STG

2019-03-30 Thread Christopher Done
Hi all, Could you offer some insight into newtypes at the STG level? Here’s the context: 1. I’m working on this interpreter for STG (https://github.com/chrisdone/prana) and I’m trying to generate a pristine AST where all names in it are resolved to something known to me. 2.

Is this the correct way to get Stg for a module?

2019-02-15 Thread Christopher Done
Hi all, I'm attempting to get the Stg for a module with the intention of interpreting it myself. Here is a self-contained GHC-8.4.3-specific test-case to get STG: https://gist.github.com/chrisdone/08ef9e8447b71c9dadc5bba949cda638#file-printstgghc8_4_3-hs-L47-L76 I'm using the handy helpers GHC.

Re: Constructor wrappers vs workers in generated Core

2019-02-08 Thread Christopher Done
ram as > possible then you could print `$WFoo` as just `Foo`? > > The existence of wrappers is a crucial part of desugaring so perhaps > it's useful for users to see them in the output of your program if > it's intended to be educational? > > Matt > > > On Sat

Re: Constructor wrappers vs workers in generated Core

2019-02-02 Thread Christopher Done
On Sat, 2 Feb 2019 at 14:50, Matthew Pickering wrote: > There is no way to turn off wrappers and I don't think it would be > possible to implement easily if at all. Fair enough. > However, they will all probably be inlined after the optimiser runs > but it seems that you don't want to run the op

Constructor wrappers vs workers in generated Core

2019-02-02 Thread Christopher Done
Hi all, I'm compiling Haskell modules with this simple function. I'd like to interpret the Core for practical use and also educational use. compile :: GHC.GhcMonad m => GHC.ModSummary -> m GHC.ModGuts compile modSummary = do parsedModule <- GHC.parseModule modSummary typecheckedModul

Max identifier length

2019-01-14 Thread Christopher Done
Hey, Quick question: Does GHC have an upper limit on the length of binding names? Cheers! ___ ghc-devs mailing list ghc-devs@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs

Re: GHC (API?) question: GHC Core for Base libraries

2018-12-19 Thread Christopher Done
Here is the simplest possible way to print core in the Main.hs, by the way: https://github.com/chrisdone/prana/commit/1303c7bb385a95eef7bb4752997897455853ca72#diff-28e5b5a88ae58fa953c1ad5ab5a7bfe0 That's taking GHC 8.0's Main.hs and patching it. On Wed, 19 Dec 2018 at 10:50, Christ

Re: GHC (API?) question: GHC Core for Base libraries

2018-12-19 Thread Christopher Done
Hi Bill, I use a different approach, using docker, and that's to use a patched `Main.hs` (https://github.com/chrisdone/prana/commits/master/ghc-8.0/Main.hs) and compile GHC with that patched file. It's a little unorthodox but has so far been highly effective. Here is a repo of a core interpreter

Re: How to use Data.Compact.Serialize

2018-12-19 Thread Christopher Done
I forgot to address the fact that libc never statically links things like name server libraries. Therefore would GHC devs recommend using a musl-based build e.g. on Alpine Linux? Cheers On Wed, 19 Dec 2018 at 10:31, Christopher Done wrote: > > Hi, > > On the docs for Data.Compact.

How to use Data.Compact.Serialize

2018-12-19 Thread Christopher Done
Hi, On the docs for Data.Compact.Serialize it says: http://hackage.haskell.org/package/compact-0.1.0.1/docs/Data-Compact-Serialize.html > Our binary representation contains direct pointers to the info tables > of objects in the region. This means that the info tables of the > receiving process mu

Re: Writing a simple Core evaluator, having trouble with name lookups

2018-12-01 Thread Christopher Done
+ unique (what is unique per invocation) > > It is safe because only the exported names can appear in an external > expression and those do not contain the GHC's unique value. > Just think about how the object code linker deals with GHC symbols. > > Cheers, > Csaba > >

Re: Writing a simple Core evaluator, having trouble with name lookups

2018-12-01 Thread Christopher Done
I think what Csaba means is that we can have e.g. * GHC invocation 1 * ghc-prim: * MyModule.foo has Unique 123 * OtherModule.bar has Unique 124 * GHC invocation 2 * base: * MyMod.mu has Unique 123 * OtherMod.zot has Unique 124 For a unique reference then, we just need: * ghc-

Re: Writing a simple Core evaluator, having trouble with name lookups

2018-11-30 Thread Christopher Done
Hi Csaba, Thanks for your answer. I think I'm doing something very similar to you. I'm converting the GHC AST to my own AST with this code: https://gist.github.com/chrisdone/96e228f12bdbc3c43d06718467e69029#file-main-hs-L815--L915 I have an Id type that's similar to yours, data Id = Id

Writing a simple Core evaluator, having trouble with name lookups

2018-11-27 Thread Christopher Done
Hi all, I'm attempting to make a simple evaluator for GHC core, but I'm not clear on how to reliably looking up names. I'm compiling each of ghc-prim, integer-simple and base with a patched version of GHC which performs an extra output step with the Core AST to a file for each module. Later, I lo

Re: How do you build base with your own compiler?

2018-06-28 Thread Christopher Done
esome. I'd much prefer that over the whole compiling GHC rigmarole. Ciao! On Thu, 28 Jun 2018 at 18:35, Herbert Valerio Riedel wrote: > > Note that `base` is mostly a normal cabal package and you can easily > build it with `cabal new-build` if that's any help. > On Thu, Jun

How do you build base with your own compiler?

2018-06-28 Thread Christopher Done
I've built the GHC compiler along with libraries/base in the canonical way. Now, I want to compile base with my own compiler frontend which will do some analysis. Here's what I've done so far: 1) I've compiled my frontend with the ghc-stage2 compiler and registered it. That works. 2) I've found t

Re: Tracking down instances from use-sites

2018-06-26 Thread Christopher Done
Ben, Thanks for the in-depth elaboration of what Mathew/Simon were describing! It seems within reach! > Of course, in the case that you have a concrete dictionary you *also* > want to know the source location of the instance declaration from which > it arose. I'm afraid this may be quite challeng

Re: Tracking down instances from use-sites

2018-06-26 Thread Christopher Done
typechecked program using the > `-ddump-tc-ast` flag. > > Finally, you should considering writing this as a source plugin rather > than using the GHC API as it will be easier to run in a variety of > different scenarios. > > Cheers, > > Matt > > On Tue, Jun 26, 2018

Tracking down instances from use-sites

2018-06-26 Thread Christopher Done
Hi all, Given a TypecheckedModule, what's the most direct way given a Var expression retrieved from the AST, to determine: 1) that it's a class method e.g. `read` 2) that it's a generic call (no instance chosen) e.g. `Read a => a -> String` 3) or if it's a resolved instance, then which instance i

Re: GHC typecheck API

2017-12-01 Thread Christopher Done
clear whether the report is to do with > compile time or runtime. > > > > If you can boil down a test case, maybe a ticket would be good > > > > *From:* Christopher Done [mailto:chrisd...@gmail.com] > *Sent:* 01 December 2017 12:01 > *To:* Németh Boldizsár > *Cc:

Re: GHC typecheck API

2017-12-01 Thread Christopher Done
> > Boldizsár > > 2017.12.01. 4:12 keltezéssel, Christopher Done írta: > > I suppose setting -fdefer-type-errors would also be handy in this scenario! > > On Thu, 30 Nov 2017 at 15:37, Simon Peyton Jones via ghc-devs < > ghc-devs@haskell.org> wrote: > >> This sound

Re: GHC Core simplifier question: turn off all passes?

2017-04-07 Thread Christopher Done
Thanks all, I'll try looking at the innards of the desugarer! On 7 April 2017 at 15:24, Christopher Done wrote: > Indeed, it seems that even with -ddump-ds that there's a replacement > of immediatelly-applied-lambdas ((\x->x) a => a). > > I'm using the GHC AP

Re: GHC Core simplifier question: turn off all passes?

2017-04-07 Thread Christopher Done
hris, > > I think you're looking for -ddump-ds which outputs the Core just after the > desugarer is done. -ddump-simpl gives the Core after the simplifier is run. > > Hope that helps, > Rahul > > On Fri, Apr 7, 2017 at 6:25 PM, Christopher Done > wrote: >> >&g

GHC Core simplifier question: turn off all passes?

2017-04-07 Thread Christopher Done
Hi all, Just checking, if I want to see the Haskell code desugared to core BEFORE any simplification passes, is this the way to do it? bash-3.2$ cat > X.hs module X where it = (\x -> x * 2) 123 bash-3.2$ stack exec -- ghc -ddump-simpl X.hs -fforce-recomp -fmax-simplifier-iterations=0 -O0 [1 of 1]

Re: Disable messages with GHC API

2017-02-03 Thread Christopher Done
> On Fri, Feb 3, 2017 at 12:21 PM, Christopher Done wrote: >> In Intero, after loading modules, for each one I run the following >> function: >> https://github.com/commercialhaskell/intero/blob/300ac5a/src/GhciInfo.hs#L75..L85 >> >> If there are warnings or any outpu

Disable messages with GHC API

2017-02-03 Thread Christopher Done
In Intero, after loading modules, for each one I run the following function: https://github.com/commercialhaskell/intero/blob/300ac5a/src/GhciInfo.hs#L75..L85 If there are warnings or any output, they get outputted. As they are already outputted by regular :load, I don’t need the same output twic

Re: Competing with C in a simple loop

2016-12-23 Thread Christopher Done
ote: > > On 23 December 2016 at 03:23, Christopher Done > wrote: >> >> But if you scroll down the README to the 182kb file example, you see that >> hexml takes 33us and xeno takes 111us. That's surprising to me because I'm >> doing just a walk across a st

Competing with C in a simple loop

2016-12-22 Thread Christopher Done
Purely as an experiment, I've written a function that uses ByteString to simply elemIndex it's way across a string here. Look for <, then look for >. Repeat until done. https://github.com/chrisdone/xeno (under src/Xeno.hs) But if you scroll down the README to the 182kb file example, you see that

Re: How to best display type variables with the same name

2016-10-27 Thread Christopher Done
On 19 October 2016 at 13:48, Richard Eisenberg wrote: > Interesting problem & solution. > > Here's a wacky idea, from a position of utter ignorance about your > environment: could you use color? Already, when I saw `b :: a` in the > commentary there, where `b` is in scope as a type variable, it se

Re: How to best display type variables with the same name

2016-10-27 Thread Christopher Done
On 26 October 2016 at 11:43, Simon Peyton Jones wrote: > As far as I understand it: > > · You are plucking a type from the midst of a syntax tree, and > displaying it. > > · That type might well mention type variables that are bound > “further out” > > o either by a forall (if th

Re: How to best display type variables with the same name

2016-10-21 Thread Christopher Done
On 19 October 2016 at 17:00, Simon Peyton Jones simo...@microsoft.com wrote: I’m afraid I didn’t understand the issue in the link below. It speaks of “querying the type”, but I’m not sure what that means. A GHCi session perhaps? Does this relate to the way GHC

How to best display type variables with the same name

2016-10-19 Thread Christopher Done
We've encountered a problem in Intero which is that when inspecting types of expressions and patterns, sometimes it happens that the type, when pretty printing, yields variables of the same name but which have different provenance. Here's a summary of the issue: https://github.com/commercialhaske

Re: Using the GHC API to write an interpreter

2016-06-28 Thread Christopher Done
Thanks! It's strange to think there was once no GHCi. This is an interesting piece of Haskell implementation history! =) On 27 June 2016 at 15:27, Simon Marlow wrote: > > > On 27 June 2016 at 13:31, Christopher Done wrote: > >> On 27 June 2016 at 10:01, Simon Marlow

Re: Using the GHC API to write an interpreter

2016-06-27 Thread Christopher Done
On 27 June 2016 at 10:01, Simon Marlow wrote: > On 26 June 2016 at 11:28, Christopher Done wrote: >> >> I've been pondering how feasible it would be to: >> >> * Compile in stages a module with the byte code linker >> * Keep hold of the Core source >

Re: Using the GHC API to write an interpreter

2016-06-27 Thread Christopher Done
On 27 June 2016 at 04:11, Edward Z. Yang wrote: > I don't understand what the bytecode format has to do here. Since > your suggestion is to just store Core you can just compile to object > code. True, I could compile to either as long as I can link it dynamically. > > Any input into this? How fa

Using the GHC API to write an interpreter

2016-06-26 Thread Christopher Done
I've been pondering how feasible it would be to: * Compile in stages a module with the byte code linker * Keep hold of the Core source * Interpret the Core AST within Haskell * When encountering built-in/primitives (or things from other libraries), we compile that Core term and link it as an HValu

Re: wither the Platform

2015-03-23 Thread Christopher Done
I suppose ironically the page does a good job of representing community opinion; i.e. there is still debate on this issue. Even though ideally the vision was for the site to be as clear as possible, I saw no uncontentious choice here. ___ ghc-devs mailing

Re: wither the Platform

2015-03-23 Thread Christopher Done
On 23 March 2015 at 15:01, Mark Lentczner wrote: > On Mon, Mar 23, 2015 at 3:01 AM, Simon Peyton Jones wrote: > > Like Richard, I was astonished by this. I always thought that the > > Haskell Platform was the route of choice to install GHC, together > > with a respectable set of libraries. It’s

Re: GHC support for the new "record" package

2015-01-28 Thread Christopher Done
> The latter {| ... |} might serve as a solid syntax suggestion for the > anonymous row type syntax. I like this well enough. My Hugs TRex suggestion comes from not particularly caring much what characters are used to delimit some fields, but that using an existing implementation's design decisio

Re: GHC support for the new "record" package

2015-01-28 Thread Christopher Done
On 29 January 2015 at 00:40, Edward Kmett ekm...@gmail.com wrote: There is a problem with the old TRex syntax. In a world with kind signatures and rank-2 types, it would appear that type Point2D = Rec ( x :: Coord, y :: Coord ) is ambiguous. The kind-signature resemblance had occurred to me, b

Re: GHC support for the new "record" package

2015-01-28 Thread Christopher Done
There’s too much to absorb in this discussion at the moment and I’m late to the party anyway, but I would like to make a small note on syntax. Given that this is very similar to TRex both in behaviour and syntactic means of construction, why not just take TRex’s actual syntax? http://en.wikipedia.o

Re: Making GHCi awesomer?

2014-10-18 Thread Christopher Done
On 18 October 2014 22:36, Herbert Valerio Riedel wrote: Yeah, it's quite convenient to hack on GHCi that way as it's just an > ordinary Cabal package (so it doesn't require to setup a GHC source-tree > and wrangle with the GHC build-system), if you're lucky enough (which is > most of the time) th

Re: Making GHCi awesomer?

2014-10-18 Thread Christopher Done
On 18 October 2014 19:28, Daniel Gröber wrote: > Do you have any examples of such projects, I've never seen any > complaints about ghc-mod doing this. > I haven't used ghc-mod enough to have a crash happen to me. I couldn't get it to work the times I'd tried it and others make this complaint. Wh

Re: Making GHCi awesomer?

2014-10-18 Thread Christopher Done
On 18 October 2014 19:05, Mateusz Kowalczyk wrote: > Sounds interesting. My only request/comment is that I hope whatever > conclusion you come to, the library part of it will be usable just as > much (or even more) as the executable: if we can talk to the library > natively then that's much easie

Making GHCi awesomer?

2014-10-18 Thread Christopher Done
Good evening, So I’ve been working on Haskell user-facing tooling in general for some years. By that I mean the level of Emacs talking with Haskell tools. I wrote the interactive-haskell-mode (most functionality exists in this file