Re: [Haskell-cafe] Newclasses

2013-10-05 Thread Wvv
Stijn van Drongelen wrote
 On Fri, Oct 4, 2013 at 10:31 PM, Wvv lt;

 vitea3v@

 gt; wrote:
 About newclass and compose data, we can do next:

newclass Foo [a] = FooList a where {containerMainipulation=...}

newclass Foo (Set a) = FooSet a where {containerMainipulation=...}

newclass Foo (Sequence a) = FooSeq a where
 {containerMainipulation=...}

 so now I can switch any container of my data, changing only name of
 newclass:

   instance FooList MyData where {dataMainipulation=...}

 
 You can already solve that in Haskell 98:
 
 class Foo2 f where { containerManipulation = ... }
 instance Foo2 [] where { ... }
 instance Foo2 Set where { ... }
 instance Foo2 Sequence where { ... }
 
 class (Foo2 f) = Foo1 f a where { dataManipulation = ... }
 
 Or even:
 
 class Foo' a where { dataManipulation' = ... }
 dataManipulation = dataManipulation' yourDefaultContainerManipulation

Yes, I agree, use newclasses for composite data is an additional, secondary
feature. Haskell has huge infrastructure of data to use alternative ways
instead using newclasses this way.



Stijn van Drongelen wrote
 On Fri, Oct 4, 2013 at 10:31 PM, Wvv lt;

 vitea3v@

 gt; wrote:
 
 Let's see how many lines of code this costs in Haskell 98:
 
 instance Monad MyMonad where { ... }
 instance Functor MyMonad where
 fmap = liftM
 instance Applicative MyMonad where
 pure = return
 (*) = ap
 
 Only three lines more, and they're readable.

I see, we are looking to the same situation from different angles. I try to
show you why I think my point of view is important.
2 situations: first is more practical, second is more philosophical.

(1)  we have several libraries with lenses and lens-looking like libraries.
Why is the main popularity going to Kmett's library?
My answer: easy connection: just add one line  makeLens MyRecord''  and we
already could use all their abilities.
Why Kmett's library of JSON is so popular. Sure, it more quicker, but what
is the main reason?
My answer: easy connection.

Why Pipes, Streams, Conduit,  are not as super-popular as they could be?
They have very powerful abilities.
You need time not only for studying how this library works, but also how to
switch your data to library functions.

If you need to work with ... RMonad or MonadDatabase or something like this,
do you always know how to switch your data on?

(2) Let I have a lamp and I wish to switch it on. So, I say, I want to have
a plug. But you argue: this isn't necessary: you take 3 wires, green one you
contact here, blue one contact here, and finally, brown one contact there!
Easy!

Ok, now I wish to connect computer with iPhone. You say: take 12 wires ,
pins-scheme, 
But I want USB-30pin  cable.
Newclasses are those connectors-plugs and adapters.
Deriving are those plugs.
Generic instances and Data instances are those  plugs.

Newclasses are something like deriving, but much-much flexible and more
universal (sure, we can't replace deriving with newclasses).

If I have a Data which has an instance of Foo and I want to switch it to
class Bar, and I have 2 newclasses: Foo2Tmp and Tmp2Bar, I do the next:

   instance Foo2Tmp MyData 
   instance Tmp2Bar MyData

done!
or much simpler if I have Foo2Bar newclass:

  instance Foo2Bar MyData

I do not care  how easy or complex those instances I could write without
newclasses.
My aim is not to connect, but use abilities, which I take after connection.
And newclass is amazing tool for easy connection between classes.



--
View this message in context: 
http://haskell.1045720.n5.nabble.com/Newclasses-tp5737596p5737833.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Newclasses

2013-10-04 Thread Wvv
Newclasses are something like instances, but out of scope. In a baggage.
We don't use them for interfere their functions.
This why newclasses never overlap each other and between them and any
instances.
We use newclasses to plug-in/connect to any related class or combine data


Replying to you question, yes, instance of newclass desugar to instance of
class:

  instance BMonad MyBind where {return= ...}

desugar into 

  instance Monad MyBind where {return= ...; (=) = (-)}

We already have too many classes: look at
Edward Kmett
http://hackage.haskell.org/package/semigroupoids
13 dependent classes (from Foldable to MonadPlus)
http://hackage.haskell.org/package/category-extras
30-60 dependent class
http://hackage.haskell.org/package/lens
11 dependent classes

We can't divide all classes to atimic ones. 
I do not want to implement all depended class instances, even of atomic, if
I want to work with hight class only.
But I want easy connection with any related class! And newclasses solve this
situation.

Also in reality we have several realizations of same class/compose data and
we want to mix them for better realizations. Newclasses allows switch them
as engines! Easy.


Main purpose of newclasses is to make instances as minimal as possible. In
many cases empty.

About newclass and compose data, we can do next:

   newclass Foo [a] = FooList a where {containerMainipulation=...}

   newclass Foo (Set a) = FooSet a where {containerMainipulation=...}

   newclass Foo (Sequence a) = FooSeq a where {containerMainipulation=...}

so now I can switch any container of my data, changing only name of
newclass:

  instance FooList MyData where {dataMainipulation=...}


Or let I have an MyArrow data. And I need some semigroupoid manipulations.
I just write

  instance ArrSemigroupoid MyArrow --empty

that's all, I plug-in, let's just use semigroupoids functions!

Or I have MyMonad and I want some Functor, so I just plug-in:

  instance MFunctor MyMonad   --empty

that's all.
I also need some Applicative! Easy:

  instance MApplicative MyMonad   --empty again

done!


About conflicts, I don't understand a bit. Which ones? We catch Overlapped
instances or even Incoherent instances at once we add both newclass
instances of the same class.



John Lato-2 wrote
 I meant to say, does it mean that by
 writing a BMonad instance a Monad instance would be automatically
 generated?  If so, that seems like it would cause conflicts in many cases.
 Regardless, I think newclass needs to be better specified if you want
 other people to be able to support it.
 
 
 On Thu, Oct 3, 2013 at 7:53 PM, John Lato lt;

 jwlato@

 gt; wrote:
 
 I don't really understand what a newclass is supposed to be.


 On Thu, Oct 3, 2013 at 2:15 PM, Wvv lt;

 vitea3v@

 gt; wrote:


 newclass Bind a = Monad a = BMonad a where { (=) = (-) }


 I think this means that `BMonad` is supposed to be a new class that has
 both Bind and Monad in scope, the same as

   class (Bind a, Monad a) = BMonad a

 except that the Monad instance's (=) is replaced by (-).

 If that's what newclass means, it seems absolutely pointless.

 Does it instead mean that one could write

   instance Bind MyType where

   instance BMonad MyType

 
 ___
 Haskell-Cafe mailing list

 Haskell-Cafe@

 http://www.haskell.org/mailman/listinfo/haskell-cafe





--
View this message in context: 
http://haskell.1045720.n5.nabble.com/Newclasses-tp5737596p5737792.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Newclasses

2013-10-03 Thread Wvv
 Your first two cases will be fixed in 7.10, as Applicative finally becomes
a superclass of Monad.

Sure, newclassses not about Applicative and Monads only. 
This question is more wider.

Must Apply be a superclass of Bind?
Must Bind be a superclass of Monad?
So, must Monad has 2 superclasses at once: Bind and Applicative?

Must Semigroupoids be a superclass of Category?
Must Category be a superclass of Arrow?


With newclasses we could write empty instances to provide correct functional
dependencies:
   instance ArrCategory MyArrow
   instance CatSemigroupoids MyCategory

   instance MBind MyMonad
   instance MApply MyMonad
   instance MApplicative MyMonad
   instance MFunctor MyMonad

 Also, I don't see why it would be a misfeature to have Eq as a superclass
 of Ord, or Functor as a superclass of Applicative.
I see 2 reasons:
1) class functions in reality don't depend of superclass functions
2) Haskell can't check if superclass instance is correspond with class laws





