Re: [Haskell-cafe] Associated types for number coercion

2013-03-19 Thread Conrad Parker
On 20 March 2013 06:58, Christopher Done wrote: > From the paper Fun with Type Funs, it's said: > >> One compelling use of such type functions is to make type >> coercions implicit, especially in arithmetic. Suppose we want to be able to >> write add a b to add two numeric values a and b even if o

Re: [Haskell-cafe] Associated types for number coercion

2013-03-19 Thread Christopher Done
(But I get annoyed about having to convert between five string types (String, Text, lazy Text, ByteString, lazy ByteString), so maybe I'm just generally more bothered by the whole “not being able to just write the program” than others.) On 20 March 2013 00:22, Christopher Done wrote: > On 20 Marc

Re: [Haskell-cafe] Associated types for number coercion

2013-03-19 Thread Christopher Done
On 20 March 2013 00:05, Johan Tibell wrote: > I prefer the current way (which is interestingly what Go chose as well). > With implicit casts it's easy to shoot yourself in the foot e.g. when doing > bit-twiddling. I don't think it's an either-or case, though, is it? I would use the magic implicit

Re: [Haskell-cafe] Associated types for number coercion

2013-03-19 Thread Johan Tibell
On Tue, Mar 19, 2013 at 3:58 PM, Christopher Done wrote: > From the paper Fun with Type Funs, it's said: > > > One compelling use of such type functions is to make type > > coercions implicit, especially in arithmetic. Suppose we want to be able > to > > write add a b to add two numeric values a a

Re: [Haskell-cafe] Associated types

2010-07-01 Thread Ivan Miljenovic
On 2 July 2010 04:48, David Menendez wrote: > Maybe you're thinking of equality superclasses. In another thread, > this example came up: > > | class (DerivedOf a ~ derived) => Typecheck a derived where > > which doesn't work yet, but should work in 6.14. I've asked Manuel Chakravarty about this,

Re: [Haskell-cafe] Associated types

2010-07-01 Thread Edward Kmett
On Thu, Jul 1, 2010 at 2:26 PM, Christopher Lane Hinson < l...@downstairspeople.org> wrote: > class (Path p, CompletePath (CompletedPath p)) => IncompletePath p where >> type CompletedPath p :: * >> > > AIUI, this isn't implemented yet. You'll have to place the constraint on > each > involved fun

Re: [Haskell-cafe] Associated types

2010-07-01 Thread David Menendez
On Thu, Jul 1, 2010 at 2:35 PM, Christopher Lane Hinson wrote: > On Thu, 1 Jul 2010, Christopher Lane Hinson wrote: > >> >>> Something like this should work: >>> >>> class (Path p, CompletePath (CompletedPath p)) => IncompletePath p where >>>   type CompletedPath p :: * >>> >> >> AIUI, this isn't

Re: [Haskell-cafe] Associated types

2010-07-01 Thread Miguel Mitrofanov
GADTs? data CompletePathEv p where CompletePathEv :: CompletePath p => CompletePathEv p class Path p => IncompletePath p where type CompletedPath p :: * completedPathEv :: CompletePathEv (CompletedPath p) Later you can pattern-match on completedPathEv and get your CompletePath inst

Re: [Haskell-cafe] Associated types

2010-07-01 Thread Christopher Lane Hinson
On Thu, 1 Jul 2010, Christopher Lane Hinson wrote: Something like this should work: class (Path p, CompletePath (CompletedPath p)) => IncompletePath p where type CompletedPath p :: * AIUI, this isn't implemented yet. You'll have to place the constraint on each involved function. Fri

Re: [Haskell-cafe] Associated types

2010-07-01 Thread Christopher Lane Hinson
Something like this should work: class (Path p, CompletePath (CompletedPath p)) => IncompletePath p where type CompletedPath p :: * AIUI, this isn't implemented yet. You'll have to place the constraint on each involved function. Friendly, --Lane _

Re: [Haskell-cafe] Associated types

2010-07-01 Thread Andrew Coppin
David Menendez wrote: Something like this should work: class (Path p, CompletePath (CompletedPath p)) => IncompletePath p where type CompletedPath p :: * Oh, you can do that? (I.e., mention the CompletedPath function before you've defined it.) Sweet... ___

Re: [Haskell-cafe] Associated types

2010-07-01 Thread David Menendez
On Thu, Jul 1, 2010 at 2:09 PM, Andrew Coppin wrote: > Consider the following: > >  class Path p where ... > >  class Path p => CompletePath p where ... > >  class Path p => IncompletePath p where >   type CompletedPath p :: * > > Obviously, the idea is that CompletedPath Foo (where Foo is an > In

[Haskell-cafe] Associated types

2010-07-01 Thread Andrew Coppin
Consider the following: class Path p where ... class Path p => CompletePath p where ... class Path p => IncompletePath p where type CompletedPath p :: * Obviously, the idea is that CompletedPath Foo (where Foo is an IncompletePath) should yield some type which is a CompletePath. However

Re: [Haskell-cafe] Associated Types and several Classes

2008-10-13 Thread Martin Hofmann
Hi Ryan. Thanks a lot, that was exactly the information I needed. Concerning the type classes, there are methods, but I dropped them, because they were not necessary for the problem. However, you are right. Implementation hiding is what I need. One suggestion. Maybe a HaskellWiki page on design

Re: [Haskell-cafe] Associated Types and several Classes

2008-10-13 Thread Ryan Ingram
First, a comment. I don't understand why you have so many classes! What proof invariants are they helping you enforce? Do you really a constraint that says that something is a "Rule"? Are you going to write functions that are polymorphic over CRule? How can you do so when CRule has no methods?

[Haskell-cafe] Associated Types and several Classes

2008-10-13 Thread Martin Hofmann
> {-# OPTIONS_GHC -fglasgow-exts #-} > module Test where >import qualified Data.Set as S Hi. I try to model the following: Hypotheses are build up from Rules, which itself are made of the type Rule. Because I may change the implementation later, I want to use type classes, which define the signa

[Haskell-cafe] Associated types and data constructors (was: the MPTC Dilemma (please solve))

2006-03-19 Thread David Menendez
(I've moved this from haskell' to haskell-cafe, because it's more a question about associated types than about resolving the MPTC dilemma.) Bulat Ziganshin writes: > Hello Manuel, > > MMTC> My statement remains: Why use a relational notation if you can > MMTC> have a functional one? > > how ab