Re: [Haskell-cafe] Typechecking Using GHC API

2011-12-17 Thread Daniel Schoepe
On Tue, 13 Dec 2011 18:16:17 +0100, Sh NJP shayan@gmail.com wrote:
 I do some pre-processing on a normal Haskell code ( -F ). The pre-processor
 needs to know the type of each expression.
 What are the possibilities to do so?
 Can I use GHC API to employ GHC type checker? If yes, any good tutorial?
 Is it too naive to think of a function, f :: String - AnnotatedAST , that
 takes Haskell code and returns its corresponding abstract syntax tree
 annotated with types?

Another, less powerful, but much easier approach would be to use hint,
which also provides some type-checking functionality. Unfortunately, the
results seem to be just Strings:

http://hackage.haskell.org/packages/archive/hint/0.3.3.3/doc/html/Language-Haskell-Interpreter.html#g:7

If you want to see more examples of using the GHC API, you could also
take a look at the ghc-mod repository on github, which uses the GHC API
to provide type information to Emacs:

https://github.com/kazu-yamamoto/ghc-mod

Cheers,
Daniel


pgpBVUtUkkqQF.pgp
Description: PGP signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] German names for kinds and sorts

2011-11-12 Thread Daniel Schoepe
On Sat, 12 Nov 2011 17:05:51 +0100, Robert Clausecker fuz...@gmail.com wrote:
 Most time, it is not really difficult to find an appropriate term for
 concepts of Haskell, like types (Typen) or type classes (Typklassen).
 But I really don't know how to call kinds and sorts in German. Any
 ideas?

I'd go with Arten and Sorten respectively.

Cheers,
Daniel


pgpkgjyy8iFEB.pgp
Description: PGP signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Easiest to use NoSQL storage with Haskell?

2011-11-10 Thread Daniel Schoepe
On Wed, 9 Nov 2011 20:34:11 +0300, dokondr doko...@gmail.com wrote:
 I am wondering if Database.Persist can work with key/value storage such as
 Riak or SimpleDB where records are lists of key/value pairs and any two
 lists can have different keys?
 Is simple implementation of 'persistent'  based on files with key/value
 records possible?
 For example 'persistent' based on KyotoCabinet package?
 (http://hackage.haskell.org/package/KyotoCabinet)http://hackage.haskell.org/package/KyotoCabinet

As far as I know, persistent doesn't depend on any particular backend,
but as far as NoSQL-stuff goes, I think there's only persistent-mongodb
at the moment. I don't know how much work it is to create a new backend
(and if it's worth the effort in your case), but this looks like a good
place to start:

http://hackage.haskell.org/packages/archive/persistent/0.6.4/doc/html/Database-Persist.html#t:PersistBackend

Cheers,
Daniel


pgpJFU0H52TZ9.pgp
Description: PGP signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Easiest to use NoSQL storage with Haskell?

2011-11-09 Thread Daniel Schoepe
On Wed, 9 Nov 2011 13:59:46 +0300, dokondr doko...@gmail.com wrote:
 Hi,
 What  Haskell package to work with NoSQL storage is both mature and easiest
 to use?
 I need persistent storage for simple key/value lists (not complex JSON
 docs).
 CouchDB and Cassandra seems to be overkill for my needs. What about Riak,
 MongoDB,  Voldemort, etc. ?

persistent (part of yesod, but useable without other yesod libraries) is
quite pleasant to use and supports MongoDB:

http://hackage.haskell.org/package/persistent-0.6.4
http://hackage.haskell.org/package/persistent-mongoDB-0.6.3

Cheers,
Daniel


pgpOrSLejqLG4.pgp
Description: PGP signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] howto best use emacs + tiling WM (Xmonad,DWM)

2011-11-04 Thread Daniel Schoepe
On Fri, 4 Nov 2011 11:24:37 -0700, Jason Dagit dag...@gmail.com wrote:
 The default buffer manipulation in emacs is not great.  Take a look at
 things like ido mode:
 http://www.emacswiki.org/emacs/InteractivelyDoThings
 
 It's approximately 3 orders of magnitude better than the default way
 :)

And anything is even better than that in my opinion:

http://www.emacswiki.org/emacs/Anything