--
View this message in context: 
http://haskell.1045720.n5.nabble.com/Newclasses-tp5737596p5737625.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Newclasses

2013-10-03 Thread Wvv
Yes, multi-class instances allow us write

type Monad a = (Applicative a, Bind a)

But at least 1 issue remains:

   Applicative :  pure; Monad: return
   Bind : (-); Monad: (=)
   With MultiClassInstances we could write only

   instance Monad MyMonad where { pure= ...; (-)= ...}
  
  But we don't want to break the existent code.
  Fortunately, an easy extension FunctionSynonyms could help us:
 
  type return = pure-- this allow us to use 'return' instead of 'pure'
in instances
  type (=) = (-)-- this allow us to use '(=)' instead of '(-)' in
instances
  
2) Still remains issue with several default instances, like 'Generic a =
ToJSON a' and 'Data a = ToJSON a', which we can't unite to 1 instance

3) If devs of library don't want to change the behavior, (for example divide
Monad to Applicative and Bind), but we still want easy connection to that
class, newclasses is our choice!
 
 Yes, this solution is good! Very nice! I like it!
 I should name it solution from derivatives. From bottom to top. We have
only independent classes and unite them with types.

 Newclasses solve same problem in integral way. From top to bottom. Instead
of having independent little classes, it allow to have big classes with
dependences, which are written in newclasses, and they allow to connect easy
to any dependent class.

newclass Bind a = Monad a = BMonad a where { (=) = (-) }
newclass Applicative a = Monad a = ApMonad a where { return = pure }
newclass (BMonad a, ApMonad a)  = BApMonad a   --empty

type ApBMonad = BApMonad

--then connect these classes:

instance Bind MyDataAB where { (-) = ...}
instance Applicative MyDataAB where { pure = ... ; (*) = ...}
instance ApBMonad MyDataAB   --empty

--or these
instance Monad MyDataM where {return= ... ; (=) = ...}
instance MBind MyDataM --empty
instance MApply MyDataM   --empty
instance MApplicative MyDataM--empty
instance MFunctor MyDataM--empty


If Haskell add MultiClassInstances + FunctionSynonyms, or Newclasses, or
both of them, Haskell would be the best language in nearest future!!!


About  the misfeature.
If class is independent of superclass functions and can't check dependence's
laws, why does it order to have instances of unnecessary class?


Stijn van Drongelen wrote
 On Thu, Oct 3, 2013 at 8:16 AM, Wvv lt;

 vitea3v@

 gt; wrote:
 
  Your first two cases will be fixed in 7.10, as Applicative finally
 becomes
 a superclass of Monad.

 Sure, newclassses not about Applicative and Monads only.
 This question is more wider.

 Must Apply be a superclass of Bind?
 Must Bind be a superclass of Monad?
 So, must Monad has 2 superclasses at once: Bind and Applicative?

 Must Semigroupoids be a superclass of Category?
 Must Category be a superclass of Arrow?
 
 
 There is no theoretical problem here, just a practical one. It would be
 resolved by solving your 4th problem, for which you don't need newclasses.
 Consider:
 
 {-# LANGUAGE ConstraintKinds #-}
 class Functor f where { fmap :: (a - b) - f a - f b }
 class Functor f = Apply f where { (*) :: f (a - b) - f a - f b }
 class Apply f = Applicative f where { pure :: a - f a }
 class Apply f = Bind f where { (=) :: (a - f b) - f a - f b }
 
 type Monad f = (Applicative f, Bind f)
 return :: Monad f = a - f a
 return = pure
 
 I might have made some mistakes in the exact hierarchy, but something like
 this should work. There are no problems with having hierarchies like this,
 as far as I'm aware.
 
 The current problem is that nobody wants to use this hierarchy: to get a
 Monad instance, you have to write four separate instances for your type.
 What would be nicer is a feature (ConstraintSynonymInstances?) where
 something like this can be written:
 
 instance (Functor Maybe, Apply Maybe, Monad Maybe) where
 fmap _ Nothing = Nothing
 fmap f (Just x) = Just (f x)
 
 Just f * Just x = Just (f x)
 _ * _ = Nothing
 
 pure = Just
 
 f = Just x = f x
 _ = Nothing = Nothing
 
 This would be sugar for
 
 instance Functor Maybe where { fmap = ... }
 instance Apply Maybe where { (*) = ... }
 instance Monad Maybe where { pure = ... ; (=) = ... }
 
 and the last would be sugar for
 
 instance Applicative Maybe where { pure = ... }
 instance Bind Maybe where { (=) = ... }
 
 You don't need any new keywords for this, because the above does not
 conflict with the existing rules for instance declarations.
 
   Also, I don't see why it would be a misfeature to have Eq as a
 superclass
  of Ord, or Functor as a superclass of Applicative.
 I see 2 reasons:
 1) class functions in reality don't depend of superclass functions
 2) Haskell can't check if superclass instance is correspond with class
 laws
 
 
 Again, I don't see why that makes it a misfeature.
 
 ___
 Haskell-Cafe mailing list

