Re: default roles

2013-10-08 Thread José Pedro Magalhães
Hi,

On Tue, Oct 8, 2013 at 3:21 AM, Richard Eisenberg e...@cis.upenn.edu wrote:

 We considered this for a while, but it led to a strange design -- to do it
 right, you would have to import all constructors for all datatypes
 *recursively* out to the leaves, starting at the datatypes mentioned in the
 class for which you wanted to use GND. This would mean potentially a whole
 lot of imports for symbols not actually used in the text of a program.


I'm not sure I understand why constructors are involved in this. Wouldn't
something like
the following potentially be useful?

data Role = Nominal | Representational | Phantom | Fun Role Role

type family HasRole (t :: k) :: Role

data MyData a b = MyData a
data MyGADT a b where MyGADT :: MyGADT a Int

type instance HasRole MyData  = Fun Representational Phantom
type instance HasRole MyGADT  = Fun Representational Nominal
type instance HasRole Traversable = Nominal

HasRole instances would be automatically given by GHC.


Cheers,
Pedro
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: ghc src snapshots

2013-10-08 Thread Jens Petersen
I built 
http://petersen.fedorapeople.org/ghc/ghc-7.7.20131005-src.tar.bz2http://petersen.fedorapeople.org/ghc/
for Fedora (http://koji.fedoraproject.org/koji/taskinfo?taskID=6034005)
and uploaded the builds for x86_64, i686 and armv7hl to my fedorapeople
repo:

  http://repos.fedorapeople.org/repos/petersen/ghc-7.7

Initial basic testing suggests it works okay, but let me
know if you notice any Fedora specific problems.

Jens
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: default roles

2013-10-08 Thread Richard Eisenberg
Pedro is suggesting a way for a Haskell type-level program to gain access to 
role information. This might indeed be useful, but it doesn't seem terribly 
related to the problem of defaults / abstraction. The problem has to do with 
definitions like these:

 module A where
 data S a b = S1 a | S2 b
 data T a b = MkT (S a b)

 module B where
 import A ( {- what goes here? -} )

 class C a where
   mkT :: T Bool a

 instance C Int where ...
 newtype Age = MkAge Int deriving C

What constructors do we need in order to convert the (C Int) instance to (C 
Age) by hand? To me, it looks like we need MkT and S2, but not S1. Yet, this is 
not obvious and seems to be quite confusing.

I hope this helps understanding the issue!
Richard

On Oct 8, 2013, at 4:01 AM, José Pedro Magalhães drei...@gmail.com wrote:

 Hi,
 
 On Tue, Oct 8, 2013 at 3:21 AM, Richard Eisenberg e...@cis.upenn.edu wrote:
 We considered this for a while, but it led to a strange design -- to do it 
 right, you would have to import all constructors for all datatypes 
 *recursively* out to the leaves, starting at the datatypes mentioned in the 
 class for which you wanted to use GND. This would mean potentially a whole 
 lot of imports for symbols not actually used in the text of a program.
 
 I'm not sure I understand why constructors are involved in this. Wouldn't 
 something like
 the following potentially be useful?
 
 data Role = Nominal | Representational | Phantom | Fun Role Role
 
 type family HasRole (t :: k) :: Role
 
 data MyData a b = MyData a
 data MyGADT a b where MyGADT :: MyGADT a Int
 
 type instance HasRole MyData  = Fun Representational Phantom
 type instance HasRole MyGADT  = Fun Representational Nominal
 type instance HasRole Traversable = Nominal
 
 HasRole instances would be automatically given by GHC.
 
 
 Cheers,
 Pedro
 
 

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: default roles

2013-10-08 Thread Miguel
I don't understand it either.

Type family solution, however, seems wrong. See, if we, somehow, make
something nominal when it has to be representational — well, some code
won't compile, but nothing really bad happens. If, on the other hand, we by
some miracle make something representational when in should be nominal — we
can get a runtime error. It seems to be very similar to how type classes
work, with nominal being the default, and representational a type class.

Consider, for example, the Tricky example from the slides, slightly
changed:

data Tricky2 a b c = MkTricky2 (a c) (b c)

Currently parameter c would be nominal. I suggest that it should be
representational if and only if it's representational for BOTH a and b.
WIth type classes it would be very simple:

instance (HasRepresentationalParameter a, HasRepresentationalParameter b)
= HasRepresentationalParameter (Tricky2 a b)

With type families... well, apparently I don't have enough milliolegs to
figure out how to do it.


On Tue, Oct 8, 2013 at 12:01 PM, José Pedro Magalhães drei...@gmail.comwrote:

 Hi,

 On Tue, Oct 8, 2013 at 3:21 AM, Richard Eisenberg e...@cis.upenn.eduwrote:

 We considered this for a while, but it led to a strange design -- to do
 it right, you would have to import all constructors for all datatypes
 *recursively* out to the leaves, starting at the datatypes mentioned in the
 class for which you wanted to use GND. This would mean potentially a whole
 lot of imports for symbols not actually used in the text of a program.


 I'm not sure I understand why constructors are involved in this. Wouldn't
 something like
 the following potentially be useful?

 data Role = Nominal | Representational | Phantom | Fun Role Role

 type family HasRole (t :: k) :: Role

 data MyData a b = MyData a
 data MyGADT a b where MyGADT :: MyGADT a Int

 type instance HasRole MyData  = Fun Representational Phantom
 type instance HasRole MyGADT  = Fun Representational Nominal
 type instance HasRole Traversable = Nominal

 HasRole instances would be automatically given by GHC.


 Cheers,
 Pedro



 ___
 Glasgow-haskell-users mailing list
 Glasgow-haskell-users@haskell.org
 http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: default roles

2013-10-08 Thread Richard Eisenberg
Perhaps I can spot the source of the confusion: there seem to be 2 different 
conversations going on here!

1: How to fit roles in with the ability to declare a datatype to be abstract. 
Should a library author be required to use a role annotation to make an 
abstract datatype, or should a library author be required to use a role 
annotation to allow GND with a datatype?

2: Some form of role abstraction, where an argument to a type parameter might 
get a representational role, depending on the role of some other variable. 
Using typeclasses is the current proposal for how to do this, and it in 
migmit's email below. Pedro also suggests a type families approach.


My initial email was seeking advice on issue #1.

As for #2: Using typeclasses here might be a decent surface syntax for the 
feature of role abstraction, but the automatic generation of instances, etc., 
would seem to require deep and pervasive magic under the hood. Essentially, 
every type and type variable would need to be annotated with both a kind and a 
role, significantly complicating GHC's type system. The question would be 
whether or not this upfront and ongoing investment is worth it.

Thanks,
Richard

On Oct 8, 2013, at 10:49 AM, Miguel mig...@gmail.com wrote:

 I don't understand it either.
 
 Type family solution, however, seems wrong. See, if we, somehow, make 
 something nominal when it has to be representational — well, some code won't 
 compile, but nothing really bad happens. If, on the other hand, we by some 
 miracle make something representational when in should be nominal — we can 
 get a runtime error. It seems to be very similar to how type classes work, 
 with nominal being the default, and representational a type class.
 
 Consider, for example, the Tricky example from the slides, slightly changed:
 
 data Tricky2 a b c = MkTricky2 (a c) (b c)
 
 Currently parameter c would be nominal. I suggest that it should be 
 representational if and only if it's representational for BOTH a and b. WIth 
 type classes it would be very simple:
 
 instance (HasRepresentationalParameter a, HasRepresentationalParameter b) = 
 HasRepresentationalParameter (Tricky2 a b)
 
 With type families... well, apparently I don't have enough milliolegs to 
 figure out how to do it.
 
 
 On Tue, Oct 8, 2013 at 12:01 PM, José Pedro Magalhães drei...@gmail.com 
 wrote:
 Hi,
 
 On Tue, Oct 8, 2013 at 3:21 AM, Richard Eisenberg e...@cis.upenn.edu wrote:
 We considered this for a while, but it led to a strange design -- to do it 
 right, you would have to import all constructors for all datatypes 
 *recursively* out to the leaves, starting at the datatypes mentioned in the 
 class for which you wanted to use GND. This would mean potentially a whole 
 lot of imports for symbols not actually used in the text of a program.
 
 I'm not sure I understand why constructors are involved in this. Wouldn't 
 something like
 the following potentially be useful?
 
 data Role = Nominal | Representational | Phantom | Fun Role Role
 
 type family HasRole (t :: k) :: Role
 
 data MyData a b = MyData a
 data MyGADT a b where MyGADT :: MyGADT a Int
 
 type instance HasRole MyData  = Fun Representational Phantom
 type instance HasRole MyGADT  = Fun Representational Nominal
 type instance HasRole Traversable = Nominal
 
 HasRole instances would be automatically given by GHC.
 
 
 Cheers,
 Pedro
 
 
 
 ___
 Glasgow-haskell-users mailing list
 Glasgow-haskell-users@haskell.org
 http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
 
 

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


RTS option -A affecting cpu-core usage?

2013-10-08 Thread Daniel Trstenjak

Hi all,

I played around with a parallel algorithm and tried to get the GC time
down by specifying the RTS option '-A'.

But if I'm specifying '-A' than also the usage of the cpu-cores seems to
change. Without '-A' I'm getting a total cpu-core usage of '4.44s',
with '-A' I'm getting only '1.67s'.

Any ideas?


Greetings,
Daniel


Without '-A':
-

dan@machine ~ ghc-mod-dev find showWindows +RTS -s -N4
XMonad.Util.XUtils
 980,770,296 bytes allocated in the heap
 552,122,168 bytes copied during GC
 163,683,152 bytes maximum residency (11 sample(s))
   4,369,800 bytes maximum slop
 280 MB total memory in use (0 MB lost due to fragmentation)

Tot time (elapsed)  Avg pause  Max pause
  Gen  0  1690 colls,  1690 par2.45s0.66s 0.0004s0.0024s
  Gen  111 colls,10 par0.98s0.26s 0.0239s0.1022s

  Parallel GC work balance: 18.06% (serial 0%, perfect 100%)

  TASKS: 6 (1 bound, 5 peak workers (5 total), using -N4)

  SPARKS: 1025 (0 converted, 0 overflowed, 0 dud, 0 GC'd, 1025 fizzled)

  INITtime0.00s  (  0.00s elapsed)
  MUT time0.99s  (  0.83s elapsed)
  GC  time3.43s  (  0.93s elapsed)
  EXITtime0.02s  (  0.02s elapsed)
  Total   time4.44s  (  1.78s elapsed)

  Alloc rate995,571,064 bytes per MUT second

  Productivity  22.7% of total user, 56.5% of total elapsed

gc_alloc_block_sync: 53552
whitehole_spin: 0
gen[0].sync: 75
gen[1].sync: 23678


With '-A':
--

dan@machine ~ ghc-mod-dev find showWindows +RTS -s -N4 -A500m
XMonad.Util.XUtils
 979,761,872 bytes allocated in the heap
  94,043,424 bytes copied during GC
 118,609,784 bytes maximum residency (2 sample(s))
   2,844,808 bytes maximum slop
2196 MB total memory in use (0 MB lost due to fragmentati

Tot time (elapsed)  Avg pause  Ma
  Gen  0 0 colls, 0 par0.00s0.00s 0.s
  Gen  1 2 colls, 1 par0.47s0.18s 0.0878s

  Parallel GC work balance: 57.02% (serial 0%, perfect 100%)

  TASKS: 6 (1 bound, 5 peak workers (5 total), using -N4)

  SPARKS: 1025 (616 converted, 0 overflowed, 0 dud, 0 GC'd, 409 fizzl

  INITtime0.02s  (  0.02s elapsed)
  MUT time1.16s  (  1.16s elapsed)
  GC  time0.47s  (  0.18s elapsed)
  EXITtime0.02s  (  0.02s elapsed)
  Total   time1.67s  (  1.38s elapsed)

  Alloc rate844,914,346 bytes per MUT second

  Productivity  70.8% of total user, 85.9% of total elapsed

gc_alloc_block_sync: 33458
whitehole_spin: 0
gen[0].sync: 5372
gen[1].sync: 0
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: RTS option -A affecting cpu-core usage?

2013-10-08 Thread Daniel Trstenjak

Ok, I think I got it. The cpu-cores are spending most of their time
doing GC, by reducing the GC time the cpu-cores don't have anything
left to do.

Seems like a really great parallel algorithm ;).


Greetings,
Daniel
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users