Injective type families?

2011-02-14 Thread Conal Elliott
Is there a way to declare a type family to be injective? I have > data Z > data S n > type family n :+: m > type instance Z :+: m = m > type instance S n :+: m = S (n :+: m) My intent is that (:+:) really is injective in each argument (holding the other as fixed), but I don't know how to pers

Re: Injective type families?

2011-02-14 Thread John Meacham
Isn't this what data families (as opposed to type families) do? John On Mon, Feb 14, 2011 at 1:28 PM, Conal Elliott wrote: > Is there a way to declare a type family to be injective? > > I have > >> data Z >> data S n > >> type family n :+: m >> type instance Z   :+: m = m >> type instance S

Re: Injective type families?

2011-02-14 Thread Conal Elliott
Yes, it's one things that data families do. Another is introducing *new* data types rather than reusing existing ones. - Conal On Mon, Feb 14, 2011 at 1:41 PM, John Meacham wrote: > Isn't this what data families (as opposed to type families) do? > >John > > On Mon, Feb 14, 2011 at 1:28 PM, C

Re: Injective type families?

2011-02-14 Thread Daniel Peebles
I think what you want is closed type families, as do I and many others :) Unfortunately we don't have those. On Mon, Feb 14, 2011 at 10:02 PM, Conal Elliott wrote: > Yes, it's one things that data families do. Another is introducing *new* > data types rather than reusing existing ones. - Conal >

Re: Injective type families?

2011-02-14 Thread Dan Doel
On Monday 14 February 2011 5:51:55 PM Daniel Peebles wrote: > I think what you want is closed type families, as do I and many others :) > Unfortunately we don't have those. Closed type families wouldn't necessarily be injective, either. What he wants is the facility to prove (or assert) to the co

RE: Injective type families?

2011-02-14 Thread Simon Peyton-Jones
Injective type families are a perfectly reasonable idea, but we have not implemented them (yet). The idea would be: * You declare the family to be injective injective type family T a :: * * At every type instance, injectivity is checked. That is, if you say type instance T (a,Int) = Either a

Re: Injective type families?

2011-02-14 Thread Sebastian Fischer
> > On Mon, Feb 14, 2011 at 1:41 PM, John Meacham wrote: > >> Isn't this what data families (as opposed to type families) do? > > On Tue, Feb 15, 2011 at 7:02 AM, Conal Elliott wrote: > Yes, it's one things that data families do. Another is introducing *new* > data types rather than reusing exis

Re: Injective type families?

2011-02-15 Thread Iavor Diatchki
u have a use case for type nats, I'd be curious to find out more. On Mon, Feb 14, 2011 at 3:26 PM, Simon Peyton-Jones wrote: > Injective type families are a perfectly reasonable idea, but we have not > implemented them (yet). The idea would be: > > * You declare the family to

RE: Injective type families?

2011-02-15 Thread Simon Peyton-Jones
shouldn't the check go the other way? (i.e., if the RHSs unify, then the LHS must be the same). Here is an example: -- This function is not injective. type instance F a = Int type instance F b = Int Yes, you’re right. Still, Conal's example would not work if we just added support for injectiv

Re: Injective type families?

2011-02-16 Thread Roman Leshchinskiy
On 14/02/2011, at 21:28, Conal Elliott wrote: > Is there a way to declare a type family to be injective? > > I have > > > data Z > > data S n > > > type family n :+: m > > type instance Z :+: m = m > > type instance S n :+: m = S (n :+: m) You could prove it :-) class Nat n where induct :

Injective type families for GHC

2015-02-09 Thread Jan Stolarek
Haskellers, I am finishing work on adding injective type families to GHC. I know that in the past many people have asked for this feature. If you have use cases for injective type families I would appreciate if you could show them to me. My implementation has some restrictions and I want to

Trouble with injective type families

2017-07-04 Thread Wolfgang Jeltsch
Hi! Injective type families as supported by GHC 8.0.1 do not behave like I would expect them to behave from my intuitive understanding. Let us consider the following example: > {-# LANGUAGE RankNTypes, TypeFamilyDependencies #-} > > class C a where > > type T a = b | b -&g

RE: Trouble with injective type families

2017-07-04 Thread Simon Peyton Jones via Glasgow-haskell-users
C, GHC's core language, to do so. Simon | -Original Message- | From: Glasgow-haskell-users [mailto:glasgow-haskell-users- | boun...@haskell.org] On Behalf Of Wolfgang Jeltsch | Sent: 05 July 2017 01:21 | To: glasgow-haskell-users@haskell.org | Subject: Trouble with injective ty

Re: Trouble with injective type families

2017-07-05 Thread Wolfgang Jeltsch
t you'd need to extend System FC, GHC's core language, to > do so. > > Simon > > > > > > -Original Message- > > From: Glasgow-haskell-users [mailto:glasgow-haskell-users- > > boun...@haskell.org] On Behalf Of Wolfgang Jeltsch > > Sent

Re: Trouble with injective type families

2017-07-05 Thread Richard Eisenberg
T Int ~ b). False |> ?? >> >> Again, what evidence can we use to cast False to 'a'. >> >> >> In short, fundeps and type family dependencies only add extra >> unification constraints, which may help to resolve ambiguous >> types. They don’t provide evidenc