[Haskell-cafe] Newclasses

2013-10-02 Thread Wvv
Newclasses are not a new vision of classes!
Not at all!
Newclasses could elegant solve several instance problems!

1) we want to have partly applied instances, like Parent2Child: Parent a
= Child a
like 
instance Applicative m = Monad m where
return = pure
-- we won't define here (=)

2) we want to have superclass' instances, like Child2Parent: Child a =
Parent a
like
instance Monad m = Applicative m where
pure  = return
(*) = ap

3) we want to have default instances outside of class and as many as
possible, not the only one.
like
class Foo a where
foo :: ...
default foo :: ...
foo = ...

4) we want to have multi-class instances to separate (or unite) classes
like
type Stringy a = (Show a, Read a)
instance Stringy SomeData where
read = ...
show = ...


(4)th problem we could solve separately, but maybe it isn't easy enough to
do such de-sugaring, and it could much easier to add them in newclasses.
(3)rd problem is solved partly, but not in universal way, non-flexible and a
bit ugly.
(2)nd problem is solved, but it is mostly impossible to use them and it is
not recommend to use it for overlapping and incoherent issues.
(1)st problem is unsolved at all (partly, it is possible to make depended
classes, but checker don't check if we implement parent classes).

This is a compose proposal. Newclasses solve these problems at once!
As newtype is a data looking like a type, same newclass is looking like a
class, but is mostly an instance!
Mostly, but not full.

To best understanding what newclasses is, let's look at (1)st problem:

-- we wish to write 
-- instance Applicative m = Monad m where
--  return = pure

-- we write newclass instead of instance
-- add = and giving a name to newclass like a class
-- this is not instance, so newclass can't overlap with any instance
newclass (Applicative m) = Monad m = ApMonad m where
return = pure

data D a 
instance Applicative D where 
pure  = ...
(*) = ...

-- creating instances from newclass is intuitive
-- we implement here Monad class, not ApMonad; ApMonad is a just 
newclass
instance ApMonad D where 
-- we already have 'return = pure', so we define only (=)
(=) = ...

What do we see here?
Newclass looks like class, but it's mostly an instance!

Newclass:

Grammar:

  newclass constraint = Parent a = NewClassName a where ...

As class, newclass has a name, which is unique and can't conflict with any
other newclass or class names.
As class, methods of newclass could be empty or implemented.
As class, methods of newclass are not use in function inference.
As class we can make an instance of newclasses and overwrite any of his
functions!
But, instance of newclass IS an instance of the parent (!)class! So,
newclasses is like a de-sugaring.

As instance, newclass contains only parents methods!
On contrary to instancess, we don't use newclasse directly, it only help us
to create instances.

If we allow for newclass to be as Parent not only classes, but newclasses,
then newclass can't be recursive: neither of his (Grand)Parent could be he
by himself.
If we allow for newclass muliple Parents, we solve (4)th problem too.

Examples:
We have:

class Functor f where
fmap :: (a - b) - f a - f b

class Applicative f where -- without Functor f =, this is a 
misfeature
pure  :: a - f a
(*) :: f (a - b) - f a - f b
 
class Monad m where
return :: a - m a
(=)  :: m a - (a - m b) - m b

class Ord' a where -- without Eq a =, this is a misfeature
...
compare a b-- not as in Prelude
| a  b = LT
| a  b = GT
| otherwise = EQ


(1)st, Parent2Child:
Common pattern to write newclass like:

newclass Parent a = Child a = ParChild a where ...

Examples:

newclass (Applicative m) = Monad m = ApMonad m where
return = pure

data C1 a ...
instance Applicative C1 where
pure  = ...
(*) = ...

instance ApMonad C1 where
-- return is already defined
(=) = ...
--

newclass (Ord' a) = Eq a = OEq a where
a == b = case compare a b of
EQ - True
_  - False


data C2 ...
instance Ord' C2 where
() = ...

Re: [Haskell-cafe] Proposal: new function for lifting

2013-09-27 Thread Wvv
Which lift?
This one?

class MonadTrans t where
lift :: Monad m = m a - t m a



--
View this message in context: 
http://haskell.1045720.n5.nabble.com/Proposal-new-function-for-lifting-tp5737189p5737196.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Why superclass' instances are bad idea?

2013-09-26 Thread Wvv
Thanks a lot!
This makes clear. I haven't noticed before that OverlappingInstances don't
look at constraint!


John Lato-2 wrote
 This line
 
 instance Monad m = Applicative m where
 
 tells the compiler Every type (of the appropriate kind) is an instance of
 Applicative.  And it needs to have a Monad instance as well.
 
 That's what Edward means when he said that it means every Applicative is
 a
 Monad.  Theoretically the statement makes no sense, but that's what this
 instance head means.  Everything is Applicative, and it also needs a Monad
 instance to use that Applicative.
 
 Consider what happens for something that isn't a Monad, e.g. ZipList.
 Since it's not a Monad, it would need its own instance
 
 instance Applicative ZipList where
 ...
 
 But now you'd need to enable OverlappingInstances, because ZipList matches
 both this instance and the general one you've defined above (GHC doesn't
 consider constraints when matching instance heads).  OverlappingInstances
 is much more problematic than the other extensions because it could (and
 almost certainly would in this case) give rise to incoherence (see the
 warning under
 http://www.haskell.org/ghc/docs/latest/html/users_guide/type-class-extensions.html#instance-overlap
 ).

 
 ___
 Haskell-Cafe mailing list

 Haskell-Cafe@

 http://www.haskell.org/mailman/listinfo/haskell-cafe





--
View this message in context: 
http://haskell.1045720.n5.nabble.com/Why-superclass-instances-are-bad-idea-tp5737056p5737139.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Proposal: RankedInstances

2013-09-26 Thread Wvv
The main power of Haskell is on instances.
But Haskell instances system work fine with lower number of instances (rare
instances).
But we want hight density of instances!
If we wish to have more selective instances we use `OverlappingInstances`
(which are desined in a poor way)  and if we still have too many instances
we use `IncoherentInstances`.

~~`RankedInstances` extension ~~

I suggest simple `RankedInstances` extension.
We use it (!)before OverlappingInstances (it must include
`RankedInstances`), and in many cases instead of.

This extension is easy to implement and it give us a lot of new
possibilities and instruments.

Now the system of instances is flat, and compiler takes all of them and
check if only 1 match. If it is not(less or more than) - compiler trow an
error.

I suggest to add rankings, so compiler
* compiler set N=0
* took all N-ranked instances and 
 ** try to find only one match instance.
 *** If it found 1 - this is RESULT: needed instance, 
 *** If it found many instances - still throw an error 
 *** (then we use `OverlappingInstances` to resolve this)
 *** If compiler found NO instances, compiler set N=N+1 and repeat
* If N=MaxRank and still no matches compiler throw an error

~~How to add a rank~~
I suggest next grammar:

  {-# LANGUAGE RankedInstances #-}

  instance rank 1. C a = D a where ...


  instance   C2 a = E a where ...  
  == 
  instance rank 0. C2 a = E a where ...

So, all written instances(without ranking) are 0-ranked instances.

Backward compatibility = without -XRankedInstances all instances with rank
n, where n 0 - are not exported

~Example~
1)
  instance rank 1. C Int a where ...   -- (A)
  instance   C a   Bool  where ...   -- (B) rank 0
1+)
  instance rank 1. C Int a where ...   -- (A)
  instance rank 1. C a   Bool  where ...   -- (B)  
  instance   C Int Bool  where ...   -- (C) rank 0
  
