Arlen Cuss cel...@sairyx.org writes:
import Data.Either
type (:|:) a b = Either a b
(???) = either
foo :: (Int :|: Bool :|: String :|: Double) - Int
foo =
\ i - i + 7 ???
\ b - if b then 1 else 0 ???
\ s - length s ???
\ d - floor d
INFIX TYPE OPERATORS!!??!
Why not just do what we do for tuples? Define a bunch of generic types up front:
data Choice2 a b = OneOf2 a | TwoOf2 b
data Choice3 a b c = OneOf3 a | TwoOf3 b | ThreeOf3 cThe module Text.XML.HaXml.OneOfN defines these types up to size 20.The package HaXml also comes with a small command-line
On 6/21/11 10:48 PM, Casey McCann wrote:
On Tue, Jun 21, 2011 at 9:51 PM, wren ng thorntonw...@freegeek.org
wrote:
I don't think there are any problems[1].
(...)
[1] modulo the A:+:A ~ A issue.
Oops, I should've said A:*:A there.
That issue is exactly my concern, though, and it seems a bit
On Jun 22, 2:19 pm, wren ng thornton w...@freegeek.org wrote:
In contrast, ordered pairs and disjoint unions are tidy, simple, and
obvious.
Disjoint pairs are sufficient; they needn't be ordered. All we need is
that they are tagged in the same way that disjoint unions are, so that
we can
On Wed, Jun 22, 2011 at 1:25 PM, pipoca eliyahu.ben.mi...@gmail.com wrote:
Also, I don't think that the formulation of (:|:) above is
sufficient. Suppose:
foo :: Foo - Bar
baz :: Baz - Quux
foobaz :: [Foo :|: Baz]
-- map foo and baz over foobaz
barquux :: [Bar :|: Quux]
barquux = map
On Wed, Jun 22, 2011 at 2:19 PM, wren ng thornton w...@freegeek.org wrote:
[1] modulo the A:+:A ~ A issue.
Oops, I should've said A:*:A there.
That issue is exactly my concern, though, and it seems a bit too
thorny to handwave aside.
Indeed. If we have A:*:A ~ A, then A:*:A is not a
On Wed, Jun 22, 2011 at 5:00 PM, Alexander Solla alex.so...@gmail.com wrote:
You're building up (Either a b) into a monoidal category. There used to be
a package called category-extras for this kind of stuff. I think it has
been broken up. Does anybody know the status of its replacement(s)?
On Wed, Jun 22, 2011 at 1:25 PM, pipoca eliyahu.ben.mi...@gmail.com wrote:
Is there any reason why we don't have either anonymous disjoint union
types, or why some of the proposals here (e.g. type (:|:) a b = Either
a b ) haven't been implemented, or put into the standard libraries
(and
On 6/22/11 6:00 PM, Casey McCann wrote:
On Wed, Jun 22, 2011 at 2:19 PM, wren ng thorntonw...@freegeek.org
wrote:
[1] modulo the A:+:A ~ A issue.
Oops, I should've said A:*:A there.
That issue is exactly my concern, though, and it seems a bit too
thorny to handwave aside.
Indeed. If we
A tuple is basically an anonymous product type. It's convenient to not have
to spend the time making a named product type, because product types are so
obviously useful.
Is there any reason why Haskell doesn't have anonymous sum types? If there
isn't some theoretical problem, is there any
On 21 Jun 2011, at 20:53, Elliot Stern wrote:
A tuple is basically an anonymous product type. It's convenient to not have
to spend the time making a named product type, because product types are so
obviously useful.
Is there any reason why Haskell doesn't have anonymous sum types? If
On Tue, Jun 21, 2011 at 12:53 PM, Elliot Stern
eliyahu.ben.mi...@gmail.comwrote:
A tuple is basically an anonymous product type. It's convenient to not
have to spend the time making a named product type, because product types
are so obviously useful.
Tuples are not so anonymous. Although
On Jun 21, 4:15 pm, Alexander Solla alex.so...@gmail.com wrote:
The problem is that a sum type must name the different types, or else it
can't give access to them. How is a function supposed to know if a value
blah :: A :+: B
is an A or a B? It seems possible that it could figure it out,
On Jun 21, 2011, at 4:02 PM, Malcolm Wallace wrote:
On 21 Jun 2011, at 20:53, Elliot Stern wrote:
A tuple is basically an anonymous product type. It's convenient to
not have to spend the time making a named product type, because
product types are so obviously useful.
Is there any reason
On 22.06.2011 00:32, pipoca wrote:
On Jun 21, 4:15 pm, Alexander Sollaalex.so...@gmail.com wrote:
The problem is that a sum type must name the different types, or else it
can't give access to them. How is a function supposed to know if a value
blah :: A :+: B
is an A or a B? It seems
On Jun 21, 4:57 pm, Alexey Khudyakov alexey.sklad...@gmail.com
wrote:
Types may be same.
oops :: Int :+: Int - Int
oops Int i = mmm which one?
If you were to have your anonymous sum types be a union instead of the
disjoint union, then you could say that A :+: A has no meaning.
That's what I
On Tue, Jun 21, 2011 at 1:36 PM, Matthew Steele mdste...@alum.mit.eduwrote:
On Jun 21, 2011, at 4:02 PM, Malcolm Wallace wrote:
On 21 Jun 2011, at 20:53, Elliot Stern wrote:
A tuple is basically an anonymous product type. It's convenient to not
have to spend the time making a named
On Tue, Jun 21, 2011 at 3:36 PM, Matthew Steele mdste...@alum.mit.edu wrote:
On Jun 21, 2011, at 4:02 PM, Malcolm Wallace wrote:
On 21 Jun 2011, at 20:53, Elliot Stern wrote:
A tuple is basically an anonymous product type. It's convenient to not
have to spend the time making a named product
On Tue, Jun 21, 2011 at 5:24 PM, pipoca eliyahu.ben.mi...@gmail.com wrote:
If you were to have your anonymous sum types be a union instead of the
disjoint union, then you could say that A :+: A has no meaning.
That's what I was originally thinking of when I suggested that
syntax. However, as
On Tue, Jun 21, 2011 at 1:36 PM, Matthew Steele mdste...@alum.mit.eduwrote:
Yes, Either is to sum types what (,) is to product types. The difference
is that there is no anonymous sum type equivalent to (,,) and (,,,) and
() and so on, which I think is what the original question is getting
On Tue, Jun 21, 2011 at 2:24 PM, pipoca eliyahu.ben.mi...@gmail.com wrote:
On Jun 21, 4:57 pm, Alexey Khudyakov alexey.sklad...@gmail.com
wrote:
Types may be same.
oops :: Int :+: Int - Int
oops Int i = mmm which one?
If you were to have your anonymous sum types be a union instead of
import Data.Either
type (:|:) a b = Either a b
(???) = either
foo :: (Int :|: Bool :|: String :|: Double) - Int
foo =
\ i - i + 7 ???
\ b - if b then 1 else 0 ???
\ s - length s ???
\ d - floor d
INFIX TYPE OPERATORS!!??!
On 6/21/11 6:54 PM, Casey McCann wrote:
That said, I don't think either retains the tidy algebraic properties
that disjoint unions and tuples have, so I'm not sure if calling them
sums and products is actually correct.
I don't think there are any problems[1]. Categorically speaking, a product
On Tue, Jun 21, 2011 at 9:51 PM, wren ng thornton w...@freegeek.org wrote:
I don't think there are any problems[1].
(...)
[1] modulo the A:+:A ~ A issue.
That issue is exactly my concern, though, and it seems a bit too
thorny to handwave aside. For instance, doesn't this also cause
problems for
24 matches
Mail list logo