Re: Trouble with injective type families

2017-07-06 Thread Anthony Clayden
;> types. They don’t provide evidence. That's not to say that they >> couldn't. But you'd need to extend System FC, GHC's core language, to >> do so. >> >> Simon >> >> >>> >>> -Original Message- &

Re: Trouble with injective type families

2017-07-15 Thread gkaracha
n the draft), if we treat them as type-level functions. Hence, we had to tighten up the restrictions imposed on them, good thing that until now they didn't affect the generated System FC code! There is still some work to be done to transfer the results to injective type families but I believ

Re: [Haskell-cafe] Injective type families for GHC

2015-02-09 Thread adam vogt
[(),()]) => Proxy y Prints desired :: Proxy '[y, y1] current :: HLength y ~ 'HSucc ('HSucc 'HZero) => Proxy y Regards, Adam On Mon, Feb 9, 2015 at 10:58 AM, Jan Stolarek wrote: > Haskellers, > > I am finishing work on adding injective type families to GHC. I know

Re: [Haskell-cafe] Injective type families for GHC

2015-02-10 Thread Jan Stolarek
Thank you Adam. > One example is https://github.com/haskell/vector/issues/34 Yes, this looks like an example where injectivity will work. One question here: how does one build vector with GHC HEAD? I tried but failed because of dependencies. > I see lots of potential uses in HList. For example

Re: [Haskell-cafe] Injective type families for GHC

2015-02-10 Thread adam vogt
On Tue, Feb 10, 2015 at 6:38 AM, Jan Stolarek wrote: >> I don't know how realistic this is but a constraint (HLength x ~ >> HLength y) would ideally have the same result as SameLength x y. > I'm not sure if I understand that part. HLength is not injective. How would > injectivity help here? I ag

ghc-7.10.0 type inference regression when faking injective type families

2015-01-19 Thread adam vogt
Hello List, With ghc - 7.8 and 7.6 the following program is accepted: {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeFamilies #-} class (UnF (F a) ~ a, Show a) => C a where type F a f :: F a -> a type family UnF a g :: forall a. C a => a -> String g _ = show a where a = f (und

Re: ghc-7.10.0 type inference regression when faking injective type families

2015-01-20 Thread Richard Eisenberg
After quite a bit of thought, I agree that this is a regression and that the original program should be accepted. Make a bug report! Thanks, Richard ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman

Re: ghc-7.10.0 type inference regression when faking injective type families

2015-01-20 Thread adam vogt
I've added it as https://ghc.haskell.org/trac/ghc/ticket/10009 On Tue, Jan 20, 2015 at 11:23 AM, Richard Eisenberg wrote: > After quite a bit of thought, I agree that this is a regression and that the > original program should be accepted. > > Make a bug report! > > Thanks, > Richard ___

Re: ghc-7.10.0 type inference regression when faking injective type families

2015-01-20 Thread David Feuer
And I've closed it as worksforme. I couldn't reproduce the problem with 7.11.20150103. On Tue, Jan 20, 2015 at 11:42 AM, adam vogt wrote: > I've added it as https://ghc.haskell.org/trac/ghc/ticket/10009 > > On Tue, Jan 20, 2015 at 11:23 AM, Richard Eisenberg > wrote: >> After quite a bit of tho

Re: ghc-7.10.0 type inference regression when faking injective type families

2015-01-20 Thread David Feuer
Wrongly, as it turned out. Sorry! The problem remains. On Tue, Jan 20, 2015 at 2:37 PM, David Feuer wrote: > And I've closed it as worksforme. I couldn't reproduce the problem > with 7.11.20150103. > > On Tue, Jan 20, 2015 at 11:42 AM, adam vogt wrote: >> I've added it as https://ghc.haskell.org

RE: ghc-7.10.0 type inference regression when faking injective type families

2015-01-20 Thread Simon Peyton Jones
| To: adam vogt | Cc: Glasgow-Haskell-Users | Subject: Re: ghc-7.10.0 type inference regression when faking injective | type families | | After quite a bit of thought, I agree that this is a regression and that | the original program should be accepted. | | Make a bug report! | | Thanks