My guess is because irrationals can't be represented on a discrete computer
Well, call it arbitrary precision floating point then. Having built in
Integer support, it does seem odd only having Float/Double/Rational...
Keean.
..
___
I have now read most of the notes on template-haskell2, but I still
have a problem with naming (although I think my issues with types
are adequately dealt with by the '' notation.
I wish to create a declaration in template haskell, where the funtion
name is supplied: something like:
$(label
Just reporting a bug, taking types using '' works fine for:
''Int
''[]
But when you try:
''(-)
you get:
No match in record selector TyCon.algTcRhs
Please report it as a compiler bug to [EMAIL PROTECTED],
or http://sourceforge.net/projects/ghc/.
As posted on this list, there is template-haskell code to do:
$(derive [| data Foo = Foo |])
You can also get the type of Foo in TH by doing:
dummy :: Foo
dummy = undefined
$(derive2 dummy)
and the code for derive2 reify's the argument, which then gives the
reflected type... so the example
What replaces 'gensym' in GHC 6.3?
Keean.
___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Thanks for the URL... I have realised I jumped the gun saying the derivation can be
done in template-haskell... there is one small problem:
$(derive [t| SomeConstructor a b |])
passes the constructor to derive... is there any way to get the type information
for some type? You can do
$(derive
Check out Ulf Norell's IOHCC submission, his DeriveData.hs module does this,
Do you have a link?
Keean.
___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
What is the situation with deriving?
Some instances can be derived automatically for both data/newtype (built in)?
Some instances cen be derived automatically for newtype (any)?
You used to be able to define functions useing {|+|} and {|*|} (or similar)
that could be derived for both data and
look at the user manual.
Okay, I see the Generic type class stuff does not support multi
parameter type classes. I guess I am stuck - any suggestions as to
how best do this?
I wish to be able to derive type level labels for datatypes, like
the following:
data Fred a = Fred a deriving
How is deriving coded in ghc. For example the Typeable class, when in
the compilation sequence is this expanded? Which modules do this, and
which functions?
Keean.
___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
If I print out HsSyn types with pprTrace, I get:
test{v} () = id{v} ()
or something similar (depending on the declaration). Is there
any way I can get it to print out the raw data structure?
Keean.
___
Glasgow-haskell-users mailing list
[EMAIL
Would it cause me any problems if I added deriving Show to all the
types in compiler/hsSyn? (Can't think of a problem here... is there any
reason why this is not done by default? - It is really handy if trying to
pattern match on code syntax to be able to see what abstract syntax is
generated by
I have added some of the required deriving clauses, however I now
get lots of warnings about:
Bad eta expand
__coerce ()
(CmmParse.zgzg {- v rnrp -}
@ ()
@ ()
(__coerce CmmParse.ExtCode {- tc rB2 -} happyzuxzu1 {- v a1B9 -})
(__coerce CmmParse.ExtCode {- tc rB2
I need to change the boot .hi files for TypeRep, to include
the derivied show instance for TyThing, what is the format?
Keean.
___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Yes, it might be easier to elaborate the ppr instances... That
way I only have to modify instances I am interested in.
Keean.
___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Playing with HsSyn types (like HsModule)... I have got down to the
definition level like:
Sig id = Sig (Location name) (LHsDecl name)
what type is name? Presumably it can be a range of types,
what are valid types for name?
Keean.
___
When writing code in the compiler, how do you use pprTrace?
I want to print out the type of a SigD from HsDecl?
Keean.
___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
I wish to add some extended syntax to type definitions,
assuming I modify the parser files and associated datatypes
to carry the extra information, is there a convenient place
to insert a pre-parse (before type-checking) to convert the
syntax extensions to regular haskell?
Keean.
Try type annotations:
new_point (s::s) t b : interleave (next_state s::s) bs (t:ts)
Keean.
___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
You will have to give both the errors and the source code...
I have done quite a bit with classes and GHC's constraint
inferance is pretty good.
The chances are you really do need to add some extra
constraints...
(by the way if you are working with heterogeneous collections,
you may be
I thought NT and more recent was Posix compliant... Surely it should
support posix signals?
Keean.
___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
There is a portable System.Process library here:
On that note, perhaps all signals on unix should be
set to ignore, so if you are writing cross platform
code you don't have to do special stuff with say
sigPIPE for example
Keean.
___
Yes, lazy type-class resolution is a known GHC feature - and in my
opinion much superior to Hugs stict type class resolution. Hugs
can get confused with overlapping instances and will choose the
wrong instance because it commits too early. GHC does not suffer
from this.
Keean.
If I wanted to experiment with instance selection, which part of
GHC do I want to be looking at?
Keean
___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
just checked out the CVS ghc to play with instance
resolution - however:
fptools/mk/config.h.in
seems to be missing and nothing can be built.
Keean.
___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
Been having a bit of a discussion in the Cafe... Just wondered what
GHC specific issues would be involved with assuming all classes are closed.
I am thinking that there is no real dis-advantage to considering all
classes closed within their current context (IE all the imports to
the current
Actually I lied. You need the -fglasgow-exts flag.
Yes, I should have tried it before I posted, I just remembered reading
in the manual that type synonyms were excluded... But on re reading
it actually said partial applications of type synonyms were excluded,
which does not affect what I wanted
Is there any chance of enabling type synonyms in instance declarations.
I remember a posting where is was stated that there was no technical
reason for not being able to do this.
Could we perhaps have a command line switch to enable this...
For example, I think the following:-
What would happen if a timeout occurs in the _socket_ level?
I believe a (unix) socket level problem (including remote server
closing the connection unexpectedly) results in a Posix SigPIPE.
Is you set the default action to ignore:
installHandler sigPIPE Ignore Nothing
Then it gets
If you fork a thread to handle each connection the async
exception is thrown to the (Haskell) thread which is
performing IO on the socket when it happens.
(the ignore means ignore the signal the default action is
to terminate the program)
Keean.
I don't see why GHC can't have a 'callAllOutstandingFinalizers' call
as part of _exit() or something...
Keean.
___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Can't help but comment...
Purely functional languages like Haskell are excellent
within certain niches, but non-trivial problems exist
with language interoperability between lazy and strict
languages.
I don't wish to appear to be too harsh on Microsoft, (after all
they are supporting work on
I have seen very compact Prolog implementations in Haskell, and I
also know that constraints, modelled by CHRs can be evaluated directly
in Prolog. Why not just bolt one of these compact Prologs onto the
compiler, and just feed it the facts and rules...
Keean.
but unfortunately some simple programming exercises can quickly turn
into problems that require a PhD. to solve.
Of course you could say that the excersise is not actaully as simple
as you believe, and other languages will let you get away with stuff
you really shouldn't be doing.
A good
I don't know whether this was apparent, but only the instance
pattern is used in determining which instance to use, so
PO a is the same as PO a ... you need to make them different
otherwise they don;t just overlap they are identical.
the left-hand-side of the = play no part in instance
That's not the notion of priority I was referring to.
Any type of priority would not help. As I said then the instance heads
are identical (PO a) and (PO a) - no kind of priority will help
differenciate the,
Keean.
___
Glasgow-haskell-users
I wasn't talking about _any_ notion of ordering of instance heads; I
said that prioritising instance _declarations_ themselves, explicitly,
by 'name' would suffice.
How does that help... if you name the instances differently are they
not just ordinary functions, as they would no longer be
I don't think you get it... naming does not help, the problem is the
compiler cannot distinguish between the instances.
The alternative to the current situation is to take into account the
dependancies of instances when selecting. The problem here is that
the compiler may select an instance,
that is not the case with -fallow-undecidable-instances ... as far as
I understand it , ghc never considers the dependancies when selecting an
instance. If you don't think so you will need to show me an example where
it clearly does... as I haven't seen one yet (but just because I haven't
seen it
I think you should read the GHC manual (assuming it is up to date
and undecidable instances means what it says it does, the difference
is...
Without undecidable instances at least one type in the instance
must not be a type variable.
With undecidable instances you can have a default-instance
tried to update to update GHC from CVS today, with CVSROOT=
:pserver:[EMAIL PROTECTED]:/cvs
but got the error:
cvs [login aborted]: connect to glass.cse.ogi.edu(129.95.44.145):2401 failed:
Connection refused
Is it my ISP, or is everyone having the same problem?
Regards,
How can you take the results of a comparison like that seriously:
For example the reverse file test, here is the Haskell actually used:
main = interact $ unlines . reverse . lines
and here is the C:
/* -*- mode: c -*-
* $Id: reversefile.gcc,v 1.10 2001/07/20 17:20:32 doug Exp $
*
Is there any way to insist that two types are different? For example
f :: NotSame a b = a - b
Regards,
Keean Schupke.
___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
Hi Oleg, I like the polymorphic list indexed by Ints... there
do seem to be a couple of differences between this and the list
indexed by natural numbers.
The list indexed by integers cannot determine the type of the
return value through induction on the class... in other words
it cannot
This is the latest varient. Let me know whether you guys find this
interesting, as I am coding what I need for a practical application,
it may be tedious for you... I am still of the opinion that some
kind of polygenious list (or maybe heteromorphic?) would be good in
the standard libraries,
I did not know about Oleg's posting, as I originally said, I based my implementation on
a paper by Conor McBride. Oleg is addressing the question of type safe casting, rather
than generic storage, so his code is a bit different. Infact his class:
class TypeSeq t s where
type_index:: t - s -
I have written a first attempt at a fold function for the heterogenious list:
class RFold i r where
rFold :: (forall a . a - i - i) - i - r - i
instance RFold i RNil where
rFold f i RNil = i
instance RFold i r = RFold i (a `RCons` r) where
rFold f i (x `RCons` xs) = f x (rFold f i xs)
I have written a first attempt at a fold function for the heterogenious list:
class RFold i r where
rFold :: (forall a . a - i - i) - i - r - i
instance RFold i RNil where
rFold f i RNil = i
instance RFold i r = RFold i (a `RCons` r) where
rFold f i (x `RCons` xs) = f x (rFold f i xs)
Ok... After playing with these types, I could not get it to work with
the satFold
below. However it did inspire me to try something else, and this seems
to work
quite well.
First redefine the RFold function to use RFoldFn class as its operator.
Then create
instances of RFoldFn to do what you
I needed a list which could handle items of different types for the
database code I am writing. I have written a module implementing such a
list based on dependant types (from Conor McBride: Faking It; Simulating
Depandant Types in Haskell). Although McBride does not mention
lists/vectors with
Didn't know If I should post it straight away... its quite long and I dont do
attachments (well not If I can help it. I am aware Dynamic can model heterogenious
lists
(thanks for correct terminology) - but I need static typing. Thats the clever thing
about
this code - the list is heterogenious
I was thinking about improving array performance, and was wondering
if a transactional model would work well. You would keep a base copy
of the array, and any writes would be written to a delta style transaction
list. A reference to the array would be the list plus the base array.
Different
with reference to Ptr, I only need an instance of Data for the
Ptr () case (ie opaque pointers) ... so for generics it only needs
to know that a Ptr is a Ptr, and to treat it like a value.
Regards,
Keean Schupke.
___
There appears to be no instance for Double values in the
Generics.Basic
Also no instance for Ptr.
am I not importing the right file, or does this need to be fixed?
Regards,
Keean Schupke.
PS. This is with ghc-6.2
___
b - mapArray id a
The reason it is slow is because the array type is copied every time
a member is assigned.
There are two solutions:
1) Use a mutable-array in the StateMonad then freeze it.
2) In this particular case where processing is sequential (IE you
are only altering values based on
Was just thinking about GHC's implementation of arrays, and their
poor performance. I know little about GHC's internal workings, but
I was thinking about how array performance could be improved.
What if when writing an array you instead construct a function:
f :: (Ix x,Ix y) = Array a - Ix x -
When deriving Data with all warnings enabled, for example compiling the
following line:
data TestType = TestType Int deriving (Typeable,Data)
ghc 6.2 gives the following warnings:
Warning: Pattern match(es) are non-exhaustive
In a case alternative:
Patterns not
the identity function will convert one to the other
Okay. This I understand.
I understand why the type of a generic transform has to be:
gtrans :: Data a = a - a
and thinking about this has given me the solution. Obviously
my data types are wrong... If a loose one type and create an
Presumably not replace all Ints by Floats
I've thought about it some more, and I don't think its
possible to do what I want using generics... Ideally I would like
to achieve the following type transformation:
type SqlColumn a = String
type TypedExpr a = Int
the function would map SqlColumns to
I have used generics in a couple of places (from the
scrap your boilerplate paper) and want to know if it is
possible to write a function that will (for example) change
the types 'in place' in a type. For example replace all the
elements in a tuple with a string (using Show):
(3 :: Int,3.5 ::
I now have a vague clue how to do what I wanted. I wanted to substitute
types in place... a silly example would be to convert Ints to Floats and
Floats to Ints...
(3 :: Int, 4.0 :: Float) - (3.0 :: Float, 4 :: Int)
I already have a function that will convert the input to:
I have read the Scrap Your Boilerplate: A Practical Design
Pattern for Generic Programming and have worked out how to
do it. This seems much better than using Template Haskell for
this kind of problem.
I used mkQ and extQ to convert from various types that are allowed
in the record structure, to
I am currently using template haskell to generate code to work on a
record data type... This however is not very pretty, and I wondered if
there was another way to do what I want in GHC. I need to iterate over
the contents of a record for example:
data Test = Test { a :: Int, b :: String, c ::
Whilst I appreciate the topic of show is not directly related to GHC,
what I would like to know is how to handle UNICODE properly... If I assume
I have a good unicode terminal, so stdin and stdout are in unicode format,
and all my text files are in unicode, how do I deal with this properly in
This is one good reason they have to be protected by MVars
Forgive my stupidity, but arn't the MVar operations (takeMVar, putMVar)
IO operation, therefore the locks must be in the IO monad, therefore
the code acting on the DiffArray should be in the IO monad... otherwise
they can't use the MVar
GHC only runs code on a single CPU at the moment
Is this true even if compiled with --threaded-rts ?
regards,
Keean Schupke.
___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
never used in multi-threaded situation.
Erm, nearly all my code in Haskell is multi-threaded. One of the
main reasons why I am using haskell is the low-cost light weight
multi-threading. Surely this is a big win for Haskell on SMP/Numa
machines - which are surely the future - as even Intel have
With reference to the future of template haskell - it would be nice if you could
express the
following:
stringType :: String - Q [Dec]
stringType s = do
x - gensym x
y - gensym y
return [
Newtype [] s [] (Constr s [(Strict,Tcon (TconName String))]) [],
Proto (show++s) (Tapp
Just a thought, but once you have a data structure representing reified code
there is a couple of things it would be nice to be able to do:
1) use the Parser to read a source file (i'm assuming the parser produces the
same data stuctures as template haskell)
2) run the reified code directly
I would like to create a template to generate type declarations, for example:
newtype mytype = myconstructor String
I am struggling without an example... how do I do it?
Regards,
Keean Schupke.
___
Glasgow-haskell-users mailing list
Okay, I have got my template working, but its extremely unreadable... could
anyone tell me how to make this look more like normal Haskell code?
stringType :: String - Q [Dec]
stringType s = do
x - gensym x
return [
Newtype [] s [] (Constr s [(NonStrict,Tcon (TconName String))]) [],
Will the arrow's notation be in 6.2, whilst this is not vital, it would be very useful.
Regards,
Keean Schupke.
___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Would it not be better to have control over exactly where these options apply,
could you not have:
{-# OPTIONS fallow-overlapping-instances=true #-}
... some code ...
{-# OPTIONS -fallow-overlapping-instances=false #-}
... more code ...
So you can ensure instances you don't want overlapping
I am trying to define the left operator for a CPS arrow of type:
newtype CPSFunctor ans a b c = CPS ((a c ans) - (a b ans))
This is the definition given by John Hughes for first:
first (CPS f) = CPS $ \k - arr (\(b,d) - (f (arr (\c - (c,d)) k),b)) app
So I try and apply this to left and
I agree, I certainly don't want inefficency introduced by unecessary
flushes, and
I would expect to control where the flushes happen. I think the query
originally
assumed a sequencing ambiguity in the IO monad... but in my experiance
(all be it
limited) the IO monad is there to ensure strict
I know this has been discussed before, but I can't remember the
conclusion and nothing seems to have
been done, so I am going to bring it up again.
Is there any way the compiler can mark object files with whether they
are profiling or not, so that you cannot
link a profiled object with a
Can I get ghc to use a local definition of `=` and return... currently
I have:
{-# OPTIONS -fglasgow-exts -fno-implicit-prelude #-}
module Main(main) where
import qualified Prelude (Monad(..))
import Prelude hiding (Monad(..))
... Then a definition of Monad using a Premonad for return, however
77 matches
Mail list logo