`anything-buffers+' from anything-config.el makes switching between
buffers a breeze.

Cheers,
Daniel


pgpkgiMradBZk.pgp
Description: PGP signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Is there a DFA library?

2011-10-11 Thread Daniel Schoepe
On Fri, 7 Oct 2011 15:29:50 -0400, Alex Rozenshteyn rpglove...@gmail.com 
wrote:
 I'm looking for things like minimization, completion, etc. kinda like
 http://www.cis.upenn.edu/~cis639/docs/xfst.html

This library's main purpose seems to be educational, but perhaps it's
useful to you anyway:

http://www3.di.uminho.pt/~jas/Research/HaLeX/HaLeX.html
http://hackage.haskell.org/package/HaLeX

Cheers,
Daniel


pgpN2L7oYwudk.pgp
Description: PGP signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] class and instance

2011-07-10 Thread Daniel Schoepe
On Sun, 10 Jul 2011 11:49:44 +0100, Patrick Browne patrick.bro...@dit.ie 
wrote:
 My main question is in understanding the relationship between the
 arguments of the functions getX and getY in the class and in the
 instance. It seems to me that the constructor Pt 1 2 produces one
 element of type Point which has two components. How does this square
 with the class definition of getX which has two arguments?
 Is there a difference between:
 getX :: p a - a

This applies the type constructor p, in this case Point to the type
variable a. It is not a function that takes two arguments.

A minor clarification: Pt 1 2 produces a value of type (Num a) = Point
a, so a type where the type constructor Point is already applied to
something. Just Point is not a valid type a value can have, but
something that you have to apply to another type, called a type
constructor.

  and
 getX :: p - a - a

This is a function that takes two arguments.

Cheers,
Daniel


pgpHx4UHpkIaI.pgp
Description: PGP signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Class and Instance

2011-06-10 Thread Daniel Schoepe
On Fri, 10 Jun 2011 17:28:22 +0100, Patrick Browne patrick.bro...@dit.ie 
wrote:
 -- Not OK
 -- insert 2 [9,2]

This causes an error, because numeric literals like 2 are polymorphic:

 :t 2
2 :: Num a = a

If you fix the type to Integer, it works as expected:

insert (2 :: Integer) [9,2]

By the way: It's helpful to include the error messages in your mail when
some piece of code doesn't compile.

Cheers,
Daniel


pgpiVLpuLW0ar.pgp
Description: PGP signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Comment Syntax

2011-06-03 Thread Daniel Schoepe
On Fri, 03 Jun 2011 12:19:31 +0300, Guy guytsalmave...@yahoo.com wrote:
 On 03/06/2011 12:01, Malcolm Wallace wrote:
  I believe the motivating example that persuaded the Language Committee to 
  allow these symbols was
--
  which is not of course used anywhere in the standard libraries, but is an 
  extremely nice symbol to have available in user code.
 
 Seeing as no library actually defines such a symbol, is it worth forcing an 
 extra space into comments? [..]

That's not true, xmonad[0] for example defines a ---operator; and I
would find making exceptions for --| and --^ very inconsistent and
annoying.

[0] http://xmonad.org/xmonad-docs/xmonad/XMonad-ManageHook.html#v%3A--%3E


pgp8FyrB33uh7.pgp
Description: PGP signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] trying to use Tag Soup - fromAttrib

2010-11-02 Thread Daniel Schoepe
Excerpts from Michael Litchard's message of Tue Nov 02 22:40:27 +0100 2010:
 Daniel,
Thank you for your reply. I'm still confused.
 When I see a code sample like this
 main = do
   posts - liftM parseTags (readFile posts.xml)
   print $ head $ map (fromAttrib Id) $
  filter (~== (row OwnerUserId= ++ userid ++ ))
  posts
 
 I have no idea how to match that up with what you said. The usage of
 fromAttrib here doesn't match up with what I htink the type signature
 is saying.
 
 fromAttrib :: (Show str, Eq str, StringLike str) = str - Tag str - str
 
 seems to say fromAttrib takes two parameters (I know it doesn't
 literally take two), one str (with the constraints in parenthesis to
 the left) and one str of type Tag, giving back a str. Then I look at
 the above code sample and can't match the two up.

In the code sample, the first argument is Id, in which case the
concrete type for the type variable str is String, and the second
argument are the tags returned by the call to filter, which have type
Tag String.

The second parameter is not a str of type Tag, but Tag (which is a
type constructor) applied to
the same concrete type for str its first argument has.

So in your case, calling
 fromAttrib href (TagOpen ...)

Would give you
/launchWebForward.do?resourceId=4policy=0returnTo=%2FshowWebForwards.do. To
get the resourceId you want, you'd have to dissect this string further.


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


Re: [Haskell-cafe] a way to convert partial functions to functions with Maybe's

2010-04-13 Thread Daniel Schoepe
Excerpts from Ozgur Akgun's message of Tue Apr 13 12:02:06 +0200 2010:
 Cafe,
 
 Is there a way (without going into the IO lands) to achieve this:
 [..]

There's package for that on hackage:
http://hackage.haskell.org/packages/archive/spoon/0.3/doc/html/Control-Spoon.html

However, this is somewhat controversial regarding _|_:
http://www.reddit.com/r/haskell/comments/acasn/tired_of_functions_that_could_live_in_maybe_but/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] n00b question: defining datatype

2009-08-06 Thread Daniel Schoepe
On Thu, Jul 23, 2009 at 08:17:34PM +0100, Iain Barnett wrote:
 [..]
 against the empty list it's not really a problem to have it there. I didn't
 realise I could use Maybe in the constructor because it's a monad, but
 that's good because I was wondering about the best way to make a nullable
 value.

Actually, this has nothing to do with Maybe being a monad. The reason
you can do this is because Maybe itself is not a type, but a (unary)
type constructor(It has kind * - *), so you need to apply it to
another type. Doing something like test :: Maybe would be an error.

 That Data.Tree module looks interesting too! It does seem to be a
 naturally recursive type, but I'm still trying to become easy with that sort
 of thought :)
 [..]

A list is also recursively defined, so it is not really more difficult
to use a Tree instead. E.g. one could define a list type like this:
 data List a = Nil | Cons a (List a)

- Daniel


pgpx25fhhGIwn.pgp
Description: PGP signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe