Re: [Haskell-cafe] Re: Allowing hyphens in identifiers

2009-12-12 Thread Matthew Pocock
 x - take_while some_condition some_list

 and

 x - takeWhile someCondition someList


x - take-while some-condition some-list

As someone who is dyslexic, I find both camelCase and dashes far easier to
read than underscores. I find it hard to count the words in the underscore
version - the underscores and spaces confuse me. Dashes do not, presumably
because they are 'within' the line of sight for the letters.

However, I can't help feeling that if we use good IDEs, we could
'internationalize' identifiers into english/french/chinese/camel/dash or
whatever.

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


Re: [Haskell-cafe] Implicit newtype unwrapping

2009-12-03 Thread Matthew Pocock
Perhaps what you are looking for is a more powerful defining semantics?

newtype MyFoo = Foo defining (Foo(..)) -- all class instances that Foo has
are delegated through from MyFoo

Matthew


 not sure if this is what you are thinking at, but everytime I wrap a
 type Foo in a newtype MyFoo to define my own instances (or just for more
 expressiveness code), I wish I had a way to tell the compiler:
 „Please define function myfoo to be the same as foo, with all occurences
 of Foo in its type signature replaced by MyFoo.“

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


Re: [Haskell-cafe] Implicit newtype unwrapping

2009-12-03 Thread Matthew Pocock
Of course, I meand 'deriving', not 'defining'

/me embarsed

2009/12/3 Matthew Pocock matthew.poc...@ncl.ac.uk

 Perhaps what you are looking for is a more powerful defining semantics?

 newtype MyFoo = Foo defining (Foo(..)) -- all class instances that Foo has
 are delegated through from MyFoo

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


Re: [Haskell-cafe] Graph drawing library for Haskell

2009-11-20 Thread Matthew Pocock
I have had some luck with the graphviz (dotter) bindings for drawing
node/ark graphs. It's not an ideal solution, and will require some wrappers
to bind to your data structures, but it does work.

Matthew

2009/11/20 Victor Mateus Oliveira rhapso...@gmail.com

 Hi,

 Anyone knows a good library for graph diagram drawing? Or a haskell
 binding for one?
 Something like jgraph. http://www.jgraph.com/jgraph.html

 []s'
 Victor

 --
 GNU/Linux user #446397 - http://counter.li.org
 ___
 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] Re: Long running Haskell program

2009-11-12 Thread Matthew Pocock
2009/11/12 Heinrich Apfelmus apfel...@quantentunnel.de

 Interestingly, this is different from  Control.Monad.State.Strict . The
 latter never forces the state itself, just the pair constructor of the
 (result,state) pair.


 Yes. This bit me the first time I came across it. I think we need a
Control.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Long running Haskell program

2009-11-12 Thread Matthew Pocock
2009/11/12 Heinrich Apfelmus apfel...@quantentunnel.de

 Interestingly, this is different from  Control.Monad.State.Strict . The
 latter never forces the state itself, just the pair constructor of the
 (result,state) pair.


Yes. This bit me the first time I came across it. I think we need a
Control.Monad.State.StrictOnState with strict behaviour on the state value.
I notice this same underlying issue is coming up in more than one thread on
these lists.

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


Re: [Haskell-cafe] Re: Long running Haskell program

2009-11-12 Thread Matthew Pocock
How about:

instance (Monad m) = MonadState s (SStateT s m) where
get = S get
put s = S (put $ using s $ strategy m)

where our state monad has a strategy field?

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


Re: [Haskell-cafe] Long running Haskell program

2009-11-11 Thread Matthew Pocock
Is there a state monad that is strict on the state but lazy on the
computation? Of course, strictness in the state will force a portion of the
computation to be run, but there may be significant portions of it which are
not run. Would there be a way to write a state monad such that it is
entirely lazy, but then to wrap either the computation or the state in an
'eager' strategy datatype which takes care of this in a more flexible
manner?

Thanks,

Matthew

2009/11/11 Bryan O'Sullivan b...@serpentine.com

 On Wed, Nov 11, 2009 at 7:43 AM, David Leimbach leim...@gmail.com wrote:


 I recently ran into some serious space leak difficulties that would
 ultimately cause this program to crash some time after startup (my simulator
 is also written in Haskell, and runs a LOT faster than the real application
 ever could, this has enabled me to fast forward a bit the data growth issues
 and crash in minutes instead of days!)


 It sounds to me like you were storing a Map in a StateT. Since the usual
 State and StateT monads don't force the evaluation of their payload, I'm not
 terribly surprised that such a leak should arise.

 ___
 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] Re: Libraries need a new owner

2008-03-24 Thread Matthew Pocock
On Monday 24 March 2008, Don Stewart wrote:
 Let's get a new faster Data.Map and other containers ready to go by the
 end of the northern summer?

And while we are visiting this, can I put in a vote for a seperation between 
the default Data.* container concrete implementations and associated classes? 
E.g. between the cannonical Map implementation and a Map class that could (if 
I felt mad) be backed by a list, or (if I was more sane) the cannonical Map 
datatype? This would go /at least/ for Map, Set, List.

Matthew


 -- Don
 ___
 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] Random Monad

2008-03-24 Thread Matthew Pocock
Hi,

Who currently maintains the Random monad code? I have some patches to 
contribute.

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


Re: [Haskell-cafe] Random Monad

2008-03-24 Thread Matthew Pocock
On Monday 24 March 2008, Henning Thielemann wrote:
 On Mon, 24 Mar 2008, Matthew Pocock wrote:
  Who currently maintains the Random monad code? I have some patches to
  contribute.

 Do you refer to the code on the wiki?

No, to the code in darcs at http://code.haskell.org/monadrandom

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


[Haskell-cafe] hoisting as well as lifting and returning

2008-03-23 Thread Matthew Pocock
Hi,

Happy Easter!

I've been using monad transformers for the first time in anger this week. They 
certainly do the job. However, there's an operation that I keep defining over 
and over again. It is sort of like lift and return in that it's glue to get 
operations and values into the monad from outside it. Here are two examples.

hoistList :: (Monad m) = [a] - ListT m a
hoistList = foldr (mplus . return) mzero

hoistMaybe :: (Monad m) = Maybe a - MaybeT m a
hoistMaybe = maybe mzero return

The general idea is that you have some legacy, non-transform operation in some 
monad MonadFoo, and you are writing an operation in MonadFooT. You want to 
get the monadFoo value into MonadFooT. So, you say something like:

do vInMFT - hoist vInMF

Is this a common enough operation on a monad transformer and it's 'raw' monad 
to warrant a class of its own? I have 'hoist' methods for several monad 
transformers, including RamdomMonadT, although I've probably defined them in 
ways that are overly eager or eat stack/heap, so I'd prefer knowledgable 
people to write them :)

There must be other operations that link the base monad with its transformed 
version, other than 'hoist' - the runFooT method for example.

Perhaps 'hoist' already exists and I'm re-inventing the wheel?

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


Re: [Haskell-cafe] hoisting as well as lifting and returning

2008-03-23 Thread Matthew Pocock
Hi Yitz,

I was thinking along the lines of a class linking the monad transformer with 
the base monad:

class (MonadTrans mt, Monad b) = MonadTForm mt b | mt - b
where 
  hoist :: (Monad m) = b a - mt m a

This is to restrict it directly between the base monad and the transformed 
version. If you wish to 'adapt' any other pair of monads, then I think that's 
another operation, just as lift is a different operation to hoist.

Matthew

On Sunday 23 March 2008, Yitzchak Gale wrote:
 You are correct. This is a fundamental operation. It exists
 for just about every monad, but in a haphazard and
 inconsistent way. In my opinion, its type needs to be
 more polymorphic in a slightly different direction than what
 you are suggesting.

...

 What I do sorely feel the need for is a hoist for each pair
 of base/transformer monads: i.e., polymorphic monad
 constructors.

 So, for example, if we had

 mkState :: (st - (a, st)) - m a

 as a member of the MonadState st m class,
 then it would be so much easier to write functions

 f :: MonadState st m = ...

 that could be used without having to refactor it every time
 the monad stack changes. In general, each monad
 Foo would have a MonadFoo class (even the monads
 that don't have one yet) containing (at least) a mkFoo
 method that lifts the underlying structure polymorphically
 either to Foo or to FooT.

...

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


[Haskell-cafe] classes for data structures

2008-02-06 Thread Matthew Pocock
Hi,

I've been working a lot with maps, sets and lists. While the process of 
getting things out of them is abstracted by foldable, traversable and 
friends, the process of building one up is not. Would it be possible to have 
something like:

class Buildable b where
  empty :: b a --makes an empty b with elements of type a
  insert :: a - b a - b a --inserts the new element into the buildable

I'm not particularly wedded to the names. It's just that it would be very 
convenient sometimes to collect data items into e.g. a list or a set, without 
pushing in some klunky foralled insert function.

I see that this is realted to MonadPlus, but the space of possible container 
classes is wider than that of monads e.g. set.

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


Re: [Haskell-cafe] Signature for non-empty filter

2008-02-06 Thread Matthew Pocock
On Wednesday 06 February 2008, Henning Thielemann wrote:

 If the type checker does not terminate because the checked function does
 not terminate on the example input, then the function does not pass the
 type check and as a compromise this would be ok.

Can't fault this logic. The problem is that you may have to wait quite a long 
time to discover this non-termination.

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


Re: [Haskell-cafe] Haskell maximum stack depth

2008-02-04 Thread Matthew Pocock
On Monday 04 February 2008, Adrian Hey wrote:
 Yikes!

 Also, I can't help thinking that the common justification for the
 current limit (that it helps find alleged bugs) is a little lame.
 It only helps find bugs if one expects ones program to use less than
 8M of stack (hence if it's using more, it's a bug by ones *own*
 definition). 

My experience so far is that I've only triggered stack overflows when I've had 
an infinite recursion. Getting foldl and foldr wrong on long lists has 
usually lead to disasterous memory churn, not ever to an overflow.

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


Re: [Haskell-cafe] Haskell maximum stack depth

2008-02-04 Thread Matthew Pocock
On Monday 04 February 2008, Neil Mitchell wrote:
 Hi

 That would be nice. But its only beneficial if there are programs
 which takes large amounts of stack at some point, but then shrink down
 to very little stack and continue for a reasonable amount of time.

From the 'when I was a lad' department...

Thinking back to when Java transitioned to a garbage collector that could give 
memory back to the OS, we got some unexpected benefits. Consider a machine 
that's running a load of programs, launched from some q system e.g. 
LSF/condor. If they keep memory, the box, q scheduler or admins get unhappy.

If I had £1 for each time our admins said your 200 java apps are using 500m 
each when I could see for sure that except for an initial memory burn 
during loading files in, only a few megs where resident. Magically, once Java 
could release heap, these grypes went away.

Matthew

 Thanks

 Neil
 ___
 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] Re: Re: hxt memory useage

2008-01-28 Thread Matthew Pocock
On Monday 28 January 2008, Rene de Visser wrote:
 It would be nice if HXT was incremental even when you are processing the
 whole tree.

 If I remember correctly, the data type of the tree in HXT is something like

 data Tree = Tree NodeData [Tree]

 which means that already processed parts of the tree can't be garbage
 collected because the parent node is holding onto them.

 If instead it was

 data Tree = Tree NodeData (IORef [Tree])

 Would could remove each subtree as it was processed (well just before would
 probably be necessary, and we would need to rely on blackholing to remove
 the reference on the stack). This would perhaps allow already processed
 subtree to be garbage collected. Together with the lazy evaluation this
 could lead to quite good memory usage.

 Rene.

Not so sure about this. For streaming processing, it would be nicer to have 
something like StAX with a stack of already entered elements kept about as 
book-keeping |(the tags + attribute sets to root). Let's face it, if you sign 
up to a document model, you are signing up to a document and shouldn't be 
supprised when it sits in memory.

I think the 'right' solution at least in part goes with the problem to be 
solved. I'd be upset if we moved to something more complex where my code 
breaks because something accidentaly garbage collected data that I need to 
back-track to.

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


Re: [Haskell-cafe] hxt memory useage

2008-01-26 Thread Matthew Pocock
On Saturday 26 January 2008, Keith Fahlgren wrote:
 Perhaps a more modern approach would be StAX[1]-like rather than SAX-like?
 In either case, streaming, non-DOM.

 I am concerned by the number of people expressing willingness to abandon
 namespace support, but perhaps I'm being too much of a purist

 Keith

StAX is fine for a very wide range of applications, including web services. In 
the web-service domain, namespaces and entity expansion and xsd are not 
optional extras, but these can be layered on top of StAX rather than a more 
DOM-like structure.

Just as a reality check, we regularly stream xml messages between web services 
in Java where the message bodies are many gig in size, using StAX, and 
neither the client or server need anything other than a constant memory 
overhead, as the portions of the message are generated and consumed in a 
streaming manner. It would be very nice if we could do similar things in 
haskell.

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


[Haskell-cafe] hxt memory useage

2008-01-24 Thread Matthew Pocock
Hi,

I've been using hxt to process xml files. Now that my files are getting a bit 
bigger (30m) I'm finding that hxt uses inordinate amounts of memory. I have 
8g on my box, and it's running out. As far as I can tell, this memory is 
getting used up while parsing the text, rather than in any down-stream 
processing by xpickle.

Is this a known issue?

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


Re: [Haskell-cafe] hxt memory useage

2008-01-24 Thread Matthew Pocock
On Thursday 24 January 2008, Albert Y. C. Lai wrote:
 Matthew Pocock wrote:
  I've been using hxt to process xml files. Now that my files are getting a
  bit bigger (30m) I'm finding that hxt uses inordinate amounts of memory.
  I have 8g on my box, and it's running out. As far as I can tell, this
  memory is getting used up while parsing the text, rather than in any
  down-stream processing by xpickle.
 
  Is this a known issue?

 Yes, hxt calls parsec, which is not incremental.

 haxml offers the choice of non-incremental parsers and incremental
 parsers. The incremental parsers offer finer control (and therefore also
 require finer control).

I've got a load of code using xpickle, which taken together are quite an 
investment in hxt. Moving to haxml may not be very practical, as I'll have to 
find some eqivalent of xpickle for haxml and port thousands of lines of code 
over. Is there likely to be a low-cost solution to convincing hxt to be 
incremental that would get me out of this mess?

Matthew

 ___
 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] parsec and bytestring; was: hxt memory useage

2008-01-24 Thread Matthew Pocock
Would a bytestring-backed implementation of parsec solve my problems? Is there 
such a beast out there?

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


Re: [Haskell-cafe] Using GADTs

2007-07-29 Thread Matthew Pocock
On Sunday 29 July 2007, Jim Apple wrote:

 The way I would do this would be to encode as much of the value as I
 cared to in the constructors for concepts, rather than just encoding
 the top-level constructor.

  data Named
  data Equal a b
  data Negation a
  data Top
 
  data Concept t where
   CNamed   :: String - Concept Named
   CEqual   :: Concept a - Concept b - Concept (Equal a b)
   CNegation:: Concept a - Concept (Negation a)
   CTop :: Concept Top

Ah, great. That was the first trick I'd missed.


 Then, I could form a datatype that does not contain a Concept, but
 merely certifies that all Concepts of a certain type are in NNF.

This turns out not to be needed if you describe what nnf is in terms of those 
parameterised datatypes above. You can re-use the same datatype! I had to 
move the nnf function into a class to get it to compile, which makes the code 
more verbose, but appart from that I'm quite pleased with the result.

 By the way, the code you included last time did not compile. I think
 you'll probably get a quicker response than my lazy two-day turnaround
 if you make sure to run your posted code through Your Favorite
 Compiler first.

Yeah, sorry about that. It was a late-at-night thing. I've pasted in my 
(compiling and working) code below, for anyone that's interested.

I think I like GADTs quite a lot :) Pitty I can't get deriving clauses to work 
with them...

Thanks

Matthew

data Named
data Equal a b
data Conjunction a b
data Disjunction a b
data Negation a
data Existential a
data Universal a
data Top
data Bottom

data Concept t where
  CNamed   :: String - Concept Named
  CEqual   :: Concept a - Concept b - Concept (Equal a b)
  CConjunction :: Concept a - Concept b - Concept (Conjunction a b)
  CDisjunction :: Concept a - Concept b - Concept (Disjunction a b)
  CNegation:: Concept a - Concept (Negation a)
  CExistential :: Role Named - Concept a - Concept (Existential a)
  CUniversal   :: Role Named - Concept a - Concept (Universal a)
  CTop :: Concept Top
  CBottom  :: Concept Bottom

data Role t where
  RNamed :: String - Role Named

class InNNF nnf

instance InNNF Named
instance InNNF Top
instance InNNF Bottom
instance InNNF (Negation Named)
instance InNNF (Negation Top)
instance InNNF (Negation Bottom)
instance (InNNF a, InNNF b) = InNNF (Equal a b)
instance (InNNF a, InNNF b) = InNNF (Conjunction a b)
instance (InNNF a, InNNF b) = InNNF (Disjunction a b)
instance (InNNF a) = InNNF (Existential a)
instance (InNNF a) = InNNF (Universal a)

class ( InNNF u ) = ToNNF t u | t - u where
  nnf :: Concept t - Concept u

instance ToNNF Named Named where
  nnf = id

instance (ToNNF a c, ToNNF b d) = ToNNF (Equal a b) (Equal c d)
 where
  nnf (CEqual lhs rhs) = CEqual (nnf lhs) (nnf rhs)
  
instance (ToNNF a c, ToNNF b d) = ToNNF (Conjunction a b) (Conjunction c d)
 where
  nnf (CConjunction lhs rhs) = CConjunction (nnf lhs) (nnf rhs)
  
instance (ToNNF a c, ToNNF b d) = ToNNF (Disjunction a b) (Disjunction c d)
 where
  nnf (CDisjunction lhs rhs) = CDisjunction (nnf lhs) (nnf rhs)
  
instance (ToNNF a b) = ToNNF (Existential a) (Existential b)
 where
  nnf (CExistential r c) = CExistential r (nnf c)
  
instance (ToNNF a b) = ToNNF (Universal a) (Universal b)
 where
  nnf (CUniversal r c) = CUniversal r (nnf c)

instance ToNNF (Negation Named) (Negation Named)
 where
  nnf = id
  
instance (ToNNF (Negation a) c, ToNNF (Negation b) d) = ToNNF (Negation 
(Equal a b)) (Equal c d)
 where
  nnf (CNegation (CEqual lhs rhs)) = CEqual (nnf $ CNegation lhs) (nnf $ 
CNegation rhs)
  
instance (ToNNF (Negation a) c, ToNNF (Negation b) d) = ToNNF (Negation 
(Conjunction a b)) (Disjunction c d)
 where
  nnf (CNegation (CConjunction lhs rhs)) = CDisjunction (nnf $ CNegation lhs) 
(nnf $ CNegation rhs)
  
instance (ToNNF (Negation a) c, ToNNF (Negation b) d) = ToNNF (Negation 
(Disjunction a b)) (Conjunction c d)
 where
  nnf (CNegation (CDisjunction lhs rhs)) = CConjunction (nnf $ CNegation lhs) 
(nnf $ CNegation rhs)
  
instance (ToNNF a b) = ToNNF (Negation (Negation a)) b
 where
  nnf (CNegation (CNegation c)) = nnf c
  
instance(ToNNF (Negation a) b) = ToNNF (Negation (Existential a)) (Universal 
b)
 where
  nnf (CNegation (CExistential r c)) = CUniversal r (nnf $ CNegation c)
  
instance (ToNNF (Negation a) b) = ToNNF (Negation (Universal a)) (Existential 
b)
 where
  nnf (CNegation (CUniversal r c)) = CExistential r (nnf $ CNegation c)
  
instance ToNNF (Negation Top) (Negation Top)
 where
  nnf (CNegation CTop) = CNegation CTop
  
instance ToNNF (Negation Bottom) (Negation Bottom)
 where
  nnf (CNegation CBottom) = CNegation CBottom
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Using GADTs

2007-07-27 Thread Matthew Pocock
Hi,

I'm trying to get to grips with GADTs, and my first attempt was to convert a 
simple logic language into negative normal form, while attempting to push the 
knowledge about what consitutes negative normal form into the types. My code 
is below.

I'm not entirely happy with it, and would appreciate any feedback. The rules 
are that in nnf, only named concepts, the concept Top and the concept Bottom 
can be negated. So, I've added three NNFNegation_* constructors capturing 
these legal cases. Is there a way to use one constructor, that is allowed 
to 'range over' these three cases and none of the others?

I've ended up producing two data types, one for the general form and one for 
the nnf. Actually, the constraint on what constitutes nnf is fairly obvious - 
no complex terms are negated. Is there a way to use just the one data type 
but to describe two levels of constraints - one for the general case, and one 
for the nnf case? Or is the whole point that you capture each set of 
constraints in a different data type?

Thanks,

Matthe


data Named
data Equal
data Conjunction
data Disjunction
data Negation
data Existential
data Universal
data Top
data Bottom

data Concept t where
  CNamed   :: String - Concept Named
  CEqual   :: Concept a - Concept b - Concept Equal
  CConjunction :: Concept a - Concept b - Concept Conjunction
  CDisjunction :: Concept a - Concept b - Concept Disjunction
  CNegation:: Concept a - Concept Negation
  CExistential :: Role Named - Concept Existential
  CUniversal   :: Role Named - Concept Universal
  CTop :: Concept Top
  CBottom  :: Concept Bottom

data NNFConcept t where
  NNFCNamed   :: String - NNFConcept Named
  NNFCEqual   :: NNFConcept a - NNFConcept b - NNFConcept Equal
  NNFCConjunction :: NNFConcept a - NNFConcept b - NNFConcept Conjunction
  NNFCDisjunction :: NNFConcept a - NNFConcept b - NNFConcept Disjunction
  NNFCExistential :: Role Named - NNFConcept Existential
  NNFCUniversal   :: Role Named - NNFConcept Universal
  NNFCTop :: NNFConcept Top
  NNFCBottom  :: NNFConcept Bottom
  
  NNFCNegation_N  :: NNFConcept Named  - Concept Negation
  NNFCNegation_T  :: NNFConcept Top- Concept Negation
  NNFCNegation_B  :: NNFConcept Bottom - Concept Negation

data Role t where
  RNamed :: String - RNamed Named

-- terms not prefixed with a negation are already in nnf
nnf :: Concept t - NNFConcept u
nnf CNamed   name = NNFCNamed name
nnf CEqual   lhs  rhs = NNFConcept  (nnf lhs) (nnf rhs)
nnf CConjunction lhs  rhs = NNFCConjunction (nnf lhs) (nnf rhs)
nnf CDijunction  lhs  rhs = NNFCDisjunction (nnf lhs) (nnf rhs)
nnf CExistential rc   = NNFCExistential r (nnf c)
nnf CUniversal   rc   = NNFCUniversal   r (nnf c)

-- if negated, we must look at the term and then do The Right Thing(tm)
nnf CNegation (CNamed name)  = NNFCNegation_N  NNFCNamed name
nnf CNegation (CEqual lhs rhs)   = NNFCEqual   (nnf $ CNegation lhs) 
(nnf $ CNegation rhs)
nnf CNegation (CConjunction lhs rhs) = NNFCDisjunction (nnf $ CNegation lhs) 
(nnf $ CNegation rhs)
nnf CNegation (CDisjunction lhs rhs) = NNFCConjunction (nnf $ CNegation lhs) 
(nnf $ CNegation rhs)
nnf CNegation (CNegation c)  = nnf c
nnf CNegation (CExistential r c) = NNFCUniversal   r 
(nnf $ CNegation c)
nnf CNegation (CUniveralr c) = NNFCExistential r 
(nnf $ CNegation c)
nnf CNegation CTop   = NNFCNegation_T NNFCTop
nnf CNegation CBottom= NNFCNegation_B NNFCBottom
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] partial kinds and instances

2007-04-16 Thread Matthew Pocock
Hi,

I saw that it's possible to peal off kinds from the right-hand side when 
instantiating classes. Is it possible to peel them off from the left-hand 
side? Or in any order?

I have been told in #haskell by people who seems to know that Very Bad Things 
happen if you do this without also making the kind system more clever.

Is there a quick fix that will give me the same effect, without introducing a 
newtype or re-writing the original type declaration to introduce the extra 
types in a different order?

Illustrative code below.

Matthew

data MyType e = Singleton e  

data MyOtherType k v 
  = Empty
  | Node k v

data YetAnotherType k v
  = OtherEmpty
  | OtherNode k v

type RevYAT v k = YetAnotherType k v

class Iterable ite where
  iterate :: ite e - [e]

instance Iterable MyType where
  iterate (Singleton e) = [e]

instance Iterable (MyOtherType k) where
  iterate ite = []  --broken but illustrative

instance Iterable (RevYAT v) where
  iterate it = []  --broken again

   Type synonym `RevMOM' should have 2 arguments, but has been given 1
In the instance declaration for `Iterable (RevYAT v)'
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] haskell - fpga

2006-08-30 Thread Matthew Pocock
Hi,

Does anybody know of any compilers that can compile portions of a haskell 
program to an FPGA? I have found a few domain-specific languages implemented 
in haskell for FPGAs, but so far no back-ends for compilers like ghc.

Thanks,

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