2)
  instance rank 1. C Int [a]  where ...  -- (C)
  instance C Int [Int]  where ...  -- (D)

As we see, all instances are unambiguous!

~~ Rank Scale~~

It is for discussion, I see this like:
0   - default
1 ..9  - user free (without fear to overlap with devs instances)
10 .. 14  - Generic
15 ..  - superclass' instances

~~ Higher Rank instances~~
We don't need to use `default` inside of class:

  instance rank 10. (Generic a, GToJSON (Rep a)) = ToJSON a where
toJSON = genericToJSON defaultOptions

We could add superclass' instances now, something like these:

  instance rank 15. Monad m = Applicative m where 
pure  = return 
(*) = ap 
 
  instance rank 16. Monad m = Functor m where 
fmap = liftM  

  instance rank 17. Applicative m = Functor m where 
fmap f x = pure f * x

~~Inherit mechanism~~

What do if we want to use any proposed instance, not in the rank order ?
For example we have data, which is Monad and Applicative, but not a Functor.
We'll use automatically instance rank 16. Monad m = Functor m, but not
instance rank 17. Applicative m = Functor m .
But we wish to use the last one. We need to create a new instance and
inherit the behavior of needed instance


  data D a 

  instance Monad D where ...
  instance Applicative D where ...

  instance rank 1. Functor D inherit (D ~ m)
instance Applicative m = Functor m

  foo = ... fmap

So, in this case we'll use `fmap` as Applicative Functor.

Inherit mechanism defaulting :

   instance  C a = D a where ...
   ==
   instance  C a = D a inherit (a ~ b) class D b where

~~ As pattern in RankedInstances~~

Now we add as pattern and rewrite both of our instances:

  instance rank 17. Applicative m = ApFunctor@Functor m where 
fmap f x = pure f * x

  instance ApFunctor D --by the way 0-ranked

Wow!!! It is simple, safe and looks nicer! 

~~Partly Applied Instances~~

We describe a situation when we write a child class and want automatically
get access to parent's classes.
But sometimes we need to use already defined parent classes to describe
children classes

We CANNOT do next:

  instance rank 20. (Functor m, Applicative m) = Monad m where 
ma  mb = (fmap (const id) ma) `apply` mb

  instance rank 21. Applicative m = Monad m where
ma  mb = (pure (const id) * ma) `apply` mb  

Because if we define 

  data D a ...

  instance Functor D ...
  instance Applicative D ...

  D a = D b  -- this will compiler, but we have no full applied
MonadInstance

How to resolve this?

I suggest to add one reserved world newclass (as an analog of newtype)


--instance (Functor m, Applicative m) = FAMonad@Monad m where 
newclass (Functor m, Applicative m) = FAMonad@Monad m where 
ma  mb = (fmap (const id) ma) `apply` mb

--instance Applicative m = AMonad@Monad m where
newclass (Applicative m) = AMonad@Monad m where 
ma  mb = (pure (const id) * ma) `apply` mb

The newclass is just an instance, but guarded - compiler did count it when
it try to match
So, now next throw an error: D a = D b

And we have 

[Haskell-cafe] Why superclass' instances are bad idea?

2013-09-24 Thread Wvv
I suggest to add superclass' instances into  libraries.

http://ghc.haskell.org/trac/ghc/ticket/8348

In brief, we could write next:

