Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1.  reflection (Luca Ciciriello)
   2. Re:  reflection (Brent Yorgey)
   3. [[email protected]: Re: [Haskell-beginners]
      reflection] (Brent Yorgey)
   4. Re: [[email protected]: Re: [Haskell-beginners]
      reflection] (Luca Ciciriello)
   5.  Re: [[email protected]: Re:    reflection]
      (Heinrich Apfelmus)
   6.  ghc: unrecognised flags: -I (Lyndon Maydwell)
   7. Re:  ghc: unrecognised flags: -I (Chadda? Fouch?)
   8. Re:  ghc: unrecognised flags: -I (Lyndon Maydwell)
   9.  Help! I can't compile an example program (Tim Perry)
  10. Re:  Help! I can't compile an example program
      (Brandon S. Allbery KF8NH)


----------------------------------------------------------------------

Message: 1
Date: Tue, 5 Jan 2010 09:43:21 +0100
From: Luca Ciciriello <[email protected]>
Subject: [Haskell-beginners] reflection
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

Hi.
Someone has performed or know how to use reflection in Haskell?
I've found something on google, but that stuff seems to me very confusing.

Thanks in advance for any answer?

Luca.


------------------------------

Message: 2
Date: Tue, 5 Jan 2010 11:58:06 -0500
From: Brent Yorgey <[email protected]>
Subject: Re: [Haskell-beginners] reflection
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

On Tue, Jan 05, 2010 at 09:43:21AM +0100, Luca Ciciriello wrote:
> Hi.
> Someone has performed or know how to use reflection in Haskell?
> I've found something on google, but that stuff seems to me very confusing.

It depends what you mean by "reflection".  Can you give an example of
the sorts of things you'd like to do?  Generally speaking, Haskell
doesn't support "reflection" in the same way as many other languages
do, but there are usually idiomatic ways to accomplish the same things
you would use reflection for.

-Brent


------------------------------

Message: 3
Date: Tue, 5 Jan 2010 12:41:12 -0500
From: Brent Yorgey <[email protected]>
Subject: [[email protected]: Re: [Haskell-beginners]
        reflection]
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

Well, there are a few things I could suggest for you to look at:

  * the hint package [1] for runtime Haskell interpretation
  * look at xmonad [2] for an example of a program which recompiles and reloads 
itself on the fly
  * the haskell-src-exts library [3] for a full-featured Haskell parser/pretty 
printer

There is no way to actually inspect and modify the structure of a
running Haskell program in memory; it is simply not stored in a format
which would let you do this (it is highly optimized and compiled).
However, using the above tools I imagine you should be able to
accomplish what you want.

-Brent

[1] http://hackage.haskell.org/package/hint
[2] http://xmonad.org/
[3] http://hackage.haskell.org/package/haskell-src-exts

----- Forwarded message from Luca Ciciriello <[email protected]> -----

From: Luca Ciciriello <[email protected]>
Date: Tue, 5 Jan 2010 18:20:13 +0100
To: Brent Yorgey <[email protected]>
Subject: Re: [Haskell-beginners] reflection

My need is to have a program that at run-time should be able to read itself and 
eventually modify itself. I've used this reflection in Common LISP.
I don't know if this is possible in Haskell using GHC or GHCi (perhaps there 
are more chances inside the eval-loop of GHCi).

Thanks anyway for the answer.

Luca.


On Jan 5, 2010, at 5:58 PM, Brent Yorgey wrote:

> On Tue, Jan 05, 2010 at 09:43:21AM +0100, Luca Ciciriello wrote:
>> Hi.
>> Someone has performed or know how to use reflection in Haskell?
>> I've found something on google, but that stuff seems to me very confusing.
> 
> It depends what you mean by "reflection".  Can you give an example of
> the sorts of things you'd like to do?  Generally speaking, Haskell
> doesn't support "reflection" in the same way as many other languages
> do, but there are usually idiomatic ways to accomplish the same things
> you would use reflection for.
> 
> -Brent
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
> 



----- End forwarded message -----


------------------------------

Message: 4
Date: Tue, 5 Jan 2010 19:02:58 +0100
From: Luca Ciciriello <[email protected]>
Subject: Re: [[email protected]: Re: [Haskell-beginners]
        reflection]
To: Brent Yorgey <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

Brent, thanks for your precious help.

Luca
On Jan 5, 2010, at 6:41 PM, Brent Yorgey wrote:

> Well, there are a few things I could suggest for you to look at:
> 
>  * the hint package [1] for runtime Haskell interpretation
>  * look at xmonad [2] for an example of a program which recompiles and 
> reloads itself on the fly
>  * the haskell-src-exts library [3] for a full-featured Haskell parser/pretty 
> printer
> 
> There is no way to actually inspect and modify the structure of a
> running Haskell program in memory; it is simply not stored in a format
> which would let you do this (it is highly optimized and compiled).
> However, using the above tools I imagine you should be able to
> accomplish what you want.
> 
> -Brent
> 
> [1] http://hackage.haskell.org/package/hint
> [2] http://xmonad.org/
> [3] http://hackage.haskell.org/package/haskell-src-exts
> 
> ----- Forwarded message from Luca Ciciriello <[email protected]> 
> -----
> 
> From: Luca Ciciriello <[email protected]>
> Date: Tue, 5 Jan 2010 18:20:13 +0100
> To: Brent Yorgey <[email protected]>
> Subject: Re: [Haskell-beginners] reflection
> 
> My need is to have a program that at run-time should be able to read itself 
> and eventually modify itself. I've used this reflection in Common LISP.
> I don't know if this is possible in Haskell using GHC or GHCi (perhaps there 
> are more chances inside the eval-loop of GHCi).
> 
> Thanks anyway for the answer.
> 
> Luca.
> 
> 
> On Jan 5, 2010, at 5:58 PM, Brent Yorgey wrote:
> 
>> On Tue, Jan 05, 2010 at 09:43:21AM +0100, Luca Ciciriello wrote:
>>> Hi.
>>> Someone has performed or know how to use reflection in Haskell?
>>> I've found something on google, but that stuff seems to me very confusing.
>> 
>> It depends what you mean by "reflection".  Can you give an example of
>> the sorts of things you'd like to do?  Generally speaking, Haskell
>> doesn't support "reflection" in the same way as many other languages
>> do, but there are usually idiomatic ways to accomplish the same things
>> you would use reflection for.
>> 
>> -Brent
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://www.haskell.org/mailman/listinfo/beginners
>> 
> 
> 
> 
> ----- End forwarded message -----
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
> 



------------------------------

Message: 5
Date: Tue, 05 Jan 2010 19:24:18 +0100
From: Heinrich Apfelmus <[email protected]>
Subject: [Haskell-beginners] Re: [[email protected]: Re:
        reflection]
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8

Brent Yorgey wrote:
>
> There is no way to actually inspect and modify the structure of a
> running Haskell program in memory; it is simply not stored in a format
> which would let you do this (it is highly optimized and compiled).

There is also a very good theoretical reason for this: referential
transparency.


For example, the expressions  2+4 , 2*3  and  6  all denote the same
integer. Referential transparency means that no function

   f :: Int -> Something

may distinguish between equal integers, i.e. it must return the same
result, no matter which of the expressions is given as argument:

   f (2+4) = f (2*3) = f 6


Referentially transparency is awesome for reasoning about programs, but
it does preclude many forms of reflection. (A standard trick is to use
type classes to inspect expressions, but you still have to be explicit
about expressions versus the values they denote.)


Regards,
Heinrich Apfelmus

--
http://apfelmus.nfshost.com



------------------------------

Message: 6
Date: Wed, 6 Jan 2010 10:19:42 +0800
From: Lyndon Maydwell <[email protected]>
Subject: [Haskell-beginners] ghc: unrecognised flags: -I
To: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset=UTF-8

Hi list.

I'm trying to cabal install a few different packages and keep getting
this error:

ghc: unrecognised flags: -I

I've looked at the documentation for ghc online and there seems to be
a -I flag for letting the c-preprocessor know where to look for
included libraries.

For example, "cabal install -v logict" generates the following partial output:

/opt/local/bin/ghc -package-name logict-0.3 --make -hide-all-packages
-i -idist/build -i. -idist/build/autogen -Idist/build/autogen
-Idist/build -I -optP-include -optPdist/build/autogen/cabal_macros.h
-odir dist/build -hidir dist/build -stubdir dist/build -package
base-3.0.3.1 -package mtl-1.1.0.2 -O -O2 -Wall -XMultiParamTypeClasses
-XUndecidableInstances -XRank2Types -XFlexibleInstances
Control.Monad.Logic Control.Monad.Logic.Class

... which then triggers the "ghc: unrecognised flags: -I" error and
aborts the installation.

Is this an issue with particular versions of GHC or something?

I'm running: Glasgow Haskell Compiler, Version 6.10.4, for Haskell 98,
stage 2 booted by GHC version 6.8.2

Thanks for your help.

- Lyndon


------------------------------

Message: 7
Date: Wed, 6 Jan 2010 13:15:00 +0100
From: Chadda? Fouch? <[email protected]>
Subject: Re: [Haskell-beginners] ghc: unrecognised flags: -I
To: Lyndon Maydwell <[email protected]>
Cc: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset=UTF-8

On Wed, Jan 6, 2010 at 3:19 AM, Lyndon Maydwell <[email protected]> wrote:
> Hi list.
>
> I'm trying to cabal install a few different packages and keep getting
> this error:
>
> ghc: unrecognised flags: -I

Keep in mind that in many font a capitalized i looks uncomfortably
like a small L.

-- 
Jedaï


------------------------------

Message: 8
Date: Wed, 6 Jan 2010 20:22:47 +0800
From: Lyndon Maydwell <[email protected]>
Subject: Re: [Haskell-beginners] ghc: unrecognised flags: -I
To: Chadda? Fouch? <[email protected]>
Cc: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset=UTF-8

Indeed, it's a capital "I" for Include.

On Wed, Jan 6, 2010 at 8:15 PM, Chaddaï Fouché <[email protected]> 
wrote:
> On Wed, Jan 6, 2010 at 3:19 AM, Lyndon Maydwell <[email protected]> wrote:
>> Hi list.
>>
>> I'm trying to cabal install a few different packages and keep getting
>> this error:
>>
>> ghc: unrecognised flags: -I
>
> Keep in mind that in many font a capitalized i looks uncomfortably
> like a small L.
>
> --
> Jedaï
>


------------------------------

Message: 9
Date: Fri, 8 Jan 2010 17:27:03 -0800 (PST)
From: Tim Perry <[email protected]>
Subject: [Haskell-beginners] Help! I can't compile an example program
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

Hi all,

I found an example program that computes grades here: 
http://donsbot.wordpress.com/?s=grades

I copied it to my computer and tried to compile it and if failed. Strangely 
enough, it works on the command line using 'runhaskell'. This makes me think I 
didn't set up the libraries correctly. So I downloaded and re-installed the 
Haskell Platform from:
http://hackage.haskell.org/platform/2009.2.0.2/HaskellPlatform-2009.2.0.2-setup.exe

The problem remains. I included the errors, the source and the results of 
runhaskell below. I hope someone can help me sort out what went wrong.

Thanks,
Tim


C:\Documents and Settings\perry\hs>ghc -O Grades.hs

Grades.o:fake:(.text+0x2f7): undefined reference to 
`containerszm0zi2zi0zi1_DataziMap_Tip_closure'
Grades.o:fake:(.text+0x930): undefined reference to 
`containerszm0zi2zi0zi1_DataziMap_lvl47_closure'
Grades.o:fake:(.text+0xa8b): undefined reference to 
`__stginit_containerszm0zi2zi0zi1_DataziMap_'
Grades.o:fake:(.text+0x219): undefined reference to 
`containerszm0zi2zi0zi1_DataziMap_insertWithKey_info'
Grades.o:fake:(.text+0x504): undefined reference to 
`containerszm0zi2zi0zi1_DataziMap_lookup_info'
Grades.o:fake:(.text+0x90e): undefined reference to 
`containerszm0zi2zi0zi1_DataziMap_polyzugo1_info'
Grades.o:fake:(.text+0x93f): undefined reference to 
`containerszm0zi2zi0zi1_DataziMap_foldr_info'
Grades.o:fake:(.data+0x50): undefined reference to 
`containerszm0zi2zi0zi1_DataziMap_insertWithKey_closure'
collect2: ld returned 1 exit status

C:\Documents and Settings\perry\hs>cat Grades.hs
import Data.Char
import Data.Maybe
import Data.List
import Data.Map hiding (map)
import Text.Printf

main = do
    src <- readFile "grades.txt"
    let pairs   = map (split.words) (lines src)
        grades  = foldr insert empty pairs
    mapM_ (draw grades) (sort (keys grades))
  where
    insert (s, g) = insertWith (++) s [g]
    split [name,mark] = (name, read mark)

draw g s = printf "%s\t%s\tAverage: %f\n" s (show marks) avg
  where
    marks = findWithDefault (error "No such student") s g
    avg   = sum marks / fromIntegral (length marks) :: Double


C:\Documents and Settings\perry\hs>runhaskell Grades.hs
Alonzo  [70.0,90.0,95.0]        Average: 85.0
Bob     [80.0]  Average: 80.0
Eugenio [69.0]  Average: 69.0
Henk    [79.0]  Average: 79.0
Oleg    [77.0]  Average: 77.0
Philip  [73.0]  Average: 73.0
Simon   [94.0,99.0,93.0]        Average: 95.33333333333333

C:\Documents and Settings\perry\hs>


------------------------------

Message: 10
Date: Sat, 9 Jan 2010 04:16:10 -0500
From: "Brandon S. Allbery KF8NH" <[email protected]>
Subject: Re: [Haskell-beginners] Help! I can't compile an example
        program
To: Tim Perry <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"

On Jan 8, 2010, at 20:27 , Tim Perry wrote:
> C:\Documents and Settings\perry\hs>ghc -O Grades.hs


You almost always want ghc --make, which chases library dependencies  
for you.  (runhaskell does this automatically.)  In this case, what  
you're missing, which --make would have added automatically, is "- 
package containers" (or a versioned variant thereof).

-- 
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [email protected]
system administrator [openafs,heimdal,too many hats] [email protected]
electrical and computer engineering, carnegie mellon university    KF8NH


-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 195 bytes
Desc: This is a digitally signed message part
Url : 
http://www.haskell.org/pipermail/beginners/attachments/20100109/33a4d512/PGP.bin

------------------------------

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 19, Issue 5
****************************************

Reply via email to