Re: [Haskell-cafe] Could not find module `Text.Regex'

2010-01-29 Thread zaxis

`cabal install regex-compat` fixes my problem.  thanks!


Lee Houghton-3 wrote:
 
 On 29/01/2010 03:51, zaxis wrote:

 import Text.Regex

 date_by_ntday dateStr ntday = do
  let [y,m,d] = map (\x -  read x::Int) $ splitRegex (mkRegex -)
 dateStr
  

 %ghc --version
 The Glorious Glasgow Haskell Compilation System, version 6.12.1

 Which package(s) do i need to use Text.Regex ?

 Sincerely!
 
 It looks like you want regex-compat:
 
 http://hackage.haskell.org/packages/archive/regex-compat/0.92/doc/html/Text-Regex.html
 
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe
 
 


-
fac n = foldr (*) 1 [1..n]
-- 
View this message in context: 
http://old.nabble.com/Could-not-find-module-%60Text.Regex%27-tp27366745p27367473.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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


[Haskell-cafe] Re: OT: Literature on translation of lambda calculus to combinators

2010-01-29 Thread Nick Smallbone
Job Vranish jvran...@gmail.com writes:

 Ideally we'd like the type of convert to be something like:
 convert :: LambdaExpr - SKIExpr
 but this breaks in several places, such as the nested converts in the RHS of 
 the rule:
 convert (Lambda x (Lambda y e)) | occursFree x e = convert (Lambda x (convert 
 (Lambda y e)))

 A while ago I tried modifying the algorithm to be pure top-down so that it 
 wouldn't have this problem, but I
 didn't have much luck.

 Anybody know of a way to fix this?

The way to do it is, when you see an expression Lambda x e, first
convert e to a combinatory expression (which will have x as a free
variable, and will obviously have no lambdas). Then you don't need
nested converts at all.

Not-really-tested code follows.

Nick

data Lambda = Var String
| Apply Lambda Lambda
| Lambda String Lambda deriving Show

data Combinatory = VarC String
 | ApplyC Combinatory Combinatory
 | S
 | K
 | I deriving Show

compile :: Lambda - Combinatory
compile (Var x) = VarC x
compile (Apply t u) = ApplyC (compile t) (compile u)
compile (Lambda x t) = lambda x (compile t)

lambda :: String - Combinatory - Combinatory
lambda x t | x `notElem` vars t = ApplyC K t
lambda x (VarC y) | x == y = I
lambda x (ApplyC t u) = ApplyC (ApplyC S (lambda x t)) (lambda x u)

vars :: Combinatory - [String]
vars (VarC x) = [x]
vars (ApplyC t u) = vars t ++ vars u
vars _ = []

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


Re: [Haskell-cafe] Non-termination of type-checking

2010-01-29 Thread Nicolas Pouillard
On Thu, 28 Jan 2010 18:32:02 -0800, Ryan Ingram ryani.s...@gmail.com wrote:
 But your example uses a recursive type; the interesting bit about this
 example is that there is no recursive types or function, and yet we
 can encode this loop.

The point is that you get the Fix type by (infintely) unfolding the
type definitions.

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


RE: [Haskell-cafe] big problems with MS Access backends

2010-01-29 Thread Bayley, Alistair
 From: haskell-cafe-boun...@haskell.org 
 [mailto:haskell-cafe-boun...@haskell.org] On Behalf Of Günther Schmidt
 
 I need to use MS Access as a DB-backend. To make it not too 
 easy there 
 are tables with Umlaut Strings in some of the columns.
 
 And Takusen crashes outright.

Can you try Takusen from the darcs repo? It was at darcs.haskell.org, but now 
Ian's temporarily moved all the non-ghc projects to 
http://old-darcs.well-typed.com/, and I haven't found the time to move it to 
code.haskell.org.

I tested with Access and made a bunch of changes to the ODBC driver. It works 
for me :-)

The ODBC tests all pass with Access. Could you run them and see how you get on? 
To build and run the tests:

You probably need to edit the cabal file and comment out modules in the 
Other-modules: section for the backends that you don't have, and edit the 
imports and backendTests function in Main.hs.

To build the tests you say:
  setup configure -fbuildtests
  setup build

You will find takusen_tests.exe under dist\build\takusen_tests. Run with this 
command line:
  takusen_tests odbc noperf DSN=takusen  

(noperf just means don't run the performance tests, just the functional tests)

This assumes you have created an ODBC DSN called takusen, which points to an 
Access database.

Alistair
*
Confidentiality Note: The information contained in this message,
and any attachments, may contain confidential and/or privileged
material. It is intended solely for the person(s) or entity to
which it is addressed. Any review, retransmission, dissemination,
or taking of any action in reliance upon this information by
persons or entities other than the intended recipient(s) is
prohibited. If you received this in error, please contact the
sender and delete the material from any computer.
*

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


Re: [Haskell-cafe] Very imperfect hash function

2010-01-29 Thread John Lato
 From: Hans Aberg hab...@math.su.se

 On 28 Jan 2010, at 20:07, Steve Schafer wrote:

 The data are currently in a large lookup table. To save space, I'd
 like
 to convert that into a sort of hash function:

 hash :: key - value

 My question is this: Is there any kind of generic approach that can
 make
 use of the knowledge about the internal redundancy of the keys to come
 up with an efficient function?

 There are minimal perfect hash functions; there are some libraries
 mentioned here, though they are not in Haskell code:
   http://en.wikipedia.org/wiki/Perfect_hash_function

 This is suitable when you do a lot of lookups with few key updates. An
 alternative might be Data.Map, where lookups have time complexity
 O(log n), n = size of map.

The minimal perfect hash function looks like the real algorithmic
solution, but I would just use Data.IntMap for this.

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


[Haskell-cafe] Input request: which interface for Web Application Interface

2010-01-29 Thread Michael Snoyman
I've made a few more changes to WAI since my last update. Namely, request
and response headers are now their own datatype. As with Method, HttpVersion
and Status, they both provide constructors for everything else and have
functions to convert to/from bytestrings. This makes the package a bit more
consistent, as well as giving us some more type safety and perhaps even some
(negligible) performance gains. (Thanks again to Mark for the idea.)

Another feature that will be added is a wrapper module. This will provide
convenience functions for accessing the request body and generating a
response body via other methods. For example, it will provide a lazy I/O
interface for the request body and generating a response from a lazy
bytestring. (Thanks to Nicolas for the idea.)

The reason that it has not been written yet is because I have two options
available for the request and response body interfaces. One is a direct copy
of Hyena's enumerators, sans impredicative types. The other is a simpler I/O
interface. Here are the benefits of each as I see it:

Hyena enumerators:
Provide accumulating parameter support.
Provide mechanism for early response termination.
Probably makes the server side of the request body simpler to program.

Simple interface:
More obvious how to use it.
Makes the application side of the request body simpler to program.

You can see the code for each in github:
Enumerator: http://github.com/snoyberg/wai/blob/enumerator/Network/Wai.hs
Simple: http://github.com/snoyberg/wai/blob/master/Network/Wai.hs

I'm currently leaning to the enumerator approach, since it should be simple
application side to wrap the enumerator into a more tractable interface.
However, I'd like to hear people's opinions on this. To get an idea of how
this changes code, I'm attaching a diff of the two branches, which includes
a simple HTTP server and application.

I'm also aware that documentation is sorely lacking right now; once we come
to a decision on this piece of the interface, I'll add the wrapper functions
and comment appropriately. Commenting at this stage would be putting the
cart before the horse.

Michael
diff --git a/Network/Wai.hs b/Network/Wai.hs
index 9807c44..4466b2c 100644
--- a/Network/Wai.hs
+++ b/Network/Wai.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE ExistentialQuantification #-}
+{-# LANGUAGE Rank2Types #-}
 module Network.Wai
 ( -- * Data types
   -- ** Request method
@@ -23,6 +23,8 @@ module Network.Wai
 , Status (..)
 , statusCode
 , statusMessage
+  -- * Enumerator
+, Enumerator
   -- * WAI interface
 , Request (..)
 , Response (..)
@@ -233,6 +235,8 @@ statusMessage Status405 = B8.pack Method Not Allowed
 statusMessage Status500 = B8.pack Internal Server Error
 statusMessage (Status _ m) = m
 
+type Enumerator a = (a - B.ByteString - IO (Either a a)) - a - IO a
+
 data Request = Request
   {  requestMethod  :: Method
   ,  httpVersion:: HttpVersion
@@ -242,7 +246,7 @@ data Request = Request
   ,  serverPort :: Int
   ,  httpHeaders:: [(RequestHeader, B.ByteString)]
   ,  urlScheme  :: UrlScheme
-  ,  requestBody:: IO (Maybe B.ByteString)
+  ,  requestBody:: forall a. Enumerator a
   ,  errorHandler   :: String - IO ()
   ,  remoteHost :: String
   }
@@ -250,7 +254,7 @@ data Request = Request
 data Response = Response
   { status:: Status
   , headers   :: [(ResponseHeader, B.ByteString)]
-  , body  :: Either FilePath ((B.ByteString - IO ()) - IO ())
+  , body  :: forall a. Either FilePath (Enumerator a)
   }
 
 type Application = Request - IO Response
diff --git a/Network/Wai/Handler/SimpleServer.hs 
b/Network/Wai/Handler/SimpleServer.hs
index 72f7280..6e4d3ba 100644
--- a/Network/Wai/Handler/SimpleServer.hs
+++ b/Network/Wai/Handler/SimpleServer.hs
@@ -21,7 +21,6 @@ import Network.Wai
 import qualified System.IO
 
 import qualified Data.ByteString as BS
-import qualified Data.ByteString.Lazy as BL
 import qualified Data.ByteString.Char8 as B8
 import Network
 ( listenOn, accept, sClose, PortID(PortNumber), Socket
@@ -135,14 +134,16 @@ parseRequest port lines' handle remoteHost' = do
 , remoteHost = remoteHost'
 }
 
-requestBodyHandle :: Handle - MVar Int - IO (Maybe BS.ByteString)
-requestBodyHandle h mlen = modifyMVar mlen helper where
-helper :: Int - IO (Int, Maybe BS.ByteString)
-helper 0 = return (0, Nothing)
-helper len = do
+requestBodyHandle :: Handle - MVar Int - Enumerator a
+requestBodyHandle h mlen iter accum = modifyMVar mlen (helper accum) where
+helper a 0 = return (0, a)
+helper a len = do
 bs - BS.hGet h len
 let newLen = len - BS.length bs
-return (newLen, Just bs)
+ea' - iter a bs
+case ea' of
+Left a' - return (newLen, a')
+Right a' - helper a' newLen
 
 parseFirst :: (StringLike s, MonadFailure InvalidRequest m) =
   s
@@ -167,8 +168,9 @@ sendResponse h res = do
 

Re: [Haskell-cafe] Re: Non-termination of type-checking

2010-01-29 Thread Dan Doel
On Friday 29 January 2010 2:56:31 am o...@okmij.org wrote:
 Here is a bit more simplified version of the example. The example has
 no value level recursion and no overt recursive types, and no impredicative
 polymorphism. The key is the observation, made earlier, that two types
   c (c ()) and R (c ())
 unify when c = R. Although the GADTs R c below is not recursive, when
 we instantiate c = R, it becomes recursive, with the negative
 occurrence. The trouble is imminent.
 
 We reach the conclusion that an instance of a non-recursive GADT
 can be a recursive type. GADT may harbor recursion, so to speak.
 
 The code below, when loaded into GHCi 6.10.4, diverges on
 type-checking. It type-checks when we comment-out absurd.
 
 
 {-# LANGUAGE GADTs, EmptyDataDecls #-}
 
 data False-- No constructors
 
 data R c where-- Not recursive
 R :: (c (c ()) - False) - R (c ())
 
 -- instantiate c to R, so (c (c ())) and R (c ()) coincide
 -- and we obtain a recursive type
 --mu R. (R (R ()) - False) - R (R ())
 
 cond_false :: R (R ()) - False
 cond_false x@(R f) = f x
 
 absurd :: False
 absurd = cond_false (R cond_false)

This example is pretty weird in my view. For instance, consider:

  data S x

  type family T x :: *
  type family T () = R ()
  type family T (R ()) = S ()

  s'elim :: S x - False
  s'elim x = undefined -- case x of {}

  what :: T (T ()) - False
  what = s'elim

Now, we have T () ~ R (), and T (T ()) ~ S (R ()), so R (T ()) ~ R (R ()), no? 
And T :: * - *, so it should be an acceptable argument to R. So, one would 
expect that I could write:

  r :: R (R ()) -- R (T ())
  r = R what

However, neither of those signatures for r goes through. With the second, I 
get a complaint that:

  Couldn't match expected type `S ()' against inferred type `()'
Expected type: S (S ())
Inferred type: T (T ())

though I'm not quite sure how it gets that error. With the R (R ()) choice, I 
get:

  Couldn't match expected type `R (R ())'
 against inferred type `T (T ())'
NB: `T' is a type function, and may not be injective

but the injectivity GHC seems to be relying on isn't F x ~ F y = x ~ y, but:

  f T ~ g T = f ~ g

or injectivity of ($ ()) in this case, so to speak. But this seems like a 
significantly weirder thing to take for granted than injectivity of type 
constructors. I suppose it's sufficient to limit c (in the constructor R's 
definition) to accept only data type constructors, but that's significantly 
more limiting than I'd expect to be the case (although, it does appear to be 
what GHC does).

Anyhow, I don't particularly find this 'scary', as Haskell/GHC isn't 
attempting to be an environment for theorem proving, and being able to encode 
(\x - x x) (\x - x x) through lack of logical consistency isn't giving up 
anything that hasn't already been given up multiple times (through general 
recursion, error and negative types at least). Non-termination of type 
checking is undesirable, of course.

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


[Haskell-cafe] Include creation date in Haddock documentation

2010-01-29 Thread Dennis Walter
Hi all,

I wonder if it is possible to have Haddock include the date and time
at which the documentation was generated. Ideally this should only
occur on index.html, but to have it in any file (e.g. in the footer)
would be OK, too. I couldn't find any information about dates in the
documentation.

Documentation is created via Cabal:
  cabal haddock --executables --hyperlink-source

Right now I include a token in the Cabal description field of the
package, and sed-replace it afterwards, which is of course ugly.

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


Re: [Haskell-cafe] Very imperfect hash function

2010-01-29 Thread Hans Aberg

On 29 Jan 2010, at 12:52, John Lato wrote:


There are minimal perfect hash functions; there are some libraries
mentioned here, though they are not in Haskell code:
  http://en.wikipedia.org/wiki/Perfect_hash_function

This is suitable when you do a lot of lookups with few key updates.  
An

alternative might be Data.Map, where lookups have time complexity
O(log n), n = size of map.


The minimal perfect hash function looks like the real algorithmic
solution, but I would just use Data.IntMap for this.


That looks interesting too. Yet another idea: use arrays
  http://haskell.org/haskellwiki/Arrays
Then build a hash table, say just taking mod k n, and have values in  
some lookup map. If n  set of keys, average time complexity is O(1),  
and arrays should be very fast.


  Hans


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


Re: [Haskell-cafe] Very imperfect hash function

2010-01-29 Thread John Lato
On Fri, Jan 29, 2010 at 12:46 PM, Hans Aberg hab...@math.su.se wrote:
 On 29 Jan 2010, at 12:52, John Lato wrote:

 There are minimal perfect hash functions; there are some libraries
 mentioned here, though they are not in Haskell code:
  http://en.wikipedia.org/wiki/Perfect_hash_function

 This is suitable when you do a lot of lookups with few key updates. An
 alternative might be Data.Map, where lookups have time complexity
 O(log n), n = size of map.

 The minimal perfect hash function looks like the real algorithmic
 solution, but I would just use Data.IntMap for this.

 That looks interesting too. Yet another idea: use arrays
  http://haskell.org/haskellwiki/Arrays
 Then build a hash table, say just taking mod k n, and have values in some
 lookup map. If n  set of keys, average time complexity is O(1), and arrays
 should be very fast.

I just want to be sure I understand this.  For this plan, you aren't
intending to use a perfect hash function at all, correct?  Are you
basically just suggesting to stick everything in an array with the key
as an index?  Or are you suggesting an actual hash table?  If it's the
latter, I'm not certain where the array fits into the picture.  I'm
pretty sure I'm missing something here.

In either case, I don't think this would be as good as what I thought
was your original suggestion, i.e. using a minimal perfect hash
function mphf that hashes keys to a value 0..v-1.  With v=number of
values, valArr = array of all values, then

lookup k = valArr ! mphf k

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


Re: [Haskell-cafe] Very imperfect hash function

2010-01-29 Thread Hans Aberg

On 29 Jan 2010, at 15:57, John Lato wrote:


That looks interesting too. Yet another idea: use arrays
 http://haskell.org/haskellwiki/Arrays
Then build a hash table, say just taking mod k n, and have values  
in some
lookup map. If n  set of keys, average time complexity is O(1),  
and arrays

should be very fast.


I just want to be sure I understand this.  For this plan, you aren't
intending to use a perfect hash function at all, correct?


Yes, this is another idea. In a hash table, it is not important to  
have different indices, only that that table entries are as flat as  
possible.



Are you
basically just suggesting to stick everything in an array with the key
as an index?


You still need to fold the key values onto some interval.


Or are you suggesting an actual hash table?


The hash function folds the keys onto an interval. Since you have Int  
values k, you might just use a mod k n function for that.



If it's the
latter, I'm not certain where the array fits into the picture.  I'm
pretty sure I'm missing something here.


There is a module Data.HashTable. The array is just to make lookup  
fast. Like in:

  ST s (STArray s HashKey (Map Key Value))


In either case, I don't think this would be as good as what I thought
was your original suggestion, i.e. using a minimal perfect hash
function mphf that hashes keys to a value 0..v-1.  With v=number of
values, valArr = array of all values, then

lookup k = valArr ! mphf k


Right, but you may have to avoid implementing the perfect hash  
function by yourself, if it is only available in C. :-) There is a  
FFI, though.


  Hans


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


Re: [Haskell-cafe] imaging textbooks?

2010-01-29 Thread Håkon Lorentzen
2010/1/26 Dan Mead d.w.m...@gmail.com:
 Hey all

 Can anyone recommend a good textbook on computer vision or image processing?

 I don't care if it favors Haskell or not, I'm just trying to find a good text.

We used Digital Image Processing, Gonzales  Woods
http://www.amazon.com/Digital-Image-Processing-Rafael-Gonzalez/dp/013168728X
at our university. It is pretty decent.

-- 
Håkon Lorentzen

e-mail: hako...@gmail.com
phone: +47 90539718
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: OT: Literature on translation of lambda calculus to combinators

2010-01-29 Thread Job Vranish
Cool, Thanks :D

also quickcheck says the two algorithms are equivalent :)



On Fri, Jan 29, 2010 at 4:33 AM, Nick Smallbone nick.smallb...@gmail.comwrote:

 Job Vranish jvran...@gmail.com writes:

  Ideally we'd like the type of convert to be something like:
  convert :: LambdaExpr - SKIExpr
  but this breaks in several places, such as the nested converts in the RHS
 of the rule:
  convert (Lambda x (Lambda y e)) | occursFree x e = convert (Lambda x
 (convert (Lambda y e)))
 
  A while ago I tried modifying the algorithm to be pure top-down so that
 it wouldn't have this problem, but I
  didn't have much luck.
 
  Anybody know of a way to fix this?

 The way to do it is, when you see an expression Lambda x e, first
 convert e to a combinatory expression (which will have x as a free
 variable, and will obviously have no lambdas). Then you don't need
 nested converts at all.

 Not-really-tested code follows.

 Nick

 data Lambda = Var String
| Apply Lambda Lambda
| Lambda String Lambda deriving Show

 data Combinatory = VarC String
 | ApplyC Combinatory Combinatory
  | S
 | K
 | I deriving Show

 compile :: Lambda - Combinatory
 compile (Var x) = VarC x
 compile (Apply t u) = ApplyC (compile t) (compile u)
 compile (Lambda x t) = lambda x (compile t)

 lambda :: String - Combinatory - Combinatory
 lambda x t | x `notElem` vars t = ApplyC K t
 lambda x (VarC y) | x == y = I
 lambda x (ApplyC t u) = ApplyC (ApplyC S (lambda x t)) (lambda x u)

 vars :: Combinatory - [String]
 vars (VarC x) = [x]
 vars (ApplyC t u) = vars t ++ vars u
 vars _ = []

 ___
 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] Could not find module `Text.Regex'

2010-01-29 Thread Jason Dagit
On Fri, Jan 29, 2010 at 1:09 AM, zaxis z_a...@163.com wrote:


 `cabal install regex-compat` fixes my problem.  thanks!


For what it's worth, according to the documentation the -compat package is
for easing a transition in the api (which has now been completed).  You may
want to upgrade to a different package now, for instance regex-posix
(which I've found to be in a nice spot between portability and performance).

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


[Haskell-cafe] Community.haskell.org is down

2010-01-29 Thread Neil Mitchell
http://downforeveryoneorjustme.com/community.haskell.org/

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


[Haskell-cafe] C functional programming techniques?

2010-01-29 Thread Maurí­cio CA

Hi, all,

Sorry if this looks weird, but do you know of experiences with
functional programming, or type programming, with C? Using macro
tricks or just good specifications?

I know this is not absurd to a small extent. I've heard of proof
tool certificated C code on the net (although I don't understand
that theory), and I was also able to use what I learned from
Haskell in a few C-like tasks. [*]

So, I imagine if someone has done such kind of experiment
seriously, like others have done with object-oriented programming
(gobject etc.). Google told me nothing.

Thanks,

Maurício

[*] This may actually be interesting. I had to use a proprietary
script language mixing the worst of FORTRAN and C to drive an
application, and I tried to use what I learned from Haskell by,
say, prohibiting side effects out of some isolated code areas that
got well specified input and gave well specified output -- even
if the inside of the block itself was a huge mess. The result
was actually fun to use, and after two years without looking at
that code I was asked to adapt the application to be used inside
another, which I could do in half a day! Maybe I should write a
Why functional programming matters - 2 on that :) It's easy to
show FP is cool with abstract problems, but it's far more cool
when we can show it can save even programmers with no CS theory
background from huge headaches.

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


Re: [Haskell-cafe] Include creation date in Haddock documentation

2010-01-29 Thread David Waern
2010/1/29 Dennis Walter dennis.wal...@gmail.com:
 Hi all,

 I wonder if it is possible to have Haddock include the date and time
 at which the documentation was generated. Ideally this should only
 occur on index.html, but to have it in any file (e.g. in the footer)
 would be OK, too. I couldn't find any information about dates in the
 documentation.

 Documentation is created via Cabal:
  cabal haddock --executables --hyperlink-source

 Right now I include a token in the Cabal description field of the
 package, and sed-replace it afterwards, which is of course ugly.

It's not possible at the moment AFAIK, but we could add it. I've
created a ticket:

  http://trac.haskell.org/haddock/ticket/131

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


Re: [Haskell-cafe] Hierachical abstraction

2010-01-29 Thread Nils Anders Danielsson

On 2010-01-29 01:09, Edward Kmett wrote:

Luke pretty much nailed the summary of what you can parse using Applicative
means. I tend to consider them codata CFGs, because they can have infinite
breadth and depth. However, a 'codata CFG' can handle a much larger class of
languages than CFGs. To that end, it is interesting to consider that to
maximize the ability to successfully parse such degenerate grammars you are
well served to use a traversal that can handle both of those cases. Such a
traversal can be built out of Luke's Omega monad or a logic monad with fair
conjunction/disjunction and provides a straightforward if inefficient
'top-down' parser.


If you restrict the amount of coinduction that you allow, then you can
guarantee termination of parsing:

 http://www.cs.nott.ac.uk/~nad/publications/danielsson-parser-combinators.html

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


[Haskell-cafe] problems installing cabal on windows

2010-01-29 Thread Han Joosten

I recently upgraded to GHC 6.12.1 on my windows system.
Now I have trouble getting cabal right. 
I read the forums, and I got the cabal.exe for windows. I think I followed
the upgrade instructions. However I do not get it all to work. THis is my
version of Cabal:

   C:cabal --version
   cabal-install version 0.6.2
   using version 1.6.0.2 of the Cabal library

However, when I try to install any library, I get:

   C:cabal install graphviz
   cabal: failed to parse output of 'ghc-pkg dump'

I get the feeling that I miss some step during installation, but I cannot
figure out what that should be. 

I am the only user of my windows machine, and I have admin rights. 
Any suggestions are welcome!

Han Joosten
-- 
View this message in context: 
http://old.nabble.com/problems-installing-cabal-on-windows-tp27363309p27363309.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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


Re: [Haskell-cafe] Hierachical abstraction

2010-01-29 Thread Andrew Coppin

Luke Palmer wrote:

On Thu, Jan 28, 2010 at 12:42 PM, Andrew Coppin
andrewcop...@btinternet.com wrote:
  

I wonder if you can make a parser combinator library which is *not* monadic?
And, if you could, in what way would that limit the kinds of things you can
parse?



Absolutely!  I believe both Applicatives and Arrows were originally
invented for parsers.


I have no idea what Applicative is, but I understand that one of the 
main ideas behind Arrows is the ability to analyse the finished computation.


(Also, not all arrows support using the result of an arrow as the 
continuation - and those that do are isomorphic to monads. So it seems 
to be just another example of how limiting what you can do allows you to 
make bigger guarantees...)



I could be mistaken, but at least there are
both Applicative and Arrow parser libraries.  I don't know how to
classify the language that they parse -- it is not strictly
context-free.  It corresponds roughly to context-free where certain
types of infinite chains are allowed.  Anyway they are less expressive
than Parsec, but more efficient and optimizable, for reasons you
correctly identified.
  


Hmm, OK.


So you're interested in structures which are all similar in a way.
  


Basically, yes.

Stuff like... a circle can be represented as a point and a radius. But 
you can also represent it as a vast profusion of straight line segments.


Now I could design an algebraic data type that can represent circles and 
lines, but then how do I guarantee that a particular expression contains 
no circles, only lines? GADTs presumably.


But now suppose that I want not just circles, but *anything* that can 
possibly be reduced to line segments. An algebraic data type, 
generalised or not, has the property that it is closed, and cannot be 
added to once created. (I.e., you can't add new constructors later.)


Interestingly, you can write a class for things that can be turned into 
line segments, and an existential wrapper to type-cast any shape into a 
universal type. But you can't cast it back again. You certainly can't do 
pattern matching on it like you can with a case-expression over a 
regular ADT. I've been pondering this today...



I don't remember the name, but there is a technique where you compose
the features you want and then take its fixed point to get your AST.
You can make a typeclass for each feature that uses it on any data
structure in which it is present.  Not the prettiest thing ever, but
fairly powerful.
  


Interesting... but vague. ;-)

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


Re: [Haskell-cafe] problems installing cabal on windows

2010-01-29 Thread Neil Mitchell
Hi,

Try a:

 cabal update
 cabal install cabal-install

That will set you up with a newer version of Cabal, that should be GHC
6.12 compatible. Make sure you do all this while GHC 6.10 is on the
path, so it knows how to install cabal-install.

Thanks, Neil


On Fri, Jan 29, 2010 at 6:36 PM, Han Joosten han.joos...@atosorigin.com wrote:

 I recently upgraded to GHC 6.12.1 on my windows system.
 Now I have trouble getting cabal right.
 I read the forums, and I got the cabal.exe for windows. I think I followed
 the upgrade instructions. However I do not get it all to work. THis is my
 version of Cabal:

   C:cabal --version
   cabal-install version 0.6.2
   using version 1.6.0.2 of the Cabal library

 However, when I try to install any library, I get:

   C:cabal install graphviz
   cabal: failed to parse output of 'ghc-pkg dump'

 I get the feeling that I miss some step during installation, but I cannot
 figure out what that should be.

 I am the only user of my windows machine, and I have admin rights.
 Any suggestions are welcome!

 Han Joosten
 --
 View this message in context: 
 http://old.nabble.com/problems-installing-cabal-on-windows-tp27363309p27363309.html
 Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

 ___
 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] Hierachical abstraction

2010-01-29 Thread Andrew Coppin

Edward Kmett wrote:
Luke pretty much nailed the summary of what you can parse using 
Applicative means. I tend to consider them codata CFGs, because they 
can have infinite breadth and depth. However, a 'codata CFG' can 
handle a much larger class of languages than CFGs.


Aren't CFGs banned in most countries due to concerns about the ozone layer?

And yes, one of the major motivating ideas behind Arrows were the 
parsers of Swierstra and Duponcheel 
(http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.48.2446).


Doesn't surprise me... ;-)

I'm not sure what such a parser would look like, but by the looks of it 
enough people have made them that I ought to be able to find some 
examples to look at if I search around.


(I must say, while the idea of arrows sounds nice, I've never actually 
tried using them due to the complexity of the mere syntax.)


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


Re: [Haskell-cafe] problems installing cabal on windows

2010-01-29 Thread Daniel Fischer
Am Freitag 29 Januar 2010 19:36:12 schrieb Han Joosten:
 I recently upgraded to GHC 6.12.1 on my windows system.
 Now I have trouble getting cabal right.
 I read the forums, and I got the cabal.exe for windows. I think I
 followed the upgrade instructions. However I do not get it all to work.
 THis is my version of Cabal:

C:cabal --version
cabal-install version 0.6.2
using version 1.6.0.2 of the Cabal library

for ghc-6.12.1, you need cabal-install-0.8, 
http://hackage.haskell.org/package/cabal-install
I'm afraid the Haskell Platform is still for 6.10, I don't know whether 
there's a windows binary around anywhere.


 However, when I try to install any library, I get:

C:cabal install graphviz
cabal: failed to parse output of 'ghc-pkg dump'

 I get the feeling that I miss some step during installation, but I
 cannot figure out what that should be.

 I am the only user of my windows machine, and I have admin rights.
 Any suggestions are welcome!

Install the Haskell Platform with 6.10 and wait before you move to 6.12, or 
try getting cabal 0.8 to work by hand (if google doesn't reveal windows 
binaries).


 Han Joosten

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


Re: [Haskell-cafe] Hierachical abstraction

2010-01-29 Thread Luke Palmer
On Fri, Jan 29, 2010 at 11:45 AM, Andrew Coppin
andrewcop...@btinternet.com wrote:
 But now suppose that I want not just circles, but *anything* that can
 possibly be reduced to line segments.

If all you know about it is that it can be reduced to line segments,
there is no loss of generality in representing that simply as
[LineSegment].  This is getting close to the discussion in my recent
post about the existential typeclass pattern[1] -- there is no need
for extra structure if you cannot use it.

Luke

[1] 
http://lukepalmer.wordpress.com/2010/01/24/haskell-antipattern-existential-typeclass/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Determining application directory

2010-01-29 Thread Scott A. Waterman

'FindBin' is also useful.
http://hackage.haskell.org/package/FindBin

While System.Directory is quite useful, it doesn't contain a function  
to obtain
the directory in which the running program lives.   You can get the  
current

(working) directory (e.g. unix's 'getpwd'), and you can try to find an
executable by searching the $PATH, but you can't find the program you
are currently running.

--ts

On Jan 27, 2010, at 9:06 AM, Matveev Vladimir wrote:


Hi,
I'm writing cross-platform application in Haskell which should be
running under Windows and Linux. Under Linux configuration is stored
in the /etc directory, and under Windows configuration is meant to  
be in

the application directory. So, is there a way to get an application
directory path under Windows? I remember that there is a way to do  
this

using WinAPI, but how to do this Haskell?
___
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: Non-termination of type-checking

2010-01-29 Thread Martin Sulzmann
On Fri, Jan 29, 2010 at 8:56 AM, o...@okmij.org wrote:


 Here is a bit more simplified version of the example. The example has
 no value level recursion and no overt recursive types, and no impredicative
 polymorphism. The key is the observation, made earlier, that two types
c (c ()) and R (c ())
 unify when c = R. Although the GADTs R c below is not recursive, when
 we instantiate c = R, it becomes recursive, with the negative
 occurrence. The trouble is imminent.

 We reach the conclusion that an instance of a non-recursive GADT
 can be a recursive type. GADT may harbor recursion, so to speak.

 The code below, when loaded into GHCi 6.10.4, diverges on
 type-checking. It type-checks when we comment-out absurd.


 {-# LANGUAGE GADTs, EmptyDataDecls #-}

 data False  -- No constructors

 data R c where  -- Not recursive
R :: (c (c ()) - False) - R (c ())

 -- instantiate c to R, so (c (c ())) and R (c ()) coincide
 -- and we obtain a recursive type
 --mu R. (R (R ()) - False) - R (R ())

 cond_false :: R (R ()) - False
 cond_false x@(R f) = f x

 absurd :: False
 absurd = cond_false (R cond_false)


GHC (the compiler terminates)

The following variants terminate, either with GHCi or GHC,

absurd1 :: False
absurd1 = let x = (R cond_false)
  in cond_false x

absurd2 =  R cond_false

absurd3 x = cond_false x

absurd4 :: False
absurd4 = absurd3 absurd2

This suggests there's a bug in the type checker.
If i scribble down the type equation, I can't see
why the type checker should loop here.

-Martin




 ___
 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] problems installing cabal on windows

2010-01-29 Thread Han Joosten

Tanks for replying. 

I now see what went wrong:

I went to  http://www.haskell.org/cabal/release/cabal-install-0.8.0/
http://www.haskell.org/cabal/release/cabal-install-0.8.0/  , because I had
read that I needed the 0.8.0 version. I read the page, and grabbed the
cabal.exe binary, assuming that it would be version 0.8.0. However, it was
the 0.6.2 version. 

Just too bad. 
I changed my path to ghc-6.10.2 again, and tried to install the new
cabal-install version:

   C:\cabal install cabal-install
   Resolving dependencies...
   Configuring old-time-1.0.0.2...
   cabal: Error: some packages failed to install:
   Cabal-1.6.0.3 depends on old-time-1.0.0.2 which failed to install.
   HTTP-4000.0.7 depends on old-time-1.0.0.2 which failed to install.
   cabal-install-0.6.4 depends on old-time-1.0.0.2 which failed to install.
   directory-1.0.0.3 depends on old-time-1.0.0.2 which failed to install.
   old-time-1.0.0.2 failed during the configure step. The exception was:
   sh: runProcess: does not exist (No such file or directory)
   process-1.0.1.1 depends on old-time-1.0.0.2 which failed to install.
   random-1.0.0.1 depends on old-time-1.0.0.2 which failed to install.

I ran into installation problems with old-time before. do not know how to
solve that too. I guess I'll have to wait for ghc 6.12.2 to be launched

Thanks!
-- 
View this message in context: 
http://old.nabble.com/problems-installing-cabal-on-windows-tp27363309p27377354.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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


Re: [Haskell-cafe] C functional programming techniques?

2010-01-29 Thread Erik de Castro Lopo
Maurí­cio CA wrote:

 Hi, all,
 
 Sorry if this looks weird, but do you know of experiences with
 functional programming, or type programming, with C? Using macro
 tricks or just good specifications?

I know there is some type level programming (not strictly functional)
in CCAN:

http://ccan.ozlabs.org/

Not sure if this is what you're after though.

Erik
-- 
--
Erik de Castro Lopo
http://www.mega-nerd.com/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] begginers' questions

2010-01-29 Thread Han Joosten


knyttr wrote:
 
 1. suppose I have a function like this
 
 fun x y z = ...
 fun x y [] = ...
 fun x [] [] = ...
   where
 ...
 
 the where term will be applied just to the last definition. is it
 possible to force it to all fun definitions?
 
The last two parts of your definition of fun will never be reached. The
order of the definition is relevant. The first 'match' will be used. In this
case, even if the third parameter of fun is an empty list, the part fun x y
z =... is a match.
In this case, changing the order to 

fun x [] [] = ...
fun x y  [] = ...
fun x y z = ... 
would make more sence.

however, there still is overlap.  (ghc could generate a warning for this)

now the where part: there are several options:

fun x y z 
| z == [] = ...
| y == [] = ...
| otherwise = ...
  where
...

or using a case expression...

fun x y z = case (x,y,z) of
   (_ , _ , []) - ...
   (_ , [], [_:_]) - ...
   (_ , [_:_], [_:_]) - ... 
   where
  ...
pattern matches do not overlap this way. you could use this pattern matches
also in the previous solution.

Then your second question:


 2. how can I change a field in a list in the most easy way? the only
 solution I found is below. I am not very happy with it - it does too many
 operations just to change one field. 
 
 changeIn array index value = (take (index-1) array)++[value]++(drop index
 array)
 
 
Remember, in haskell you do not 'change' values in variables. Thers is no
such thing as a variable. You probably want a function that takes a list, an
index and a value. It produces a list with all elements from the first list,
only the n-th element is replaced with the given value. I would specify this
as follows:

f x:xs i v 
   | i == 1 = v:xs
   | i  1  = x : (f xs (i-1) v)

but there are probably dozens of other ways to do this. While you are new to
Haskell, do not worry too much about performance. (ghc will surly surprise
you =^D) The main thing is to think functions. If you do that, you will
appreciate Haskell for sure. 






-- 
View this message in context: 
http://old.nabble.com/begginers%27-questions-tp27377905p27378623.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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


Re: [Haskell-cafe] begginers' questions

2010-01-29 Thread Daniel Fischer
Am Freitag 29 Januar 2010 22:38:11 schrieb Han Joosten:
 knyttr wrote:
snip
 fun x [] [] = ...
 fun x y  [] = ...
 fun x y z = ...
 would make more sence.

 however, there still is overlap.  (ghc could generate a warning for
 this)

 now the where part: there are several options:

 fun x y z

 | z == [] = ...
 | y == [] = ...
 | otherwise = ...

   where
 ...


Better use 

fun x y z
| null z= ...
| null y= ...
| otherwise = 
  where



 or using a case expression...

 fun x y z = case (x,y,z) of
(_ , _ , []) - ...
(_ , [], [_:_]) - ...
(_ , [_:_], [_:_]) - ...
where
   ...
 pattern matches do not overlap this way. you could use this pattern
 matches also in the previous solution.

 Then your second question:
  2. how can I change a field in a list in the most easy way? the only
  solution I found is below. I am not very happy with it - it does too
  many operations just to change one field.
 
  changeIn array index value = (take (index-1) array)++[value]++(drop
  index array)

 Remember, in haskell you do not 'change' values in variables. Thers is
 no such thing as a variable. You probably want a function that takes a
 list, an index and a value. It produces a list with all elements from
 the first list, only the n-th element is replaced with the given value.
 I would specify this as follows:

 f x:xs i v

| i == 1 = v:xs
| i  1  = x : (f xs (i-1) v)

 but there are probably dozens of other ways to do this. While you are
 new to Haskell, do not worry too much about performance.

True, but also

*** be aware that lists are NOT arrays ***

trying to use them as such is sure to land you in a deep hole of horrible 
performance sooner or later.

If what you need is an array, use arrays (immutable or mutable, depending 
on the problem at hand). If you need a set, use sets (Data.Set e.g.), if a 
list is appropriate for what you want to do, use the versatile [].

 (ghc will surly
 surprise you =^D) The main thing is to think functions. If you do that,
 you will appreciate Haskell for sure.

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


[Haskell-cafe] Re: Non-termination of type-checking

2010-01-29 Thread Matthieu Sozeau


Le 29 janv. 10 à 02:56, o...@okmij.org a écrit :



Here is a bit more simplified version of the example. The example has
no value level recursion and no overt recursive types, and no  
impredicative

polymorphism. The key is the observation, made earlier, that two types
c (c ()) and R (c ())
unify when c = R. Although the GADTs R c below is not recursive, when
we instantiate c = R, it becomes recursive, with the negative
occurrence. The trouble is imminent.

We reach the conclusion that an instance of a non-recursive GADT
can be a recursive type. GADT may harbor recursion, so to speak.

The code below, when loaded into GHCi 6.10.4, diverges on
type-checking. It type-checks when we comment-out absurd.


{-# LANGUAGE GADTs, EmptyDataDecls #-}

data False  -- No constructors

data R c where  -- Not recursive
   R :: (c (c ()) - False) - R (c ())


Thanks Oleg,

  that's a bit simpler indeed. However, I'm skeptical on
the scoping of c here. Correct me if I'm wrong but in R's
constructor [c] is applied to () so it has to be a type
constructor variable of kind :: * - s. But [c] is also
applied to [c ()] so we must have s = * and c :: * - *.
Now given the application [R (c ())] we must have
[R :: * - *]. Then in [data R c] we must have [c :: *],
hence a contradiction?

  My intuition would be that the declaration is informally
equivalent to the impredicative:

data R (c :: *) where
  R :: forall c' :: * - *, (c' (c' ()) - False) - R (c' ()).

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


Re: [Haskell-cafe] Re: Non-termination of type-checking

2010-01-29 Thread Dan Doel
On Friday 29 January 2010 5:26:28 pm Matthieu Sozeau wrote:
 data R (c :: *) where
R :: forall c' :: * - *, (c' (c' ()) - False) - R (c' ()).

This is what the data declaration is. The c on the first line and the c on the 
second line are unrelated. It's sort of an oddity of GADT declarations; 
variables used between the 'data' and 'where' are just placeholders. With 
KindSignatures enabled, one could also write:

  data R :: * - * where
R :: (c (c ()) - False) - R (c ())

or explicitly quantify c in the constructor's type.

That confused me at first, as well.

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


Re: [Haskell-cafe] Re: Non-termination of type-checking

2010-01-29 Thread Daniel Fischer
Am Freitag 29 Januar 2010 23:26:28 schrieb Matthieu Sozeau:
 Le 29 janv. 10 à 02:56, o...@okmij.org a écrit :
  Here is a bit more simplified version of the example. The example has
  no value level recursion and no overt recursive types, and no
  impredicative
  polymorphism. The key is the observation, made earlier, that two types
  c (c ()) and R (c ())
  unify when c = R. Although the GADTs R c below is not recursive, when
  we instantiate c = R, it becomes recursive, with the negative
  occurrence. The trouble is imminent.
 
  We reach the conclusion that an instance of a non-recursive GADT
  can be a recursive type. GADT may harbor recursion, so to speak.
 
  The code below, when loaded into GHCi 6.10.4, diverges on
  type-checking. It type-checks when we comment-out absurd.
 
 
  {-# LANGUAGE GADTs, EmptyDataDecls #-}
 
  data False  -- No constructors
 
  data R c where  -- Not recursive
 R :: (c (c ()) - False) - R (c ())

 Thanks Oleg,

that's a bit simpler indeed. However, I'm skeptical on
 the scoping of c here.

The c in data R c has nothing to do with the c in
R :: (c (c ()) - False) - R (c ())

It would probably have been less confusing to declare it

data R :: * - * where
R :: (c (c ()) - False) - R (c ())

 Correct me if I'm wrong but in R's
 constructor [c] is applied to () so it has to be a type
 constructor variable of kind :: * - s. But [c] is also
 applied to [c ()] so we must have s = * and c :: * - *.
 Now given the application [R (c ())] we must have
 [R :: * - *]. Then in [data R c] we must have [c :: *],
 hence a contradiction?

My intuition would be that the declaration is informally
 equivalent to the impredicative:

 data R (c :: *) where
R :: forall c' :: * - *, (c' (c' ()) - False) - R (c' ()).

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


Re: [Haskell-cafe] Linguistic hair-splitting

2010-01-29 Thread Conal Elliott
I call it an m or (more specifically) an Int m or a list of Int.  For
instance, a list or an Int list or a list of Int.  - Conal

On Wed, Jan 27, 2010 at 12:14 PM, Luke Palmer lrpal...@gmail.com wrote:

 On Wed, Jan 27, 2010 at 11:39 AM, Jochem Berndsen joc...@functor.nl
 wrote:
  Now, here's the question: Is is correct to say that [3, 5, 8] is a
  monad?
 
  In what sense would this be a monad? I don't quite get your question.

 I think the question is this:  if m is a monad, then what do you call
 a thing of type m Int, or m Whatever.

 Luke
 ___
 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] Linguistic hair-splitting

2010-01-29 Thread Conal Elliott
I don't like this bias toward singling out Monad among all of the type
classes, thereby perpetuating the misleading mystique surrounding Monad.  If
you're going to call [3,5,8] a monadic value, then please give equal time
to other type classes by also calling [3,5,8] a functorial value
(functorific?), an applicative value, a monoidal value, a foldable
value (foldalicious?), a traversable value, a numeric value (see the
applicative-numbers package), etc.  Similarly when referring to values of
other types that happen to be monads as well as other type classes.

   - Conal

On Wed, Jan 27, 2010 at 12:17 PM, Jochem Berndsen joc...@functor.nl wrote:

 Luke Palmer wrote:
  On Wed, Jan 27, 2010 at 11:39 AM, Jochem Berndsen joc...@functor.nl
 wrote:
  Now, here's the question: Is is correct to say that [3, 5, 8] is a
  monad?
  In what sense would this be a monad? I don't quite get your question.
 
  I think the question is this:  if m is a monad, then what do you call
  a thing of type m Int, or m Whatever.

 Ah yes, I see. It's probably the most common to call this a monadic
 value or monadic action. As Daniel pointed out, the type constructor
 itself is called a monad (e.g., Maybe).

 Jochem

 --
 Jochem Berndsen | joc...@functor.nl
 ___
 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] Re: where is the eros distribution

2010-01-29 Thread Conal Elliott
Odd.  Looks like most of the packages on d.h.o evaporated.  I'll push the
repo to a new location.   - Conal

On Sat, Jan 23, 2010 at 10:38 AM, Thomas Hartman tphya...@gmail.com wrote:

 I was inspired by the google tech talk and would like to install and
 play with eros, but the

 http://darcs.haskell.org/packages/Eros/dist/

 address pointed to at

 http://www.haskell.org/haskellwiki/Eros

 appears to be obsolete.

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


[Haskell-cafe] Why cannot i add the `let` declaration ?

2010-01-29 Thread zaxis

find_the_day sDay 0 = sDay
find_the_day sDay nDay = 
if (is_trade_day $ nextDay sDay)
then find_the_day (nextDay sDay) (nDay - 1)
else find_the_day (nextDay sDay) nDay

nextDay sDay = addDays 1 sDay

The above code works fine. But the following always reports `compiling
error`:

find_the_day sDay 0 = sDay
find_the_day sDay nDay = 
let nextDay = addDays 1 sDay
if (is_trade_day $ nextDay)
then find_the_day nextDay (nDay - 1)
else find_the_day nextDay nDay

Any suggestion is appreciated!

-
fac n = foldr (*) 1 [1..n]
-- 
View this message in context: 
http://old.nabble.com/Why-cannot-i-add-the-%60let%60-declaration---tp27381811p27381811.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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