Re: [Haskell-cafe] Wrong kind when attempting to build a monad for a circular list of functions

2008-02-28 Thread Bas van Dijk
On Thu, Feb 28, 2008 at 8:28 AM, Aaron Altman [EMAIL PROTECTED] wrote:
  I am working on an AI agent that will perform a finite series of actions
  before starting the sequence over again.  I figured a circular list of
  functions that shifts as you apply them would be the way to do it...

I think a better representation of a finite series of actions is a
'Monad m = [m a]' because your AI agent will likely do some side
effects when it's executing. Then if you also want to thread some
state through the actions you should have a 'Monad m = [a - m a]':
(Another idea is to use MonadState)

import Control.Monad

walk :: (Monad m) = [a - m a] - a - m a
walk = foldr (=) return

always :: (Monad m) = (a - m a) - a - m b
always f z = f z = always f

ai :: (Monad m) = a - [a - m a] - m a
ai z f = always (walk f) z

example = ai 0 [ \x - print x  return x
   , \x - if x  10
   then fail the end
   else return (x+1)
   ]

regards,

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


Re: [Haskell-cafe] Wrong kind when attempting to build a monad for a circular list of functions

2008-02-28 Thread Felipe Lessa
On Thu, Feb 28, 2008 at 4:28 AM, Aaron Altman [EMAIL PROTECTED] wrote:
  runActionAndIterate :: [a - a] - a - (a, [a - a])
  runActionAndIterate (currentAction:actionList) actionInput =
  (currentAction actionInput, concat [actionList, [currentAction]])

  shiftActionList :: [a - a] - [a - a]
  shiftActionList (currentHead:rest) = concat [rest, [currentHead]]

As a side note, it's not good to recreate the list (using 'concat')
for every item as it is an O(n) operation. Bas van Dijk's 'always'
(also called 'forever'[1]) is an option, but you can also create a
circular list using the simple function 'cycle'[2] and your functions
above would become

runActionAndIterate (currentAction:actionList) actionInput =
  (currentAction actionInput, actionList)

shiftActionList = tail

[1] 
http://haskell.org/ghc/docs/latest/html/libraries/base/Control-Monad.html#v%3Aforever
[2] 
http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v%3Acycle

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


Re: [Haskell-cafe] Wrong kind when attempting to build a monad for a circular list of functions

2008-02-28 Thread Felipe Lessa
On Thu, Feb 28, 2008 at 8:15 AM, Roel van Dijk [EMAIL PROTECTED] wrote:
 I'm nitpicking but,

Not a nitpick, a great difference =). As someone else already said on
this list, it's not good to answer e-mails in the early morning heh.

Thanks,

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


Re: [Haskell-cafe] Wrong kind when attempting to build a monad for a circular list of functions

2008-02-28 Thread Roel van Dijk
I'm nitpicking but,

On Thu, Feb 28, 2008 at 11:44 AM, Felipe Lessa [EMAIL PROTECTED] wrote:
 Bas van Dijk's 'always' (also called 'forever'[1])

forever a  = a  forever a
always f z = f z = always f

Forever doesn't pass the result of the action to its recursive call,
always does.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Wrong kind when attempting to build a monad for a circular list of functions

2008-02-28 Thread Felipe Lessa
On Thu, Feb 28, 2008 at 7:44 AM, Felipe Lessa [EMAIL PROTECTED] wrote:
  Bas van Dijk's 'always' (also called 'forever'[1])

Sorry, of course

always' :: Monad m = (a - m a) - (a - m ())
forever :: Monad m = (m a) - (m ())

are of different types and so are different functions.

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


[Haskell-cafe] cabal errors

2008-02-28 Thread Kristofer Buffington
Hi

I installed ghc 6.8 from source and I've been installing packages from
hackage. I'm not sure when the problem started, but I've been getting this
error trying to install any cabal package.. accept apparently, Cabal itself.

Setup.hs:2:0:
Warning: Deprecated use of `defaultUserHooks'
 (imported from Distribution.Simple):
 Use simpleUserHooks or autoconfUserHooks
Setup: /usr/local/lib/Cabal-1.3.6/ghc-6.8.2.20080225/HSCabal-1.3.6.o:
unknown symbol `directoryzm1zi0zi0zi0_SystemziDirectory_a9_closure'
Setup: exception :: GhcException

Any ideas?
-- 

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


Re: [Haskell-cafe] Bay Area talk tomorrow, on concurrent/parallel Haskell

2008-02-28 Thread donnie Jones
Hello,

I wish I could be there, but I'm in Kentucky.  ;)
It would be great if someone could have this talk recorded and posted on
youtube, or something similar.

Thank you.
__
Donnie

On 2/27/08, Bryan O'Sullivan [EMAIL PROTECTED] wrote:

 Satnam Singh of Microsoft Research will be speaking about concurrent
 and parallel programming at Stanford tomorrow.

 Details here:


 http://www.realworldhaskell.org/blog/2008/02/28/stanford-haskell-talk-2008-02-28/

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

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


Re: [Haskell-cafe] Bay Area talk tomorrow, on concurrent/parallel Haskell

2008-02-28 Thread PR Stanley

At 13:23 28/02/2008, you wrote:

Hello,

I wish I could be there, but I'm in Kentucky.  ;)
It would be great if someone could have this talk recorded and 
posted on youtube, or something similar.


Thank you.
Now, there's an idea which could be extended to all Haskell related 
gatherings.





__
Donnie

On 2/27/08, Bryan O'Sullivan 
mailto:[EMAIL PROTECTED][EMAIL PROTECTED] wrote:

Satnam Singh of Microsoft Research will be speaking about concurrent
and parallel programming at Stanford tomorrow.

Details here:

http://www.realworldhaskell.org/blog/2008/02/28/stanford-haskell-talk-2008-02-28/http://www.realworldhaskell.org/blog/2008/02/28/stanford-haskell-talk-2008-02-28/

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


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


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


[Haskell-cafe] ANNOUNCE: parameterized-data 0.1 - Parameterized data library implementing lightweight dependent types

2008-02-28 Thread Alfonso Acosta
 This library provides an implementation of parameterized types using
type-level computations to implement the type parameters and emulate
dependent types.

 Right now only fixed-sized vectors are provided (based on Oleg's
Number-parameterized types [1]  and Frederik Eaton's Vectro library
[2])

HackageDB page:
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/parameterized-data-0.1

Darcs repository: http://code.haskell.org/parameterized-data/

Again, big thanks to Oleg and Wolfgang for their help and suggestions.

[1] http://okmij.org/ftp/Haskell/number-parameterized-types.html
[2] http://ofb.net/~frederik/vectro/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] to stimulate discussion concerning where Haskell is going .. ...

2008-02-28 Thread Galchin Vasili
1) Berkeley consternation about the inability of current concurrency to keep
up with multicor developments
1)
http://www.eetimes.com/news/latest/showArticle.jhtml;jsessionid=CWDB5YTIKPC4QQSNDLPSKH0CJUNN2JVN?articleID=206801376pgno=2printable=true


http://www.eetimes.com/news/latest/showArticle.jhtml;?articleID=206801229

IMO a gauntlet has been thrown down to the Haskell world here.


2) Sun Microsystem's planned support of hardware transactional memory
  http://www.theregister.co.uk/2007/08/21/sun_transactional_memory_rock/


 I have fished around and collected some Sun papers and slides. If any
anybody wants I can post the URLs or send to the interested

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


Re: [Haskell-cafe] to stimulate discussion concerning where Haskell is going .. ...

2008-02-28 Thread donnie Jones
Hello Vasys,

I am quite interested in concurrency and Haskell.
I appreciate your effort, and I would like the URLs, if you don't mind.

Can you elaborate on your statement IMO a gauntlet has been thrown down to
the Haskell world here.?  Are you implying that this is an opportunity for
Haskell and concurrency?  Or, that Haskell is going to be passed by?

Thank you.
__
Donnie

On 2/28/08, Galchin Vasili [EMAIL PROTECTED] wrote:


 1) Berkeley consternation about the inability of current concurrency to
 keep up with multicor developments
 1)
 http://www.eetimes.com/news/latest/showArticle.jhtml;jsessionid=CWDB5YTIKPC4QQSNDLPSKH0CJUNN2JVN?articleID=206801376pgno=2printable=true


 http://www.eetimes.com/news/latest/showArticle.jhtml;?articleID=206801229

 IMO a gauntlet has been thrown down to the Haskell world here.


 2) Sun Microsystem's planned support of hardware transactional memory

 http://www.theregister.co.uk/2007/08/21/sun_transactional_memory_rock/

  I have fished around and collected some Sun papers and slides. If any
 anybody wants I can post the URLs or send to the interested

 Regards, Vasys

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


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


[Haskell-cafe] ArrowChoice for simulation arrow (Sim)

2008-02-28 Thread Steve Lihn
Hi,
In John Hughes\' paper \Programming with arrows\ [1] Section 5, the
simulation arrow is defined (Sim). All the examples went well.
However, when I want to use it beyond circuit simulation and I added a
\if-then-else\ line, GHC is asking to define ArrowChoice for Sim.

Does anybody have the ArrowChoice definition for Sim ?

Thanks,
Steve

[1] http://www.cs.chalmers.se/~rjmh/afp-arrows.pdf
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] ANN: Hoogle 3.1

2008-02-28 Thread Dan Weston

I have a question about the ranking algorithm of Hoogle 3.1:

The top match of hoogle (a - b) - b is the inexact match

Control.Monad.State.Class.gets :: MonadState s m = (s - a) - m a

(which cannot be made to unify with (a - b) - b) instead of

Control.Monad.Cont.runCont (undefined :: Cont r a) :: (a - r) - r

which does. I would have thought all exact matches would come first 
(after considering all partial applications), especially as the increase 
in complexity is at most a small constant factor (~ 2 or 3) for 
considering all possible partial applications (type tails) of known 
library functions.


Dan

Neil Mitchell wrote:

Hi,

I am pleased to announce Hoogle 3.1. Hoogle is a search engine for
Haskell functions, that allows the user to search by name or
approximate type signature. Hoogle can be used without installing
anything, by simply visiting the online interface, or can be installed
locally.

* Online interface: http://www.haskell.org/hoogle/
* Cabal release:
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hoogle-3.1

The Cabal release contains a command line version of the Hoogle tool,
which you can install with the standard Cabal commands.

Hoogle 3.1 has a number of new features.

Command line version:

* A proper cabal release, including proper installing of the search database.
* cabal-install compatible
* No longer requires haskell-source-extensions (trhsx) to be installed

Web interface:

* Better entity escaping in some bits of the web interface
* Keyword links work again
* Lambdabot suggestions work
* Update to the most recent version of base
* Security fixes, specifically possible code injection bugs
(http://en.wikipedia.org/wiki/Code_injection) - none of which were
ever exploited, or could have been exploited (as far as I can tell)

I intend to write a more detailed account of the security fixes in a
blog post, which will be available from http://planet.haskell.org/ .
Running a custom version of the web interface is not really supported,
but if you are, please upgrade to the latest darcs version.

There are still several known bugs in the Hoogle 3.1 release, but
these are more difficult to fix, and will probably be solved in a
forthcoming Hoogle 4.0.

Thanks

Neil
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell





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


[Haskell-cafe] Re: ANN: Hoogle 3.1

2008-02-28 Thread Neil Mitchell
Hi

  The top match of hoogle (a - b) - b is the inexact match

  Control.Monad.State.Class.gets :: MonadState s m = (s - a) - m a

  (which cannot be made to unify with (a - b) - b) instead of

  Control.Monad.Cont.runCont (undefined :: Cont r a) :: (a - r) - r

  which does.

What if the type of gets was :: (s - a) - m a? Would you then think
it was the right choice of ordering? In runCont you are effectively
deleting an argument to get equality, in gets you are simply unifying
a and m a. Since m a is just wrapped in a container (monad in this
case), its entirely feasible the person wanted the monadic version.

The reason Hoogle sees gets without the type class is because
MonadState is a multi-parameter type class, and hence not Haskell 98.
Hoogle simply ignores all MPTC's while doing matching. This will be
fixed in Hoogle 4.

Thanks

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


[Haskell-cafe] Error I haven't seen before

2008-02-28 Thread Jefferson Heard
I'm getting this error when I try to render the text contained in a record
structure in the Protein module.  Does this mean that the thunk that could
calculate go_terms is being evaluated for the first time in the program?
go_terms is calculated by a Data.Map.! lookup operation.

Main: No match in record selector Protein.go_terms
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] ANNOUNCE: Sessions 2008 2 28 - RFC

2008-02-28 Thread Matthew Sackman
Hi,

So for those of you that watch the hackage what's-new page, you will
probably be aware of this. For the last few months, there's been
significant work on my implementation of Session Types in Haskell.[0]

The reason for this particular announcement is that it should now be at
a point where functionality is verging on useful. There are a few things
that are still missing which should appear over the next few weeks but
if you're at all interested in message-passing as a tool in the box for
dealing with concurrency, I'd love to know what you think.

To that end, I would *not* encourage you to try to look at the
implementation too closely as you may suddenly discover a powerful urge
to stick knives in your eyes and/or eat your computer. However, the
Tests.hs[1] file should give you a good idea of the kinds of things that
are possible and they do cover all the functionality currently
implemented. Note that ghci may well take about 5 mins to type check
Tests.hs. Or longer if you're still running a BBC B Micro.

I would almost certainly not advise anyone to look at the haddock[2]. I
really can't quite believe how horrible the type sigs end up looking
under haddock. Some of my comments may almost pass the barrier of being
useful. Nicely formatted type sigs exist in the source.

If however, you are as mad as I, and enjoy pushing the GHC type system
to the limit, then you may enjoy looking at the implementation in all
its glory. base10 numbers, lists, associative maps and a whole lot of
other madness works correctly at the type-level in ghc 6.8.2.

Anyway, as the subject says, comments gratefully received.

[0] 
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/sessions-2008.2.28
[1] 
http://wellquite.org/non-blog/sessions-browseable/Control/Concurrent/Session/Tests.hs
[2] http://wellquite.org/non-blog/sessions-browseable/doc/html/sessions/
[3] http://wellquite.org/non-blog/sessions-browseable/

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


Re: [Haskell-cafe] Best practice for embedding files in a GHC-compiled tool?

2008-02-28 Thread Alfonso Acosta
A bit late, sorry, but you could use this:

http://www.wellquite.org/hinstaller/

On Thu, Feb 7, 2008 at 5:29 AM, Dave Bayer [EMAIL PROTECTED] wrote:
 What is the best way to embed an arbitrary file in a Haskell program?

  I would like to use GHC to compile command-line tools to be used with
  OS X. I want the tool to be a single file, not a package or a
  directory, that makes no assumptions about what else is present. For
  example, it should be able to run as part of an OS X install disk.

  I want this tool to be self reproducing in the sense that one of its
  options causes it to output its own documentation and source code. I
  want this data to be stored as a compressed file within the tool
  binary itself.

  The distribution model I'm imagining here is where one writes a
  program anonymously, that isn't hosted anywhere but is passed from
  user to user because it is useful, and eventually reaches another user
  who wants to modify the code. Assume that intermediate users will care
  less about this, and will try to delete anything that they can. That
  rules out storing the data in a separate file. Think of the M.I.T.
  game Core Wars from the dawn of the computer age. I'm looking for a
  strategy here that will be evolutionarily successful in a fairly
  hostile environment.

  In other words, I want to be able to write in Haskell, without losing
  the automatic distribution of source code enjoyed by interpreted
  languages. No one deletes the source code for a Perl script, because
  by doing so they're killing the program.

  There must be some library I'm overlooking that would make this very
  easy. All I can think of is to use Template Haskell to read a
  compressed tar file into a Haskell variable. Is that what one does, or
  is there a better way?

  Thanks in advance,
  Dave

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

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


Re: [Haskell-cafe] ANNOUNCE: Sessions 2008 2 28 - RFC

2008-02-28 Thread Alfonso Acosta
On Thu, Feb 28, 2008 at 11:23 PM, Matthew Sackman [EMAIL PROTECTED] wrote:
  If however, you are as mad as I, and enjoy pushing the GHC type system
  to the limit, then you may enjoy looking at the implementation in all
  its glory. base10 numbers, lists, associative maps and a whole lot of
  other madness works correctly at the type-level in ghc 6.8.2.

Only if I had known before before 

I recently released a library, type-level [1],  which implements
type-level base10 numbers and Booleans. I could have reused your
implementation but didn't know about it ...

The plan is to include a common type-level implementation to avoid
reinventing the wheel all the time. I'm still know if people will find
it useful but if they do I could include your implementation of lists
and maps. What do you think?

[1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/type-level-0.1
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: ANN: Hoogle 3.1

2008-02-28 Thread Steve Lihn
Neil,
Would you consider adding auto-complete feature on Hoogle in the forth
coming release?

http://wiki.script.aculo.us/scriptaculous/show/Ajax.Autocompleter
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: ANN: Hoogle 3.1

2008-02-28 Thread Neil Mitchell
Hi Steve,

  Would you consider adding auto-complete feature on Hoogle in the forth
  coming release?

  http://wiki.script.aculo.us/scriptaculous/show/Ajax.Autocompleter

I am slightly hoping that I'll be able to remove the Search button
entirely, and just have results as you type. Whether that becomes
feasible depends on how quickly the Hoogle search works, at the moment
its way too slow, but the next version has clever data structures etc.
which should make it fast enough, at least for text searches.

Thanks

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


[Haskell-cafe] Wadler's blog post on the expression problem

2008-02-28 Thread Ryan Ingram
I was reading Philip Wadler's post regarding the expression problem
and Wouter Swierstra's paper, Data Types a la Carte.

Philip asks: The instances of the injection function for subtypes are
assymmetric.  Is there a symmetric solution in Haskell?

Here is a solution which works under GHC 6.8.2, heavily inspired by
the HList type computation work, available from
http://www.okmij.org/ftp/Haskell/types.html#HList

There are three keys to this trick, each of which builds on the previous.
1) TypEq: for any two types a, b, there is an instance for TypEq a b
HTrue if and only if a == b, and there is an instance for TypEq a b
HFalse otherwise.
2) This allows the definition of IsTreeMember which gives HTrue if a
type occurs somewhere within a tree and otherwise HFalse.
3) We can then use IsTreeMember as a predicate to determine whether to
use the left branch or right branch of a (:+:) constructor.

Source code follows:

{-# OPTIONS_GHC -fglasgow-exts -fallow-undecidable-instances
-fallow-overlapping-instances #-}
module Expr where

newtype Expr f = In (f (Expr f))

instance Show (f (Expr f)) = Show (Expr f) where
showsPrec _ (In x) = showParen True (showString In  . showsPrec 11 x)

out :: Expr f - f (Expr f)
out (In x) = x

data (f :+: g) e = Inl (f e) | Inr (g e) deriving Show

instance (Functor f, Functor g) = Functor (f :+: g) where
   fmap h (Inl f) = Inl (fmap h f)
   fmap h (Inr g) = Inr (fmap h g)

class (Functor sub, Functor sup) = (::) sub sup where
   inj :: sub a - sup a

instance TypTree sub sup = (::) sub sup where inj = treeInj

data Val e = Val Int deriving Show
data Add e = Add e e deriving Show
data Mul e = Mul e e deriving Show

instance Functor Val where
fmap f (Val x) = Val x
instance Functor Add where
fmap f (Add l r) = Add (f l) (f r)
instance Functor Mul where
fmap f (Mul l r) = Mul (f l) (f r)

foldExpr :: Functor f = (f a - a) - Expr f - a
foldExpr f (In t) = f (fmap (foldExpr f) t)

class Functor f = Eval f where
evalA :: f Int - Int

instance Eval Val where
evalA (Val x) = x
instance Eval Add where
evalA (Add x y) = x + y
instance Eval Mul where
evalA (Mul x y) = x * y

instance (Eval f, Eval g) = Eval (f :+: g) where
evalA (Inl f) = evalA f
evalA (Inr g) = evalA g

eval :: Eval f = Expr f - Int
eval expr = foldExpr evalA expr

val :: (Val :: e) = Int - Expr e
val x = In $ inj $ Val x

add :: (Add :: e) = Expr e - Expr e - Expr e
add x y = In $ inj $ Add x y

mul :: (Mul :: e) = Expr e - Expr e - Expr e
mul x y = In $ inj $ Mul x y

test :: Expr (Val :+: Add)
test = In (Inr (Add (val 118) (val 1219)))

test2 :: Expr (Add :+: Val)
test2 = val 1

test3 :: Expr ((Add :+: Val) :+: Mul)
test3 = add (mul (val 1) (val 2)) (val 3)

test4 :: Expr (Add :+: (Val :+: Mul))
test4 = add (mul (val 1) (val 2)) (val 3)

-- our typtree selection prefers left injection
test5 :: Expr ((Val :+: Val) :+: (Val :+: Val))
test5 = val 1

--
-- TypTree.  This is basically the same as (::).
-- I kept it a separate class during development.  This also allows the use of
-- additional constraints on (::) which improve the error messages
when you try,
-- for example:
--   testBroken :: Expr (Mul :+: Add)
--   testBroken = val 3
--
class (Functor sub, Functor sup) = TypTree sub sup where
treeInj :: sub a - sup a
instance Functor x = TypTree x x where
treeInj = id

--
-- The magic all happens here
-- We use IsTreeMember to determine if a type is part of a tree with leaves
-- of various types and internal nodes of type (l :+: r).
--
class IsTreeMember (sub :: * - *) (sup :: * - *) b | sub sup - b

instance TypEq x y b = IsTreeMember x y b
instance (IsTreeMember x l bl, IsTreeMember x r br, TypOr bl br b) =
IsTreeMember x (l :+: r) b

class (Functor sub, Functor l, Functor r) = TypTree' b sub l r where
treeInj' :: b - sub a - (l :+: r) a

--
-- We can then use this result to decide whether to select from the
left or the right.
--
instance (TypTree x l, Functor r) = TypTree' HTrue x l r where
treeInj' _ = Inl . treeInj
instance (TypTree x r, Functor l) = TypTree' HFalse x l r where
treeInj' _ = Inr . treeInj

--
-- Finally, this allows us to select which treeInj' to use based on the
-- type passed in.
-- 
instance (IsTreeMember x l b, TypTree' b x l r) = TypTree x (l :+: r) where
treeInj = treeInj' (undefined :: b)

class TypOr b1 b2 res | b1 b2 - res
instance TypOr HFalse HFalse HFalse
instance TypOr HFalse HTrue  HTrue
instance TypOr HTrue  HFalse HTrue
instance TypOr HTrue  HTrue  HTrue

-- Type equality, semi-lifted from the hlist paper; this only works in GHC.
--
-- You can avoid the reliance on GHC6.8 type equality constraints
-- by using TypeCast from the HList library instead.
--
-- see http://www.okmij.org/ftp/Haskell/types.html#HList
-- for the source of this idea.

data HFalse
data HTrue

class TypEq (x :: * - *) (y :: * - *) b | x y - b
instance TypEq x x HTrue
instance (b ~ HFalse) = TypEq x y b
___

[Haskell-cafe] Re: Wadler's blog post on the expression problem

2008-02-28 Thread Ryan Ingram
In case you're curious, Wadler's blog post is here:
http://wadler.blogspot.com/2008/02/data-types-la-carte.html
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Error I haven't seen before

2008-02-28 Thread Albert Y. C. Lai

Jefferson Heard wrote:

Main: No match in record selector Protein.go_terms


data R = A { sa :: Int } | B { sb :: Int }

sa (A 0) works (as expected). sa (B 0) gives

*** Exception: No match in record selector Main.sa

I think that explains your problem.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: ANN: Hoogle 3.1

2008-02-28 Thread Steve Lihn
You can try aggressive caching and indexing (which google uses often)
based on 20-80 rule.

http://en.wikipedia.org/wiki/Pareto_principle

On Thu, Feb 28, 2008 at 7:49 PM, Neil Mitchell [EMAIL PROTECTED] wrote:
 Hi Steve,

   Would you consider adding auto-complete feature on Hoogle in the forth
   coming release?
 
   http://wiki.script.aculo.us/scriptaculous/show/Ajax.Autocompleter

 I am slightly hoping that I'll be able to remove the Search button
 entirely, and just have results as you type. Whether that becomes
 feasible depends on how quickly the Hoogle search works, at the moment
 its way too slow, but the next version has clever data structures etc.
 which should make it fast enough, at least for text searches.

 Thanks

 Neil

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


Re: [Haskell-cafe] Re: ANN: Hoogle 3.1

2008-02-28 Thread Neil Mitchell
Hi

 You can try aggressive caching and indexing (which google uses often)
  based on 20-80 rule.

The Hoogle logs suggest this wouldn't be that useful. The most
commonly invoked searches are the three listed on the front page.
After that, the most common search is actually for where, at under
1%. However, there are other ways I think I can get the necessary
speed, and autocomplete would be very useful.

Thanks

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


Re: [Haskell-cafe] Error I haven't seen before

2008-02-28 Thread Jefferson Heard
It does.  Thank you...

On Thu, Feb 28, 2008 at 5:00 PM, Albert Y. C. Lai [EMAIL PROTECTED] wrote:

 Jefferson Heard wrote:
  Main: No match in record selector Protein.go_terms

 data R = A { sa :: Int } | B { sb :: Int }

 sa (A 0) works (as expected). sa (B 0) gives

 *** Exception: No match in record selector Main.sa

 I think that explains your problem.
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe




-- 
I try to take things like a crow; war and chaos don't always ruin a picnic,
they just mean you have to be careful what you swallow.

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


Re: [Haskell-cafe] to stimulate discussion concerning where Haskell is going .. ...

2008-02-28 Thread Benjamin L. Russell

--- Galchin Vasili [EMAIL PROTECTED] wrote:

 [snip]
 
  I have fished around and collected some Sun
 papers and slides. If any
 anybody wants I can post the URLs or send to the
 interested

Yes, I am interested.  Please post the URLs, and I
will flag the message and refer to the associated
pages as soon as I have time.

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