{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE UndecidableInstances #-}

instance Monad m = Applicative m where
pure  = return
(*) = ap
   
instance Monad m = Functor m where
fmap = liftM

instance Monad m = Bind m where
(-) = flip (=)
B.join = M.join

this code is valid! 

I've already defined 3 superclassses for Monad: Functor, Applicative and
Bind!

Similar idea said Edward Kmett in 2010 (founded by monoidal) (
http://stackoverflow.com/questions/3213490/how-do-i-write-if-typeclass-a-then-a-is-also-an-instance-of-b-by-this-definit/3216937#3216937
)

And he said but effectively what this instance is saying is that every
Applicative should be derived by first finding an instance for Monad, and
then dispatching to it. So while it would have the intention of saying that
every Monad is Applicative (by the way the implication-like = reads) what
it actually says is that every Applicative is a Monad, because having an
instance head 't' matches any type. In many ways, the syntax for 'instance'
and 'class' definitions is backwards.

Why? I don't understand.
Not every Applicative is a Monad, but every Monad is Applicative



--
View this message in context: 
http://haskell.1045720.n5.nabble.com/Why-superclass-instances-are-bad-idea-tp5737056.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Proposal: Pragma EXPORT

2013-09-16 Thread Wvv
I suggest to add instead of (or with) export section Pragma EXPORT:

We have 3 values: public, abstract and private.
Data(with newtypes and types,..) could be public, like `Data(...)` or
abstract `Data`.
Other cases abstract = public.

{-# EXPORT smth #-} pragma is valid till next {-# EXPORT smth #-}.

We also can add local pragma: 
{-# EXPORT smth from #-}  ... {-# EXPORT smth untill #-}
Outside of block is rule of previous {-# EXPORT smth #-}.

Finally we also have rule for 1: {-# EXPORT smth one #-}

Example

module C where
{-# EXPORT public #-}
data A1...
data A2...
{-# EXPORT abstract from #-}
newtype A3... 
data A4...
{-# EXPORT abstract until #-}
type A5...
{-# EXPORT private one #-}
data A6...

foo = ... 
{-# EXPORT private one #-}
bar = ... 
baz = ... 
lorem = ...   
{-# EXPORT private #-}
insput ...
dolor = ..
sit = ... 
{-# EXPORT public one #-}
amen = ...
consectetur = ... 
adipisicing = ... 
elit = ...
sed = ... 
eiusmod  = ...
tempor  = ... 
incididunt = ...  
{-# EXPORT public from #-}
ut = ...  
labore = ...  
et = ...  
{-# EXPORT public until #-}
dolore = ...  
magna = ...   
aliqua = ...  



is the same as 

module C (
  A1(..)
, A2(..)
, A3
, A4  
, A5(..)
, foo
, baz
, lorem
, amen
, ut
, labore
, et
) where 

data A1...
data A2...
newtype A3... 
data A4...
type A5...
data A6...

foo = ... 
bar = ... 
baz = ... 
lorem = ...   
insput ...
dolor = ..
sit = ... 
amen = ...
consectetur = ... 
adipisicing = ... 
elit = ...
sed = ... 
eiusmod  = ...
tempor  = ... 
incididunt = ...  
ut = ...  
labore = ...  
et = ...  
dolore = ...  
magna = ...   
aliqua = ...


We also could have complex pragma, like
{-# EXPORT inherit one foo #-}
bar=...

Backward compatibility:
module A where  ... ~  module A where {-# EXPORT public #-} ...
module B (  ) where ... ~ module B (  ) where {-# EXPORT private #-}
...



--
View this message in context: 
http://haskell.1045720.n5.nabble.com/Proposal-Pragma-EXPORT-tp5736547.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Unary functions and infix notation

2013-09-06 Thread Wvv
But we can do next:

   Prelude :set XPostfixOperators
   Prelude let z = (\y - True) :: a - Bool 
   Prelude :t (True `z`)

But still
`z` True   ~\a - a `z` True~   \a - z a True
and `z` must be a function with minimum 2 arguments



--
View this message in context: 
http://haskell.1045720.n5.nabble.com/Unary-functions-and-infix-notation-tp5735766p5735807.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Proposal: Generic conditions for 'if' and 'case'

2013-09-02 Thread Wvv
Thanks! It is a good toy for testing!


Nicolas Trangez wrote
 Here's an example implementing your proposal:
 
 {-# LANGUAGE RebindableSyntax #-}
 
 import Prelude
 
 class Boolean a where
 toBool :: a - Bool
 
 instance Boolean Bool where
 toBool = id
 
 instance Boolean [a] where
 toBool = not . null
 
 instance Boolean (Maybe a) where
 toBool = maybe False (const True)
 
 instance Boolean Int where
 toBool = (/= 0)
 
 ifThenElse :: Boolean a = a - b - b - b
 ifThenElse i t e = case toBool i of
 True - t
 False - e
 
 main :: IO ()
 main = do
 test False
 test ([] :: [Int])
 test [1]
 test (Nothing :: Maybe Int)
 test (Just 1 :: Maybe Int)
 test (0 :: Int)
 test (1 :: Int)
 {- test 'c' fails to type-check: no instance Boolean Char defined!
 -}
   where
 test v = putStrLn $ show v ++  is  ++ (if v then true else
 false)
 
 which outputs
 
 False is false
 [] is false
 [1] is true
 Nothing is false
 Just 1 is true
 0 is false
 1 is true
 
 Using RebindableSyntax, 'if I then T else E' is rewritten into
 'ifThenElse I T E' by the compiler, for whatever 'ifThenElse' is in
 scope.
 
 Nicolas
 
 
 ___
 Haskell-Cafe mailing list

 Haskell-Cafe@

 http://www.haskell.org/mailman/listinfo/haskell-cafe





--
View this message in context: 
http://haskell.1045720.n5.nabble.com/Proposal-Generic-conditions-for-if-and-case-tp5735366p5735424.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Proposal: Polymorphic typeclass and Records

2013-09-01 Thread Wvv
Thanks!
You do a great job!


Adam Gundry wrote
 Haskell doesn't allow classes to be polymorphic in the names of their
 methods

Yes, still not ((




--
View this message in context: 
http://haskell.1045720.n5.nabble.com/Proposal-Polymorphic-typeclass-and-Records-tp5735096p5735365.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Proposal: Generic conditions for 'if' and 'case'

2013-09-01 Thread Wvv
I think it is an old idea, but nevertheless.
Now we have next functions:

if (a :: Bool) then x else y

case b of
a1 :: Bool - x1
a2 :: Bool - x2
...

Let we have generic conditions for 'if' and 'case':

class Boolean a where
toBool :: a - Bool

instance Boolean Bool where
   toBool = id

instance Boolean [a] where
   toBool [] = False
   toBool _ = True

instance Boolean (Maybe a) where
   toBool Nothing = False
   toBool _ = True

instance Boolean Int where
   toBool 0 = False
   toBool _ = True

if' (a :: Boolean b) then x else y

case' d of
a1 :: Boolean b1 - x1
a2 :: Boolean b2 - x2
...


It is very easy to implement to desugar:
if' a then ... == if toBool ( a ) then ...



--
View this message in context: 
http://haskell.1045720.n5.nabble.com/Proposal-Generic-conditions-for-if-and-case-tp5735366.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Proposal: Polymorphic typeclass and Records

2013-08-28 Thread Wvv
Let we have data in one module as this:

data Person  = Person  { personId :: Int, name :: String }
data Address a = Address { personId :: Int, address :: String , way :: 
a}

It was discussed a lot in topics OverloadedRecordFields

This is an alternative:
Let we have polymorphic typeclass:

  class Record{f} a b | a - b where
  f :: a - b

so, compiler could create instances for our data as:

instance Record{personId} Person Int where
personId (Person x _) = x

instance Record{personId} (Address a) Int where
personId (Address x _ _) = x

instance Record{way} (Address Int) Int where
way (Address _ _ x) = x 

and we could use this:

p:: Record {personId} r Int = r - Int
p = personId


What do you think about this?



--
View this message in context: 
http://haskell.1045720.n5.nabble.com/Proposal-Polymorphic-typeclass-and-Records-tp5735096.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Rank N Kinds

2013-08-10 Thread Wvv
Paradoxes there are at logic and math. At programing languages we have bugs or
features :))

Higher universe levels are needed first of all for more abstract programming.


P.S. By the way, we don't need have extra TupleList, we have already list!

t3 :: [ (Int :: **) - (Bool - Bool - Bool :: **) - (String :: **) ]
t3 = [42 :: Int, (), This is true *** type ]

 :k t3
*

 head t3
42 :: Int

 (head $ tail t3) True True
True :: Bool


Wvv

  2 Aug 2013 at 5:34:26, Daniel Peebles [via Haskell]
  (ml-node+s1045720n5733708...@n5.nabble.com) wrote:


  The higher universe levels are mostly used to stave off logical paradoxes
  in languages where you care about that kind of stuff. In a fundamentally
  impredicative language like Haskell I don't see much point, but I'd be happy
  to find there is one :)

  On Thu, Aug 1, 2013 at 4:55 PM, Wvv [hidden email] wrote:

The right one is `instance Functor TupleList where ...`




--
View this message in context: 
http://haskell.1045720.n5.nabble.com/Rank-N-Kinds-tp5733482p5734055.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Rank N Kinds

2013-08-01 Thread Wvv
I still asking for good examples of ranNkinds data (and classes)

But now let's look at my example, TupleList

data TupleList (t :: **) = TupleNil | TupleUnit t (TupleList t)

we can easily define tupleList

 tupleL :: TupleList ( (Int :: **) - (String :: **) - (Bool :: **) )
 tupleL = TupleUnit 5 (TupleUnit inside tuple (TupleUnit True TupleNil)))

And we can easily define rankNkinds functions, which can only work with
rankNkinds data,
like fstL, sndL, headL, tailL (see my previous letter)


But Haskell is weak to work with truly rankNkinds functions.

Let's look at Functor

instance Functor (TupleList (a :: **)) where
 fmap :: ?
 fmap = tmap

What's the signature of fmap? Even with rankNkinds we can't define a
signature. Without new extensions.
Let's look at tmap ~ map for list.
It's bit simplier for us

 tmap :: 
 tmap _ TupleNil = TupleNil
 tmap f (TupleUnit x xs) = TupleUnit (f x) (tmap f xs)


If we wish to work with `f` like in this example, we must use
`rankNkindsFunctions` extension.
It's very hard to implement this extension into Haskell (imho)
Let's think we've already had this extension and we have a `tmap`
Let's try to write rankNkinds functions for next tupleLists:

 tupleL :: TupleList ( (Int :: **) - (String :: **) - (Bool :: **) )
 tupleL = TupleUnit 5 (TupleUnit inside tuple (TupleUnit True TupleNil)))

 tupleL' :: TupleList ( (Int :: **) - (Int :: **) - (Bool :: **) )
 tupleL' = TupleUnit 5 (TupleUnit 42 (TupleUnit True TupleNil)))

 tupleL'' :: TupleList ( (Int :: **) - (Int :: **) - (Int :: **) )
 tupleL'' = TupleUnit 5 (TupleUnit 42 (TupleUnit 777 TupleNil)))

here they are:

 f :: ((Int - Int) :: **) - ((String - String)  :: **) - ((Bool - Bool)
:: **)

 f :: Int - Int
 f = (+ 2)

 f :: String - String
 f = (Hello  ++)

 f :: Bool - Bool
 f = (True )

2nd:

 f' :: c@((Int - Int) :: **) - c'@((Int - Int)  :: **) - ((Bool - Bool)
:: **)

 f' :: c@(Int - Int)
 f' = (+ 2)

 f' :: c'@(Int - Int)
 f' = (* 5)

 f' :: Bool - Bool
 f' = (True )

3rd:

 f'' :: c@((Int - Int) :: **) - c@((Int - Int)  :: **) - c@((Int - Int) 
:: **)

 f'' :: c@(Int - Int)
 f'' = (+ 2)

These functions not only look weird, they look like overloading, but they
are not.
But truly, they are really weird.

Le's look deeply at line `tmap f (TupleUnit x xs) = TupleUnit (f x) (tmap f
xs)`
Truly rankNkinds functions works like ST Monad and partly applied function
together!
This is awesome! 

((Int - Int) :: **) - ((String - String)  :: **) - ((Bool - Bool) ::
**) `op` (Int ::*) = 
  (Int :: **) - ((String - String)  :: **) - ((Bool - Bool) :: **)

 (Int :: **) - ((String - String)  :: **) - ((Bool - Bool) :: **)
 `op` (String ::*) = 
  (Int :: **) - (String :: **) - ((Bool - Bool) :: **)

 (Int :: **) - (String :: **) - ((Bool - Bool) :: **) `op` (Bool ::*)
 = 
  (Int :: **) - (String :: **) - (Bool :: **)

== TupleUnit (f x) (TupleUnit (f x') (TupleUnit (f x'') TupleNil))


Ok. Now we are ready to redefine  f'' in a general way.
We need to have one extra extension: RecursiveSignatures.
We add 2 quantifications: 'forany' and 'forrec' (it's just my suggestion,
may be is too complicated and exists easier way to do this):

 f''' :: forany i. forrec{i} c. c@((Int - Int) :: **) - { - c }

 f''' :: forrec{i=0..3} c. c@(Int - Int)
 f''' = (+ 2)

Let's write `f` function using these quantifications:

 g :: forany i. forrec{i} a c. c@(a - a :: **) { - c } 

 g :: forrec c{0}. Int - Int   ==  g :: forrec c{0} (a{0} ~ Int). a -
a 
 g = (+ 2)

 g :: forrec c{1}. String - String
 g = (Hello  ++)

 g :: forrec c{2}. Bool - Bool
 g = (True )

And now it is possible to write signatures to `tmap` and `fmap`

 tmap :: forany i. forrec{i} a b c c' c''. c@( (a - b) :: **) { - c } -
c'@(a :: * :: **) { - c' } - c''@(b :: * :: **) { - c'' }

 fmap :: forany i. forrec{i} a b c c' c''. c@( (a - b) :: **) { - c } - f
(c'@(a :: **) { - c' }) - f (c''@(b :: **) { - c'' })



P.S. We could write foldr function for our tupleLists as:

 folded :: Bool
 folded = foldr h True tupleL

 h :: forany i. forrec{i} a c. c@( a - b - b :: **) { - c } 

 h :: forrec c{0}. Int- Bool - Bool

 h :: forrec c{1}. String - Bool - Bool

 h :: forrec c{2}. Bool   - Bool - Bool


P.S.S.  All this staff is open for discussion ))

cheers, Wvv 



--
View this message in context: 
http://haskell.1045720.n5.nabble.com/Rank-N-Kinds-tp5733482p5733699.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Rank N Kinds

2013-08-01 Thread Wvv
I'm sorry, `instance Functor (TupleList (a :: **)) where ...` isn't right,
sure.
The right one is `instance Functor TupleList where ...`



--
View this message in context: 
http://haskell.1045720.n5.nabble.com/Rank-N-Kinds-tp5733482p5733700.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Rank N Kinds

2013-07-31 Thread Wvv
OMG!
I still have 7.6.3. It has old Typeable.

I misunderstood PolyKinds a bit. It looks like k /= **, k ~ ***...

But we cannot use CloseKinds like

data Foo (a::k) = Foo a -- catch an error Expected kind `OpenKind', but `a' has
kind `k'


with RankNKinds we could write:
data Foo (a::**) = Foo a
data Bar (a::***) = Bar a

So, now the task is more easy:
I'm asking for useful examples with CloseKinds with ** and higher, and any
useful examples for *** and higher

cheers, Wvv

29 Jul 2013 at 14:44:50, José Pedro Magalhães [via Haskell]
(ml-node+s1045720n5733561...@n5.nabble.com) wrote:

  Hi,

  On Fri, Jul 26, 2013 at 10:42 PM, Wvv [hidden email] wrote:

First useful use is in Typeable.
In GHC 7.8
class Typeable (a::k) where ... == class Typeable (a ::**) where ...

But we can't write
data Foo (a::k)-(a::k)-* ... deriving Typeable


  Why not? This works fine in 7.7, as far as I know.


  Cheers,
  Pedro




--
View this message in context: 
http://haskell.1045720.n5.nabble.com/Rank-N-Kinds-tp5733482p5733667.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Rank N Kinds

2013-07-31 Thread Wvv
How about this, I found it bt myself:


data TupleList (t :: **) = TupleNil | TupleUnit t (TupleList t)

fstL :: TupleList (a - **) - a
fstL TupleNil = error TupleList2 is TupleNil
fstL (TupleUnit a _ ) = a

sndL :: TupleList (* - a - **) - a
sndL TupleNil = error TupleList2 is TupleNil
sndL (TupleUnit a TupleNil ) = error TupleList2 is TupleUnit a TupleNil
sndL (TupleUnit _ (TupleUnit a _ ) ) = a

headL :: TupleList (a - **) - a
headL TupleNil = error TupleList2 is TupleNil
headL (TupleUnit a _ ) = a

tailL :: TupleList (* - a) - a
tailL TupleNil = error TupleList2 is TupleNil
tailL (TupleUnit _ a ) = a

instance Functor (TupleList (a :: **)) where
fmap _ TupleNil = TupleNil
fmap f (TupleUnit x xs) = TupleUnit (f x) (fmap xs)


tupleL :: TupleList ( (Int :: *) - (String :: *) - (Bool :: *) )
tupleL = TupleUnit 5 (TupleUnit inside tuple (TupleUnit True TupleNil)))

fstTuppleL :: Int
fstTuppleL = fstL tupleL -- = 2

sndTuppleL :: String
sndTuppleL = sndL tupleL -- = inside tuple

tlTuppleL :: TupleList ( (String :: *) - (Bool :: *) )
tlTuppleL = tailL tupleL -- = TupleUnit inside tuple (TupleUnit True 
TupleNil))

cheers, Wvv

  31 Jul 2013 at 22:48:19, Roman Cheplyaka-2 [via Haskell]
  (ml-node+s1045720n5733671...@n5.nabble.com) wrote:


  That's because types that belong to most non-star kinds cannot have
  values.

  data Foo (a :: k) = Foo

  is okay,

  data Foo (a :: k) = Foo a

  is bad because there cannot be a field of type a :: k.

  So no, no useful examples exist, because you wouldn't be able to use
  such a data constructor even if you could declare it.

  Roman

  * Wvv [hidden email] [2013-07-31 11:40:17-0700]
   OMG!
   I still have 7.6.3. It has old Typeable.
  
   I misunderstood PolyKinds a bit. It looks like k /= **, k ~ ***...
  
   But we cannot use CloseKinds like
  
   data Foo (a::k) = Foo a -- catch an error Expected kind `OpenKind', but
  `a' has
   kind `k'
  
  
   with RankNKinds we could write:
   data Foo (a::**) = Foo a
   data Bar (a::***) = Bar a
  
   So, now the task is more easy:
   I'm asking for useful examples with CloseKinds with ** and higher, and
  any
   useful examples for *** and higher
  
   cheers, Wvv
  
   29 Jul 2013 at 14:44:50, José Pedro Magalhães [via Haskell]
   ([hidden email]) wrote:
  
   Hi,
  
   On Fri, Jul 26, 2013 at 10:42 PM, Wvv [hidden email] wrote:
  
   First useful use is in Typeable.
   In GHC 7.8
   class Typeable (a::k) where ... == class Typeable (a ::**) where ...
  
   But we can't write
   data Foo (a::k)-(a::k)-* ... deriving Typeable
  
  
   Why not? This works fine in 7.7, as far as I know.
  
  
   Cheers,
   Pedro
  
  
  
  
   --
   View this message in context:
  http://haskell.1045720.n5.nabble.com/Rank-N-Kinds-tp5733482p5733667.html
   Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
   ___
   Haskell-Cafe mailing list
   [hidden email]
   http://www.haskell.org/mailman/listinfo/haskell-cafe


  ___
  Haskell-Cafe mailing list
  [hidden email]
  http://www.haskell.org/mailman/listinfo/haskell-cafe




--
View this message in context: 
http://haskell.1045720.n5.nabble.com/Rank-N-Kinds-tp5733482p5733672.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Rank N Kinds

2013-07-28 Thread Wvv
Yes,
True :: Bool :: * :: ** :: *** ::  :: ... in Haskell is the same as

True :: Bool :: Set0 :: Set1 :: Set2 :: Set3 :: ... in Agda

And I'm asking for useful examples for *** (Set2 in Agda) and higher


cheers Wvv

  28 Jul 2013 at 8:44:08, Schonwald [via Haskell]
  (ml-node+s1045720n5733510...@n5.nabble.com) wrote:


  hello Wvv,
  a lot of these ideas have been explored before in related (albeit simpler)
  languages to haskell, are you familiar with idris, coq, or agda?
  cheers-Carter

  On Fri, Jul 26, 2013 at 4:42 PM, Wvv [hidden email] wrote:

It was discussed a bit here:
http://ghc.haskell.org/trac/ghc/ticket/8090

Rank N Kinds:
Main Idea is:

If we assume an infinite hierarchy of classifications, we have

True :: Bool :: * :: ** :: *** ::  :: ...

Bool = False, True, ...
* = Bool, Sting, Maybe Int, ...
** = *, *-Bool, *-(*-*), ...
*** = **, **-*, (**-**)-*, ...
...

RankNKinds is also a part of lambda-cube.

PlyKinds is just type of ** (Rank2Kinds)

class Foo (a :: k) where == class Foo (a :: **) where

*** is significant to work with ** data and classes;
more general: Rank(N)Kinds is significant to work with Rank(N-1)Kinds

First useful use is in Typeable.
In GHC 7.8
class Typeable (a::k) where ... == class Typeable (a ::**) where ...

But we can't write
data Foo (a::k)-(a::k)-* ... deriving Typeable

If we redeclare
class Typeable (a ::***) where ...
or even
class Typeable (a ::**) where ...
it becomes far enough for many years

I'm asking to find other useful examples



--
View this message in context:
http://haskell.1045720.n5.nabble.com/Rank-N-Kinds-tp5733482.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

___
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe



  ___
  Haskell-Cafe mailing list
  [hidden email]
  http://www.haskell.org/mailman/listinfo/haskell-cafe


  

  If you reply to this email, your message will be added to the discussion
  below:http://haskell.1045720.n5.nabble.com/Rank-N-Kinds-tp5733482p5733510.html
  To unsubscribe from Rank N Kinds, click here.
  NAML




--
View this message in context: 
http://haskell.1045720.n5.nabble.com/Rank-N-Kinds-tp5733482p5733545.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Rank N Kinds

2013-07-26 Thread Wvv
It was discussed a bit here: 
http://ghc.haskell.org/trac/ghc/ticket/8090

Rank N Kinds: 
Main Idea is: 

If we assume an infinite hierarchy of classifications, we have 

True :: Bool :: * :: ** :: ***  ::  :: ... 

Bool  = False, True, ... 
*  = Bool, Sting, Maybe Int, ... 
**= *, *-Bool, *-(*-*), ... 
***  = **, **-*, (**-**)-*, ... 
... 

RankNKinds is also a part of lambda-cube. 

PlyKinds is just type of ** (Rank2Kinds) 

class Foo (a :: k)  where == class Foo (a :: **) where 

*** is significant to work with ** data and classes; 
more general: Rank(N)Kinds is significant to work with Rank(N-1)Kinds 

First useful use is in Typeable. 
In GHC 7.8 
class Typeable (a::k) where ... == class Typeable (a ::**) where ... 

But we can't write 
data Foo (a::k)-(a::k)-* ... deriving Typeable 

If we redeclare 
class Typeable (a ::***) where ... 
or even 
class Typeable (a ::**) where ... 
it becomes far enough for many years 

I'm asking to find other useful examples



--
View this message in context: 
http://haskell.1045720.n5.nabble.com/Rank-N-Kinds-tp5733482.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe