Re: [Haskell-cafe] parsing exercise

2011-01-23 Thread Stephen Tetley
I don't think you can do this simply as you think you would always
have to build a parse tree. If the input is valid Haskell you could
follow Chung-chieh Shan's suggestion, otherwise you could parse to a
skeleton syntax tree - look for work by Jonathan Bacharach on Dylan
macros and Java Syntax Extension.

In practice, if you follow the skeleton syntax tree style you might
find not caring about the details of syntax is almost as much work
as caring about them. I've tried a couple of times to make a skeleton
parser that does paren nesting and little else, but always given up
and just used a proper parser as the skeleton parser never seemed
robust.

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


Re: [Haskell-cafe] Delivery to haskell-platf...@projects.haskell.org

2011-01-23 Thread Magnus Therning
On 23/01/11 00:00, Erik de Castro Lopo wrote:
 Magnus Therning wrote:

 I'm receiving emails saying that email can't be delivered:

 Delivery to the following recipient has been delayed:

  haskell-platf...@projects.haskell.org

 Message will be retried for 1 more day(s)

 Technical details of temporary failure:
 The recipient server did not accept our requests to connect. Learn more
 at http://mail.google.com/support/bin/answer.py?answer=7720
 [projects.haskell.org (1): Connection timed out]

 Who should I turn to to get this sorted out?

 I reported this problem to this and the haskell list on Jan 14th.

 On the 18th, Yitzchak Gale said he'd look into it. Unfortunately
 it is still unresolved.

Ouch!  Yes, I saw your email about a week ago, but I assumed that had
already
been resolved and that I was seeing another failure, but apparently not :-(

Hopefully it'll be resolved soon.

/M

-- 
Magnus Therning  OpenPGP: 0xAB4DFBA4
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus



signature.asc
Description: OpenPGP digital signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] parsing exercise

2011-01-23 Thread Sebastian Fischer
On Sun, Jan 23, 2011 at 4:31 PM, Chung-chieh Shan
ccs...@post.harvard.eduwrote:

 Maybe Text.Show.Pretty.parseValue in the pretty-show package can help?


That's what I was looking for, thanks!

On Sun, Jan 23, 2011 at 5:23 PM, Stephen Tetley stephen.tet...@gmail.com
 wrote:

 I don't think you can do this simply as you think you would always
 have to build a parse tree.


Isn't it enough to maintain a stack of open parens, brackets, char- and
string-terminators and escape chars? Below is my attempt at solving the
problem without an expression parser.

In practice, if you follow the skeleton syntax tree style you might
 find not caring about the details of syntax is almost as much work
 as caring about them. I've tried a couple of times to make a skeleton
 parser that does paren nesting and little else, but always given up
 and just used a proper parser as the skeleton parser never seemed
 robust.


Indeed I doubt that the implementation below is robust and it's too tricky
to be easily maintainable. I include it for reference. Let me know if you
spot an obvious mistake..

Sebastian

splitTLC :: String - [String]
splitTLC = parse 

type Stack  = String

parse :: Stack - String - [String]
parse _   = []
parse st (c:cs) = next c st $ parse (updStack c st) cs

next :: Char - Stack - [String] - [String]
next c []xs = if c==',' then [] : xs else c : xs
next c (_:_) xs = c : xs

infixr 0 :

(:) :: Char - [String] - [String]
c : [] = [[c]]
c : (x:xs) = (c:x):xs

updStack :: Char - Stack - Stack
updStack char stack =
  case (char,stack) of
-- char is an escaped character
(_   ,'\\':xs) - xs  -- the next character is not

-- char is the escape character
('\\', xs) - '\\':xs -- push it on the stack

-- char is the string terminator
('' , '':xs) - xs  -- closes current string literal
('' , ''':xs) - ''':xs  -- ignored inside character
('' , xs) - '':xs  -- opens a new string

-- char is the character terminator
(''' , ''':xs) - xs  -- closes current character literal
(''' , '':xs) - '':xs  -- ignored inside string
(''' , xs) - ''':xs  -- opens a new character

-- parens and brackets
(_   , '':xs) - '':xs  -- are ignored inside strings
(_   , ''':xs) - ''':xs  -- and characters
('(' , xs) - '(':xs  -- new opening paren
(')' , '(':xs) - xs  -- closing paren
('[' , xs) - '[':xs  -- opening bracket
(']' , '[':xs) - xs  -- closing bracket

-- other character don't modify the stack (ignoring record syntax)
(_   , xs) - xs
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Tool for evaluating GHCi lines in a source file

2011-01-23 Thread Steffen Schuldenzucker


Hi,

some time ago I read of a small tool that extracts lines like GHCi 
some_expression from a source file and appends GHCi's output to them.

Now I can't find it again. Does anyone remember its name?

Thanks. Steffen

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


Re: [Haskell-cafe] Delivery to haskell-platf...@projects.haskell.org

2011-01-23 Thread Malcolm Wallace
but I assumed that had already been resolved and that I was seeing  
another failure, but apparently not :-(


Hopefully it'll be resolved soon.


If anyone with sysadmin experience on Debian can suggest why telnet  
localhost 25 hangs on community.haskell.org, even though both exim  
and clamd are running, we would be grateful for some insight.  We just  
don't know what is wrong, so fixing it is not likely to be easy.   
Ideas to haskell-infrastruct...@community.galois.com please.


Regards,
Malcolm

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


[Haskell-cafe] Is SHE (the Strathclyde Haskell Enhancement) portable?

2011-01-23 Thread Maciej Piechotka
It may be strange question but:

 - Is SHE portable (assuming that the compiler have the extensions)?
 - If yes why there is only information how to use it with GHC?

Regards


signature.asc
Description: This is a digitally signed message part
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Delivery to haskell-platf...@projects.haskell.org

2011-01-23 Thread Yitzchak Gale
After a reboot, community.haskell.org is now responding again
on port 25. Please check to see if the mailing lists are
working again.

Thanks,
Yitz

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


Re: [Haskell-cafe] HMatrix Vector/Matrix interpolation ala Matlab interp/interp2 ??

2011-01-23 Thread Claude Heiland-Allen

Hi Phil,

On 22/01/11 23:13, gutti wrote:

- are  t a b c d points or curve parameters ?


a b c d are points, t is the interpolation coefficient (between 0 and 1)


- how does lifting to matrix create a 1d spline to a 2d spline ? -- I don't
see how it works


essentially, it creates a matrix of 1d splines, but now I see that this 
isn't what you wanted...


for interpolated 2d matrix lookup, something like this, perhaps:


-- using the cubic interpolator from earlier in the thread
m @@+ (x, y) =
  let (i, j) = (floor x, floor y)
  (s, t) = (x - fromIntegral i, y - fromIntegral j)
  cx j' = cubic s (m@@(i-1,j')) (m@@(i,j')) (m@@(i+1,j')) 
(m@@(i+2,j'))

  in  cubic t (cx (j-1)) (cx j) (cx (j+1)) (cx (j+2))

test =
  let m = (1616) [0 ..]
  n = 36
  r = 5
  (x0, y0) = (8, 8)
  in  [ m @@+ (x, y)
  | a - [0 .. n - 1]
  , let a' = 2 * pi * fromIntegral a / fromIntegral n
  , let x = x0 + r * cos a'
  , let y = y0 + r * sin a'
  ]


Claude
--
http://claudiusmaximus.goto10.org

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


Re: [Haskell-cafe] Is SHE (the Strathclyde Haskell Enhancement) portable?

2011-01-23 Thread Lennart Augustsson
It probably is portable, but I'd think only GHC has all the necessary
extensions.

On Sun, Jan 23, 2011 at 12:27 PM, Maciej Piechotka uzytkown...@gmail.comwrote:

 It may be strange question but:

  - Is SHE portable (assuming that the compiler have the extensions)?
  - If yes why there is only information how to use it with GHC?

 Regards

 ___
 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] Is SHE (the Strathclyde Haskell Enhancement) portable?

2011-01-23 Thread Conor McBride


On 23 Jan 2011, at 11:27, Maciej Piechotka wrote:


It may be strange question but:

- Is SHE portable (assuming that the compiler have the extensions)?


I have no idea.


- If yes why there is only information how to use it with GHC?


I'm lucky I even know how to get it to work with GHC.

It'd be a bonus if it turned out to be portable. If anyone figures
out how to bolt it on the front of other compilers, I'd be happy to
relay (with attribution) the relevant instructions on the SHE
website.

All the best

Conor


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


Re: [Haskell-cafe] Tool for evaluating GHCi lines in a source file

2011-01-23 Thread Max Rabkin
On Sun, Jan 23, 2011 at 12:35, Steffen Schuldenzucker
sschuldenzuc...@uni-bonn.de wrote:

 Hi,

 some time ago I read of a small tool that extracts lines like GHCi
 some_expression from a source file and appends GHCi's output to them.
 Now I can't find it again. Does anyone remember its name?

No, but I can guess (it's the same as the Python original, modulo
capitalisation):

http://hackage.haskell.org/package/DocTest

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


Re: [Haskell-cafe] Is SHE (the Strathclyde Haskell Enhancement) portable?

2011-01-23 Thread Maciej Piechotka
On Sun, 2011-01-23 at 18:42 +0100, Lennart Augustsson wrote:
 It probably is portable, but I'd think only GHC has all the necessary
 extensions.

I imagine some parts (idiom brackets) works with minimal amount of
extentions - maybe it would be benefitial to have instructions to run
SHE with other compilers?

Regards


signature.asc
Description: This is a digitally signed message part
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Tool for evaluating GHCi lines in a source file

2011-01-23 Thread Steffen Schuldenzucker

On 01/23/2011 06:48 PM, Max Rabkin wrote:

On Sun, Jan 23, 2011 at 12:35, Steffen Schuldenzucker
sschuldenzuc...@uni-bonn.de  wrote:
   

Hi,

some time ago I read of a small tool that extracts lines like GHCi
some_expression from a source file and appends GHCi's output to them.
Now I can't find it again. Does anyone remember its name?
 

No, but I can guess (it's the same as the Python original, modulo
capitalisation):

http://hackage.haskell.org/package/DocTest
   


Exactly what I was looking for, thanks.


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


Re: [Haskell-cafe] HMatrix Vector/Matrix interpolation ala Matlab interp/interp2 ??

2011-01-23 Thread Henning Thielemann


On Sun, 23 Jan 2011, Claude Heiland-Allen wrote:

essentially, it creates a matrix of 1d splines, but now I see that this isn't 
what you wanted...


for interpolated 2d matrix lookup, something like this, perhaps:


Interpolated matrix or vector lookup can of course be written as 
interpolation of sub-matrices or sub-vectors. For lazy matrices and 
vectors this would be almost as efficient.


interp i v =
   vectorIndex (floor i) $
   interpolateVectorSpace (fraction i)
  (Vector.take (n-3) $ Vector.drop 0 v)
  (Vector.take (n-3) $ Vector.drop 1 v)
  (Vector.take (n-3) $ Vector.drop 2 v)
  (Vector.take (n-3) $ Vector.drop 3 v)

(Sorry for the many fictional functions.)

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


Re: [Haskell-cafe] Adding a builder to the bytestring package?

2011-01-23 Thread John Millikin
Patch done and sent to the bytestring maintainers. For the interested,
here's the benchmark chart for binary, cereal, and
blaze-builder/bytestring:

http://i.imgur.com/xw3TL.png

On Wed, Jan 19, 2011 at 15:30, Johan Tibell johan.tib...@gmail.com wrote:
 On Thu, Jan 20, 2011 at 12:16 AM, John Millikin jmilli...@gmail.com wrote:
 blaze-builder already implements the binary builder interface, minus
 the putWord* functions. I think those would be trivial to reimplement
 on top of Write.

 Since it sounds like everyone agrees with / has already thought of
 moving Builder into bytestring, I'll start poking at a patch. Who is
 the current patch-reviewer for binary and bytestring?

 I'd suggest addressing the patch to Don Stewart, Duncan Coutts, and
 Lennart Kolmodin.

 Johan


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


[Haskell-cafe] ANN: follower 0.0.1

2011-01-23 Thread R . Emre Başar
Hello Cafe,

I'm happy to announce the first version of the anonymous Twitter following
tool: follower

Basically the tool allows you to follow people's tweets without having a
Twitter account. It keeps a list of the people you follow and keeps track of
the tweets you already saw.

Thanks to the authors of those nice libraries on hackage, it's just a little
more than a hundred lines (probably would be much less using the right
*morphisms) hacked up in an hour or so.

Any comments, bug reports, rants, requests and patches are welcome.

Get it from hackage: http://hackage.haskell.org/package/follower

-- 
R. Emre Başar
İstanbul Bilgi University
Department of Computer Science


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


Re: [Haskell-cafe] Is SHE (the Strathclyde Haskell Enhancement) portable?

2011-01-23 Thread Conor McBride


On 23 Jan 2011, at 18:19, Maciej Piechotka wrote:


On Sun, 2011-01-23 at 18:42 +0100, Lennart Augustsson wrote:

It probably is portable, but I'd think only GHC has all the necessary
extensions.


I imagine some parts (idiom brackets) works with minimal amount of
extentions - maybe it would be benefitial to have instructions to run
SHE with other compilers?


Yes, idiom brackets, default superclass instances, that sort of
stuff is all good clean H98 fun.

I'm open to code and/or doc patches, but I'm unlikely to have time
to take the initiative.

All the best

Conor


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


Re: [Haskell-cafe] Adding a builder to the bytestring package?

2011-01-23 Thread Conrad Parker
On 24 January 2011 07:29, John Millikin jmilli...@gmail.com wrote:
 Patch done and sent to the bytestring maintainers. For the interested,
 here's the benchmark chart for binary, cereal, and
 blaze-builder/bytestring:

 http://i.imgur.com/xw3TL.png

Can has units?

Conrad.


 On Wed, Jan 19, 2011 at 15:30, Johan Tibell johan.tib...@gmail.com wrote:
 On Thu, Jan 20, 2011 at 12:16 AM, John Millikin jmilli...@gmail.com wrote:
 blaze-builder already implements the binary builder interface, minus
 the putWord* functions. I think those would be trivial to reimplement
 on top of Write.

 Since it sounds like everyone agrees with / has already thought of
 moving Builder into bytestring, I'll start poking at a patch. Who is
 the current patch-reviewer for binary and bytestring?

 I'd suggest addressing the patch to Don Stewart, Duncan Coutts, and
 Lennart Kolmodin.

 Johan


 ___
 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] building hslogger error windows

2011-01-23 Thread Gang Yu
Hi cafe,

   I just get a build error on install config-file (which depends on
hslogger),

C:\Documents and Settings\lenovocabal install hslogger
Resolving dependencies...
Downloading hslogger-1.1.1...
Configuring hslogger-1.1.1...
Preprocessing library hslogger-1.1.1...
Preprocessing executables for hslogger-1.1.1...
Building hslogger-1.1.1...

src\System\Log\Handler\Rotating.hs:48:7:
Could not find module `System.FilePath.Windows':
  It is a member of the hidden package `filepath-1.1.0.4'.
  Perhaps you need to add `filepath' to the build-depends in your .cabal
fil
e.
  Use -v to see a list of the files searched for.
cabal: Error: some packages failed to install:
hslogger-1.1.1 failed during the building phase. The exception was:
ExitFailure 1

I am using platform-2.0, How can I solve it?

Thanks in advance

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


Re: [Haskell-cafe] Adding a builder to the bytestring package?

2011-01-23 Thread John Millikin
No units -- I generated the chart with Progression, which by default
normalises the data so the first library (here, binary) in each
benchmark is 1.0. It can also generate absolute-time charts:

Runtime in seconds, grouped by benchmark: http://i.imgur.com/f0EOa.png

Runtime in seconds, grouped by library: http://i.imgur.com/PXW97.png

Benchmark source files attached, if you'd like to poke at them.

On Sun, Jan 23, 2011 at 17:21, Conrad Parker con...@metadecks.org wrote:
 On 24 January 2011 07:29, John Millikin jmilli...@gmail.com wrote:
 Patch done and sent to the bytestring maintainers. For the interested,
 here's the benchmark chart for binary, cereal, and
 blaze-builder/bytestring:

 http://i.imgur.com/xw3TL.png

 Can has units?

 Conrad.
module Main where

import Control.DeepSeq
import Data.Monoid

import Criterion.Types
import Progression.Config
import Progression.Main

import qualified Data.ByteString as B
import qualified Data.ByteString.Lazy as BL

import qualified Data.Binary.Builder as Binary

instance NFData B.ByteString

instance NFData BL.ByteString where
	rnf a = rnf (BL.toChunks a)

bytes_100 :: B.ByteString
bytes_100 = B.replicate 100 0x61

build_strict :: Int - B.ByteString
build_strict n = BL.toStrict (Binary.toLazyByteString builder) where
	chunks = replicate n (Binary.fromByteString bytes_100)
	builder = foldr Binary.append Binary.empty chunks

build_lazy :: Int - BL.ByteString
build_lazy n = Binary.toLazyByteString builder where
	chunks = replicate n (Binary.fromByteString bytes_100)
	builder = foldr Binary.append Binary.empty chunks

build_strict_mconcat :: Int - B.ByteString
build_strict_mconcat n = BL.toStrict (Binary.toLazyByteString builder) where
	chunks = replicate n (Binary.fromByteString bytes_100)
	builder = mconcat chunks

build_lazy_mconcat :: Int - BL.ByteString
build_lazy_mconcat n = Binary.toLazyByteString builder where
	chunks = replicate n (Binary.fromByteString bytes_100)
	builder = mconcat chunks

benchmarks :: [Benchmark]
benchmarks =
	[ bench strict (nf build_strict 1000)
	, bench strict +mconcat (nf build_strict_mconcat 1000)
	, bench lazy (nf build_lazy 1000)
	, bench lazy +mconcat (nf build_lazy_mconcat 1000)
	]

main :: IO ()
main = defaultMainWith config (bgroup all benchmarks)

config = Config
	{ cfgMode = Nothing
	, cfgRun = RunSettings [] (Just 01_binary)
	, cfgGraph = mempty
	}
module Main where

import Control.DeepSeq
import Data.Monoid

import Criterion.Types
import Progression.Config
import Progression.Main

import qualified Data.ByteString as B
import qualified Data.ByteString.Lazy as BL

import qualified Blaze.ByteString.Builder as Blaze
import qualified Blaze.ByteString.Builder.Internal.Types as Blaze

instance NFData B.ByteString

instance NFData BL.ByteString where
	rnf a = rnf (BL.toChunks a)

bytes_100 :: B.ByteString
bytes_100 = B.replicate 100 0x61

builderEmpty :: Blaze.Builder
builderEmpty = Blaze.Builder id
{-# INLINE builderEmpty #-}

builderAppend :: Blaze.Builder - Blaze.Builder - Blaze.Builder
builderAppend (Blaze.Builder b1) (Blaze.Builder b2) = Blaze.Builder (b1 . b2)
{-# INLINE builderAppend #-}

builderConcat :: [Blaze.Builder] - Blaze.Builder
builderConcat = foldr builderAppend builderEmpty
{-# INLINE builderConcat #-}

build_strict :: Int - B.ByteString
build_strict n = Blaze.toByteString builder where
	chunks = replicate n (Blaze.fromByteString bytes_100)
	builder = builderConcat chunks

build_lazy :: Int - BL.ByteString
build_lazy n = Blaze.toLazyByteString builder where
	chunks = replicate n (Blaze.fromByteString bytes_100)
	builder = builderConcat chunks

build_strict_mconcat :: Int - B.ByteString
build_strict_mconcat n = Blaze.toByteString builder where
	chunks = replicate n (Blaze.fromByteString bytes_100)
	builder = mconcat chunks

build_lazy_mconcat :: Int - BL.ByteString
build_lazy_mconcat n = Blaze.toLazyByteString builder where
	chunks = replicate n (Blaze.fromByteString bytes_100)
	builder = mconcat chunks

benchmarks :: [Benchmark]
benchmarks =
	[ bench strict (nf build_strict 1000)
	, bench strict +mconcat (nf build_strict_mconcat 1000)
	, bench lazy (nf build_lazy 1000)
	, bench lazy +mconcat (nf build_lazy_mconcat 1000)
	]

main :: IO ()
main = defaultMainWith config (bgroup all benchmarks)

config = Config
	{ cfgMode = Nothing
	, cfgRun = RunSettings [] (Just 03_blaze)
	, cfgGraph = mempty
	}
module Main where

import Control.DeepSeq
import Data.Monoid

import Criterion.Types
import Progression.Config
import Progression.Main

import qualified Data.ByteString as B
import qualified Data.ByteString.Lazy as BL

import qualified Data.Serialize.Builder as Cereal

instance NFData B.ByteString

instance NFData BL.ByteString where
	rnf a = rnf (BL.toChunks a)

bytes_100 :: B.ByteString
bytes_100 = B.replicate 100 0x61

build_strict :: Int - B.ByteString
build_strict n = Cereal.toByteString builder where
	chunks = replicate n (Cereal.fromByteString bytes_100)
	builder = foldr Cereal.append Cereal.empty chunks

build_lazy :: 

Re: [Haskell-cafe] building hslogger error windows

2011-01-23 Thread Daniel Fischer
On Monday 24 January 2011 02:33:17, Gang Yu wrote:
 Hi cafe,

I just get a build error on install config-file (which depends on
 hslogger),

 C:\Documents and Settings\lenovocabal install hslogger
 Resolving dependencies...
 Downloading hslogger-1.1.1...

You can try with hslogger-1.1.0, which built on 6.12 and 7.0 on hackage, or 
maybe with hslogger-1.1.2 (which hasn't yet been built on hackage since it 
was uploaded only yesterday).
hslogger-1.1.1 had the same build failure on hackage.


 I am using platform-2.0, How can I solve it?

 Thanks in advance

 Gang


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


Re: [Haskell-cafe] Proposal: Applicative = Monad: Call for consensus

2011-01-23 Thread Tyson Whitehead
On January 21, 2011 14:01:36 Ryan Ingram wrote:
 Interesting little paper, Tyson.

Hi Ryan,

Thanks for comments and kind words.

 I think what a programmer actually wants from ambiguity resolution is
 something *predictable*; C++'s system is definitely stretching the
 boundaries of predictability, but any case where I have to break out a
 calculator to decide whether the compiler is going to choose
 specification A or specification B for my program seems like a
 failure.  I'd much rather the solution wasn't always 'the most
 probable' but at least was easy for me to figure out without thinking
 too hard.

I think you really hit the nail on the head there.  To be useful at all, it is 
absolutely critical that you don't have to reach for your calculator.

Fortunately I believe this is the case.  The basic result of the paper was 
that assuming

 - self-similarity (functional programming) and
 - finite-length (typed programs)

you get

  p(n) = 1 / 2^{2n-1)

as the probability of a specific shape composed of n elementary components.

Note that the measure is defined on the shape: the way elementary types are 
composed, not what they are.  Double and Char are indistinguishable from a 
shapes perspective, Int - Double - Char and (Int - Double) - Char are not.

An example of the probabilities give same types (shapes) would then be

  Double: p(1) = 1/2  (elementary components: Double)
  Char: p(1) = 1/2  (elementary components: Char)
  [Int]: p(2) = 1/8  (elementary components: [], Int)
  [Char] - IO (): p(5) = 1/512  (elementary components: [], Char, -, IO, ())

As p(n) is monotonically decreasing function in n, the more elementary types 
the shape is composed of, the less probable it is.

I really don't think there could be a much more pleasing result in terms of a 
predictable measure.  It is very simple, and I believe it corresponds well to 
our intuition.  The more stuff in a type, the more complex it is.

It may seem strange to have went to such ends for such a simple result, but 
that is just because these simple examples don't show the depth.  Specifically

 - we gained the ability to encode the intuition into a piece of software, and
 - we can now go beyond where our intuition starts to break down.

To see this last point, consider the shapes represented by Double vs Double - 
Int.  The formulation says the former shape will arise more frequently in 
programs, and I imagine we agree.  But are we more likely to see the shape

  (a - b -  a) - a - [b] - a

where a and b are place holders for any internal shape, or

  Int - Char - Int

Suddenly it is not so easy for us.  The former is a more complex composition, 
but it is also a less rigid composition.  The formulation has no such problem.

 The goal is to easily know when I have to manually specify ambiguity
 resolution and when I can trust the compiler to do it for me.  I
 didn't completely follow the math in your paper, so maybe it turns out
 simply if it was implemented, but it wasn't clear to me.  At the
 least, I think you should add examples of the types of ambiguity
 resolution you'd like the compiler to figure out and what your
 probability measure chooses as the correct answer in each case.

The specific ambiguous situation I was looking at resolving when I came up with 
the framework was figuring out what application operator to use.

Consider various applications incorporating a computation context c (e.g., [])

  \f - f :: (a - b) - a - b

  \f - fmap f :: (a - b) - c a - c b

  \f - f . pure :: (c a - b) - a - b

  \f - apply f :: c (a - b) - c a - c b
  \f - apply f . pure :: c (a - b) - (a - c b)
  \f - apply f . pure . pure :: c (c a - b)) - a - c b

  \f - join . func f :: (a - c b) - c a - c b
  \f - join . apply f :: c (a - c b) - c a - c b
  \f - join . apply f . pure :: c (a - c b) - a - c b
  \f - join . apply f . pure . pure :: c (ca - cb) - a - c b

where I've listed them in order of increasing structure requirements on c (the 
bottom four requiring a monad, the prior three require applicative, etc.)

In any one situation, more than one application may be possible (such as the 
under, over, state, wear example mentioned by Conor).  I want a 
rigorous argument for ordering these to follow the least surprise principal.

I probably should be more specific about this in the paper, but I really liked 
the framework, and didn't want to pigeon hole it to this specific application.

Cheers!  -Tyson


signature.asc
Description: This is a digitally signed message part.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe