it to be polymorphic as described above, the transformed
GHC
Core for an Int - Int function should look like
foo = addHook @ GHC.Types.Int @ GHC.Types.Int GHC.Classes.$fOrdInt (\ x -
...)
My question is, given the right hand side of foo, how do I construct the
type/type class information
for an Int - Int function should look like
foo = addHook @ GHC.Types.Int @ GHC.Types.Int GHC.Classes.$fOrdInt (\ x - ...)
My question is, given the right hand side of foo, how do I construct the
type/type class information inside Core shown above?
Cheers,
Shen
Wait... what do you mean Core cannot generate new names to be exported.
I meant if I add a new name in the Core transformation, that doesn't
change the module's export list as seen by everything outside that
module. Which makes sense, it just means I have to change my approach.
Maybe you mean
Christopher Done wrote:
It's very easy to state this problem without enough details and mislead
people into providing a solution for a different problem, so I'll try to
include all the information and use-case. I need a function that can
store a value in a concrete opaque type. I know the type
On 4 October 2013 10:56, Heinrich Apfelmus apfel...@quantentunnel.de wrote:
In particular, the Locker stores arbitrary values like Dynamic , except
that values are extracted and removed with the help of a Key . This gets
rid of the Typeable constraint.
lock :: Key a - a - Locker
I can't
Christopher Done wrote:
On 4 October 2013 10:56, Heinrich Apfelmus apfel...@quantentunnel.de wrote:
In particular, the Locker stores arbitrary values like Dynamic , except
that values are extracted and removed with the help of a Key . This gets
rid of the Typeable constraint.
lock ::
| However, I want to write this as a core-to-core
| translation as a ghc-plugin. I want the definition go = putStrLn Hello
| World! to be translated to what I wrote above. Core cannot generate new
| names to be exported from a module, so go_ is now gone.
Wait... what do you mean Core cannot
Hi Chris,
Maybe this package (from Edward Kmett, surprisingly) could help:
http://hackage.haskell.org/package/constraints-0.3.3/docs/Data-Constraint.html?
Considering it kind of reifies the type class constraints, I'm wondering
whether you could use this to carry the constraints along the value
a. Anything a
λ let x = Anything id
λ case x of Anything (unsafeCoerce - (id' :: Int - Int)) - id' 123
123
Great, I was able to store a value which contained non-concrete
types. But now consider the case of a value with type-class
polymorphic type in it:
y = Anything (print :: Show a = a - IO
#7557: Default implementation for a type class function missing when profiling
is
enabled
-+--
Reporter: JohnWiegley | Owner:
Type: bug | Status: new
#6117: Cyclic Type Class Hierarchy Produces loop
--+-
Reporter: jun0 | Owner: simonpj
Type: bug | Status: closed
Priority
#6117: Cyclic Type Class Hierarchy Produces loop
+---
Reporter: jun0 | Owner: simonpj
Type: bug | Status: new
#6117: Cyclic Type Class Hierarchy Produces loop
+---
Reporter: jun0 | Owner: simonpj
Type: bug | Status: new
#6117: Cyclic Type Class Hierarchy Produces loop
+---
Reporter: jun0 | Owner: simonpj
Type: bug | Status: new
#5913: Type class dictionary call loops at runtime
-+--
Reporter: mnislaih| Owner:
Type: bug | Status: closed
Priority
#6117: Cyclic Type Class Hierarchy Produces loop
+---
Reporter: jun0 | Owner: simonpj
Type: bug | Status: new
#7252: Impossible error when deriving lower-cased type class (nameModule show{tv
a9Y})
+---
Reporter: sfogarty| Owner:
Type: bug | Status: new
#7252: Impossible error when deriving lower-cased type class (nameModule show{tv
a9Y})
---+
Reporter: sfogarty|Owner:
Type: bug | Status: closed
Also, I have to admit I was a bit handwavy here; I meant P in a
metatheoretic sense, that is P(a) is some type which contains 'a' as a
free variable, and thus the 'theorem' is really a collection of theorems
parametrized on the P you choose.
For example, P(a) could be Show a a - Int; in that
On 8/17/12 12:54 AM, Alexander Solla wrote:
On Thu, Aug 16, 2012 at 8:07 PM, wren ng thornton w...@freegeek.org wrote:
Though bear in mind we're discussing second-order quantification here, not
first-order.
Can you expand on what you mean here? I don't see two kinds of
quantification in the
On 8/15/12 12:32 PM, David Feuer wrote:
On Aug 15, 2012 3:21 AM, wren ng thorntonw...@freegeek.org wrote:
It's even easier than that.
(forall a. P(a)) - Q = exists a. (P(a) - Q)
Where P and Q are metatheoretic/schematic variables. This is just the
usual thing about antecedents being in
On 8/15/12 2:55 PM, Albert Y. C. Lai wrote:
On 12-08-15 03:20 AM, wren ng thornton wrote:
(forall a. P(a)) - Q = exists a. (P(a) - Q)
For example:
A. (forall p. p drinks) - (everyone drinks)
B. exists p. ((p drinks) - (everyone drinks))
In a recent poll, 100% of respondents think A true,
On Thu, Aug 16, 2012 at 8:07 PM, wren ng thornton w...@freegeek.org wrote:
On 8/15/12 2:55 PM, Albert Y. C. Lai wrote:
On 12-08-15 03:20 AM, wren ng thornton wrote:
(forall a. P(a)) - Q = exists a. (P(a) - Q)
For example:
A. (forall p. p drinks) - (everyone drinks)
B. exists p. ((p
On 8/13/12 9:25 PM, Jay Sulzberger wrote:
I did suspect that, in some sense, constraints in combination
with forall could give the quantifier exists.
It's even easier than that.
(forall a. P(a)) - Q = exists a. (P(a) - Q)
Where P and Q are metatheoretic/schematic variables. This is
On Aug 15, 2012 3:21 AM, wren ng thornton w...@freegeek.org wrote:
It's even easier than that.
(forall a. P(a)) - Q = exists a. (P(a) - Q)
Where P and Q are metatheoretic/schematic variables. This is just the
usual thing about antecedents being in a negative position, and thus
flipping
On 12-08-15 03:20 AM, wren ng thornton wrote:
(forall a. P(a)) - Q = exists a. (P(a) - Q)
For example:
A. (forall p. p drinks) - (everyone drinks)
B. exists p. ((p drinks) - (everyone drinks))
In a recent poll, 100% of respondents think A true, 90% of them think B
paradoxical, and
In classical logic A - B is the equivalent to ~A v B
(with ~ = not and v = or)
So
(forall a. P(a)) - Q
{implication = not-or}
~(forall a. P(a)) v Q
{forall a. X is equivalent to there does not exist a such that X doesn't
hold}
~(~exists a. ~P(a)) v Q
{double negation elimination}
I understand this now, though I still don't understand the context. Thanks!
I managed to mix up implication with causation, to my great embarrassment.
On Aug 15, 2012 3:39 PM, Ryan Ingram ryani.s...@gmail.com wrote:
In classical logic A - B is the equivalent to ~A v B
(with ~ = not and v = or)
On Mon, Aug 13, 2012 at 6:53 PM, Alexander Solla alex.so...@gmail.comwrote:
In a classical logic, the duality is expressed by !E! = A, and !A! = E,
where E and A are backwards/upsidedown and ! represents negation. In
particular, for a proposition P,
Ex Px = !Ax! Px (not all x's are not P)
That pattern looks so familiar. :) Existential types seem to fit in to the
type system really well so I never got why it is not part of the standard.
On Aug 12, 2012 10:36 AM, Daniel Trstenjak daniel.trsten...@gmail.com
wrote:
Hi Oleg,
On Sat, Aug 11, 2012 at 08:14:47AM -, o...@okmij.org
On Mon, 13 Aug 2012, Johan Holmquist holmi...@gmail.com wrote:
That pattern looks so familiar. :) Existential types seem to fit in to the
type system really well so I never got why it is not part of the standard.
On Aug 12, 2012 10:36 AM, Daniel Trstenjak daniel.trsten...@gmail.com
wrote:
On Mon, Aug 13, 2012 at 12:30 PM, Jay Sulzberger j...@panix.com wrote:
Does Haskell have a word for existential type declaration? I
have the impression, and this must be wrong, that forall does
double duty, that is, it declares a for all in some sense like
the usual for all of the Lower
On Mon, 13 Aug 2012, Ryan Ingram ryani.s...@gmail.com wrote:
On Mon, Aug 13, 2012 at 12:30 PM, Jay Sulzberger j...@panix.com wrote:
Does Haskell have a word for existential type declaration? I
have the impression, and this must be wrong, that forall does
double duty, that is, it declares a
On Mon, Aug 13, 2012 at 6:25 PM, Jay Sulzberger j...@panix.com wrote:
On Mon, 13 Aug 2012, Ryan Ingram ryani.s...@gmail.com wrote:
On Mon, Aug 13, 2012 at 12:30 PM, Jay Sulzberger j...@panix.com wrote:
Does Haskell have a word for existential type declaration? I
have the impression,
On Mon, 13 Aug 2012, Alexander Solla alex.so...@gmail.com wrote:
On Mon, Aug 13, 2012 at 6:25 PM, Jay Sulzberger j...@panix.com wrote:
On Mon, 13 Aug 2012, Ryan Ingram ryani.s...@gmail.com wrote:
On Mon, Aug 13, 2012 at 12:30 PM, Jay Sulzberger j...@panix.com wrote:
Does Haskell have
Antoine Latter wrote:
It should be pretty easy to write an adapter function of type String -
(Show a = a).
The type needs to be
String - (exists a. Show a = a)
which is equivalent to
String - (forall a. Show a = a - c) - c
Here is the implementation of the adapter
newtype
Hi Oleg,
On Sat, Aug 11, 2012 at 08:14:47AM -, o...@okmij.org wrote:
I'd like to point out that the only operation we can do on the first
argument of MkFoo is to show to it. This is all we can ever do:
we have no idea of its type but we know we can show it and get a
String. Why not to
data A = A deriving Show
data B = B deriving Show
data C = C deriving Show
data Foo = forall a. Show a = MkFoo a (Int - Bool)
instance Show Foo where
show (MkFoo a f) = show a
I'd like to point out that the only operation we can do on the first
argument of MkFoo is to show to it. This
Has anyone used existential types to represent items on a schedule in a
scheduled lazy data structure?
On Aug 11, 2012 4:15 AM, o...@okmij.org wrote:
data A = A deriving Show
data B = B deriving Show
data C = C deriving Show
data Foo = forall a. Show a = MkFoo a (Int - Bool)
On Sat, Aug 11, 2012 at 4:14 AM, o...@okmij.org wrote:
I'd like to point out that the only operation we can do on the first
argument of MkFoo is to show to it. This is all we can ever do:
we have no idea of its type but we know we can show it and get a
String.
That's not all you can do:
It should be pretty easy to write an adapter function of type String -
(Show a = a).
On Aug 11, 2012 12:34 PM, Patrick Palka patr...@parcs.ath.cx wrote:
On Sat, Aug 11, 2012 at 4:14 AM, o...@okmij.org wrote:
I'd like to point out that the only operation we can do on the first
argument of
On Sat, Aug 11, 2012 at 12:01 PM, Antoine Latter aslat...@gmail.com wrote:
It should be pretty easy to write an adapter function of type String -
(Show a = a).
Not with that type. Give it a try.
Hint: what is the extension of the type variable 'a'? What do you know
about it? How would
Hi all,
it should be possible a call a function on all elements of the data
structure, to add and remove elements.
What I currently have:
the type class:
class Foo a where
hasId :: a - Int - Maybe a
a few instances:
data A = A deriving Show
instance Foo A where
hasId a 1 = Just
On Tue, Aug 7, 2012 at 2:03 PM, Daniel Trstenjak
daniel.trsten...@gmail.com wrote:
Data structure containing elements which are instances of the same type class
Are you looking for existential quantification [1]?
data SomeFoo = forall a. Foo a = a
[1]:
http://www.haskell.org/ghc/docs
Hi Joey,
On Tue, Aug 07, 2012 at 02:13:09PM -0400, Joey Adams wrote:
Are you looking for existential quantification [1]?
data SomeFoo = forall a. Foo a = a
[1]:
http://www.haskell.org/ghc/docs/latest/html/users_guide/data-type-extensions.html#existential-quantification
Thanks!
On Tue, Aug 7, 2012 at 11:03 AM, Daniel Trstenjak
daniel.trsten...@gmail.com wrote:
Hi all,
it should be possible a call a function on all elements of the data
structure, to add and remove elements.
What I currently have:
the type class:
class Foo a where
hasId :: a - Int - Maybe
be substituted for the place-holder-constructor. Does this restrict the type of equation that can be used in a type class? It seems that some equations respecting the constructor discipline are not allowed.Your intuition seems to be near the truth, although your terminology iscurrently wrong. Let's look
can be used). In the instance a real constructor can be substituted for the place-holder-constructor.Does this restrict the type of equation that can be used in a type class? It seems that some equations respecting the constructor discipline are not allowed.I appreciate that in Haskell the most
to define
functions (I assume other in-scope constructors can be used). In the
instance a real constructor can be substituted for the
place-holder-constructor. Does this restrict the type of equation
that can be used in a type class? It seems that some equations
respecting the constructor discipline
in type class.
Does the type class need two type variables?
How do I represent the constructors?
Can the equations be written in the type class rather than the instance?
-}
module QUEUE_SPEC where
data Queue e = New | Insert (Queue e) e deriving Show
isEmpty :: Queue e - Bool
isEmpty
On 22/07/12, Ertugrul Söylemez e...@ertes.de wrote:You are probably confusing the type class system with something fromOOP. A type class captures a pattern in the way a type is used. Thecorresponding concrete representation of that pattern is then written inthe instance definition: No really
I don't know whether this is really applicable but: isn't emptyStack in
Ertugrul last message some kind of constructor? You can add any kind of
special constructors as functions in the type class which return a new
queue. For example:
class Stack s where
newEmptyStack :: s a
newSingletonStack
add any kind of special constructors as functions in the type class which return a new queue. For example:
class Stack s where newEmptyStack :: s a newSingletonStack :: a - s a ...Why doesn't this fulfill you needs of specifying ways to construct new elements?
2012/7/23 Patrick Browne
to this concrete example.
What I was proposing, if you only need constructs, is that instead of
thinking of constructors, you may think of a factory pattern, similar to
that pattern in OOP: a function that creates the element for you. That
would be the newStack in your type class: every instance
Patrick,
-- Class with functional dependency
class QUEUE_SPEC_CLASS2 a q | q - a where
newC2 :: q a -- ??
sizeC2 :: q a - Int
restC2 :: q a - Maybe (q a)
insertC2 :: q a - a - q a
The above is a reasonable type class definition for what you seem to intend.
-- Without
:: q a - Maybe (q a) insertC2 :: q a - a - q aThe above is a reasonable type class definition for what you seem to intend. -- Without committing to some concrete representation such as list I do not know how to specify constructor for insertC2 ?? = ?? insertC2 newC2 a = newC2 -- wrong
Patrick Browne patrick.bro...@dit.ie wrote:
Thank you for your clear an detailed reply, the work on dependent
types seems to address my needs. However it is beyond my current
research question, which is quite narrow(see[1]). I merely wish to
identify the strengths and weakness of *current
{-Below is a *specification* of a queue. If possible I would like to write the equations in type class.Does the type class need two type variables? How do I represent the constructors?Can the equations be written in the type class rather than the instance?-}module QUEUE_SPEC wheredata Queue e
Patrick Browne patrick.bro...@dit.ie wrote:
{-
Below is a *specification* of a queue.
If possible I would like to write the equations in type class.
Does the type class need two type variables?
How do I represent the constructors?
Can the equations be written in the type class rather than
: {- Below is a *specification* of a queue. If possible I would like to write the equations in type class. Does the type class need two type variables? How do I represent the constructors? Can the equations be written in the type class rather than the instance? -}(Side note: When opening a new topic
are probably confusing the type class system with something from
OOP. A type class captures a pattern in the way a type is used. The
corresponding concrete representation of that pattern is then written in
the instance definition:
class Stacklike s where
emptyStack :: s a
push
#5913: Type class dictionary call loops at runtime
-+--
Reporter: mnislaih | Owner:
Type: bug | Status: new
Priority: normal
#5913: Type class dictionary call loops at runtime
-+--
Reporter: mnislaih | Owner:
Type: bug | Status: new
Priority: normal
#6117: Cyclic Type Class Hierarchy Produces loop
-+--
Reporter: jun0 | Owner:
Type: bug | Status: new
Priority
#6117: Cyclic Type Class Hierarchy Produces loop
-+--
Reporter: jun0 | Owner:
Type: bug | Status: new
Priority
#6117: Cyclic Type Class Hierarchy Produces loop
-+--
Reporter: jun0 | Owner:
Type: bug | Status: new
Priority: normal
#5913: Type class dictionary call loops at runtime
--+-
Reporter: mnislaih | Owner:
Type: bug | Status: new
Priority: normal
Hello!
Yes, classes of that variety exist in a few packages. This is a
particularly good treatment of it:
http://hackage.haskell.org/package/keys
Here are some classes from a very WIP implementation of a few
Commutative Replicated Data Types:
The Indexable class is declared as
class Lookup f = Indexable f where index :: f a - Key f - a
Why f must be instance of Lookup?
2012/4/12 Michael Sloan mgsl...@gmail.com
Hello!
Yes, classes of that variety exist in a few packages. This is a
particularly good treatment of it:
I think this is the result of a bit of a dilemma:
1) We want to express the fact that any Indexable thing also has a
straightforward definition for lookup.
2) Not all things supporting lookup support index, hence the direction
of the class hierarchy.
This is an ugly part of the default methods
#3108: Do a better job of solving recursive type-class constraints with
functional
dependencies
+---
Reporter: simonpj | Owner:
Type: bug
#3108: Do a better job of solving recursive type-class constraints with
functional
dependencies
+---
Reporter: simonpj| Owner:
Type: bug
#3108: Do a better job of solving recursive type-class constraints with
functional
dependencies
+---
Reporter: simonpj | Owner:
Type: bug
#3108: Do a better job of solving recursive type-class constraints with
functional
dependencies
+---
Reporter: simonpj | Owner:
Type: bug
#5913: Type class dictionary call loops at runtime
--+-
Reporter: mnislaih | Owner:
Type: bug | Status: new
Priority: normal
#5913: Type class dictionary call loops at runtime
--+-
Reporter: mnislaih | Owner:
Type: bug | Status: new
Priority: normal
On 1/9/12 7:54 AM, Luminous Fennell wrote:
On Mon, Jan 09 2012 at 10:37 +0100, Steve Horne wrote:
On 08/01/2012 21:13, Brandon Allbery wrote:
(Also, de facto I think it's already more or less been decided in
favor of type families, just because functional dependencies are (a)
a bit alien
On 08/01/2012 20:25, Brent Yorgey wrote:
On Fri, Jan 06, 2012 at 10:51:58AM +, Steve Horne wrote:
If I specify both extensions (-XMultiParamTypeClasses and
-XFlexibleInstances) it seems to work, but needing two language
extensions is a pretty strong hint that I'm doing it the wrong way.
On 08/01/2012 21:13, Brandon Allbery wrote:
(Also, de facto I think it's already more or less been decided in
favor of type families, just because functional dependencies are (a) a
bit alien [being a glob of Prolog-style logic language imported into
the middle of System Fc] and (b) [as I
Hi,
On Mon, Jan 09 2012 at 10:37 +0100, Steve Horne wrote:
On 08/01/2012 21:13, Brandon Allbery wrote:
(Also, de facto I think it's already more or less been decided in
favor of type families, just because functional dependencies are (a)
a bit alien [being a glob of Prolog-style logic
On Fri, Jan 06, 2012 at 10:51:58AM +, Steve Horne wrote:
If I specify both extensions (-XMultiParamTypeClasses and
-XFlexibleInstances) it seems to work, but needing two language
extensions is a pretty strong hint that I'm doing it the wrong way.
Not necessarily. These two extensions in
On Sun, Jan 8, 2012 at 9:25 PM, Brent Yorgey byor...@seas.upenn.edu wrote:
On Fri, Jan 06, 2012 at 10:51:58AM +, Steve Horne wrote:
If I specify both extensions (-XMultiParamTypeClasses and
-XFlexibleInstances) it seems to work, but needing two language
extensions is a pretty strong
On Sun, Jan 8, 2012 at 15:55, Christoph Breitkopf
chbreitk...@googlemail.com wrote:
On Sun, Jan 8, 2012 at 9:25 PM, Brent Yorgey byor...@seas.upenn.eduwrote:
On Fri, Jan 06, 2012 at 10:51:58AM +, Steve Horne wrote:
If I specify both extensions (-XMultiParamTypeClasses and
In an equation for `wbtData': wbtData (Branch d l r) = Just d
Failed, modules loaded: none.
Prelude
I've tried varying a number of details. Adding another parameter to the
type-class (for the item-data type) requires an extension, and even then
the instance is rejected because (I think) the tree-node
another parameter to the
type-class (for the item-data type) requires an extension, and even then
the instance is rejected because (I think) the tree-node and item-data
types aren't independent.
Did you try something like
{-# LANGUAGE MultiParamTypeClasses #-}
class WalkableBinTree n d where
not sure what to make of that. Even if the result of wbtData is
always Nothing, surely it still has a static type?
I've tried varying a number of details. Adding another parameter to the
type-class (for the item-data type) requires an extension, and even then
the instance is rejected because (I think
WalkableBinTree take a type constructor of kind (* - *)
like this:
class WalkableBinTree t where
wbtChildren :: t x - (t x, t x)
wbtData :: t x - Maybe x
instance WalkableBinTree BT where ...
Of course, you loose flexibility compared to the multi param approach,
e.g. you couldn't add type
-cafe@haskell.org
Subject: Re: [Haskell-cafe] Simple type-class experiment turns out not so
simple...
On 06/01/2012 10:29, Steffen Schuldenzucker wrote:
With 'd' not being mentioned anywhere, the signature of wbtData means
forall d. n - Maybe d. In particular, wbtData == const Nothing
various kinds of these data structures I defined a type
class for common operations on such data structures.
class DepSequence l where
nil :: l a a
app :: l a b - l b c - l a c
The instance for AltList is as follows:
instance DepSequence AltList where
nil = Nil
Nil `app` k = k
structures I defined a type class
for common operations on such data structures.
class DepSequence l where
nil :: l a a
app :: l a b - l b c - l a c
The instance for AltList is as follows:
instance DepSequence AltList where
nil = Nil
Nil `app` k = k
ICons i l `app` k = ICons
AltList :: * - * - * where
Nil :: AltList a a
ICons :: Int - AltList Int b - AltList () b
UCons :: () - AltList () b - AltList Int b
Since I have various kinds of these data structures I defined a type class
for common operations on such data structures.
class DepSequence l where
nil
:: () - AltList () b - AltList Int b
Since I have various kinds of these data structures I defined a type class for
common operations on such data structures.
class DepSequence l where
nil :: l a a
app :: l a b - l b c - l a c
The instance for AltList is as follows:
instance DepSequence
#5691: Crash: strange interaction of ScopedTypeVariables extension with type
class
name resolution
--+-
Reporter: dominiquedevriese| Owner:
Type: bug
#5691: Crash: strange interaction of ScopedTypeVariables extension with type
class
name resolution
+---
Reporter: dominiquedevriese | Owner:
Type: bug
#5691: Crash: strange interaction of ScopedTypeVariables extension with type
class
name resolution
+---
Reporter: dominiquedevriese | Owner:
Type: bug
likely than implementation packages to
break when the GHC version changes.
Aside: The problem with collections is that we don't have the programming
language means to do this well yet (although soon!). The issue is that we
want to declare a type class where the context of the methods depends
On 3 November 2011 14:56, Ryan Newton rrnew...@gmail.com wrote:
Aside: The problem with collections is that we don't have the programming
language means to do this well yet (although soon!). The issue is that we
want to declare a type class where the context of the methods depends
probably go a long way towards taming the type class wilderness.
People have mentioned this problem before with respect to Collections
generally.
One basic part of reaching such a goal is separating interface from
implementation. I ran into the following problems just in the last 24
hours. In both
could agree as a community on common interfaces to use for some basics,
that would probably go a long way towards taming the type class wilderness.
People have mentioned this problem before with respect to Collections
generally.
Aside: The problem with collections is that we don't have
typeclasses a type is a
member of, use :info.
On 12/08/2011 23:52, Patrick Browne wrote:
Hi,
Why does the Haskell :type command only sometimes print the type-class?
Should I expect type-class inference as well as type inference?
Maybe the type-class is inferred where possible, but not always
1 - 100 of 535 matches
Mail list logo