Re: [Haskell-cafe] HTML framework for web-ui

2013-05-22 Thread Heinrich Apfelmus

Vlatko Basic wrote:
I'd like to start using web pages as the UI for apps. I found out for 
yesod, snapp and happstack as the candidates.
Would you recommend any of them as better for app ui (not "classical" 
web pages)? Or maybe another one?


Not sure if that's what you are looking for, but with help from Daniel 
Austin, I'm currently working on a small GUI library that use the web 
browser to display GUI elements.


  

It's derived from Chris Done's former Ji project.

It's not quite ready for public consumption yet, but any feedback is 
appreciated, of course.



Best regards,
Heinrich Apfelmus

--
http://apfelmus.nfshost.com


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


Re: [Haskell-cafe] Infrastructure for testing the impact of a Functor/Applicative/Monad hierarchy

2013-05-22 Thread Niklas Hambüchen
Ian Lynagh just posted a link to the "hackager" program:

http://hackage.haskell.org/trac/ghc/wiki/HackageTesting

That seems to be pretty much what I was looking for.

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


[Haskell-cafe] accessing a type variable in instance declaration

2013-05-22 Thread TP
Hi all,

I wonder if there is some means to get a type variable value in the body of 
a class instance definition. It seems it is not possible (a workaround has 
already been given on this list), but I would like a confirmation.
For example, imagine that I have a Tensor type constructor, that takes a 
type-level integer (representing the Tensor order) to make a concrete type:

-
instance Show (Tensor order) where
 show TensorVar str = show "tensor " ++ str ++ " of order "
++ (show (c2num order))
--

where c2num transforms a type-level integer to an integer, through 
typeclasses (see 
http://www.haskell.org/haskellwiki/The_Monad.Reader/Issue5/Number_Param_Types)

I obtain a compilation error: order is not known in the body of the 
instance. Putting ScopedTypeVariable as extension does not change anything 
(http://www.haskell.org/ghc/docs/7.0-latest/html/users_guide/other-type-extensions.html#scoped-type-variables).

I have tried also using forall, without more success:


instance forall order. Show (Tensor order) where
  show TensorVar str = show ”tensor ” ++ str ++ ” of order ”
++ (show (c2num order))


Thanks in advance,

TP


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


Re: [Haskell-cafe] accessing a type variable in instance declaration

2013-05-22 Thread Roman Cheplyaka
* TP  [2013-05-22 16:18:55+0200]
> Hi all,
> 
> I wonder if there is some means to get a type variable value in the body of 
> a class instance definition. It seems it is not possible (a workaround has 
> already been given on this list), but I would like a confirmation.
> For example, imagine that I have a Tensor type constructor, that takes a 
> type-level integer (representing the Tensor order) to make a concrete type:
> 
> -
> instance Show (Tensor order) where
>  show TensorVar str = show "tensor " ++ str ++ " of order "
> ++ (show (c2num order))
> --
> 
> where c2num transforms a type-level integer to an integer, through 
> typeclasses (see 
> http://www.haskell.org/haskellwiki/The_Monad.Reader/Issue5/Number_Param_Types)
> 
> I obtain a compilation error: order is not known in the body of the 
> instance. Putting ScopedTypeVariable as extension does not change anything 
> (http://www.haskell.org/ghc/docs/7.0-latest/html/users_guide/other-type-extensions.html#scoped-type-variables).

You are confusing type and value variables.

  c2num order

means apply the function 'c2num' to the value variable 'order', which is
not defined.

To get from a type to a value you can use a type class 'Sing' (for 'singleton')

  class Sing a where
sing :: a

  instance Sing Zero where
sing = Zero

  instance Sing a => Sing (Succ a) where
sing = Succ sing

After adding the appropriate constraint to the instance, you can write
  
  show $ c2num $ (sing :: order)

Roman

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


[Haskell-cafe] "Haskell from N00b to Real World Programmer"

2013-05-22 Thread Mihai Maruseac
Hello,

As hinted in the previous HCAR, this year we will organize an workshop
entitled like the subject of this mail[1].

It will be organized by ROSEdu (Romanian Open Source Education) [2]
and the newly founded Haskell-Romania group (no link yet, working on
that). It is one workshop in a series of summer workshops organized by
ROSEdu (go one level up in the wiki, some of them are in Romanian and
I don't want to blindly give links to Romanian pages).

The entire schedule is given on the wiki page at [1] and detailed below:

Day 1 (8th of July)

Introduction. History and Syntax. -- basic introduction to the
language. Including @lambdabot usage as an example
Programming with Static Typing as An Ally. -- designing with types and
using GHCI for rapid prototyping and testing type of expressions.
Possible to include @djinn
Programming with State and Style. -- gentle introduction to monads in
the style of "You could have invented monads" [3]

Day 2 (9th of July)

Packaging and Distributing Code. -- hackage, cabal, cabal-dev and,
maybe, stackage
The Awesome xmonad Window Manager -- we'll let them tweak
configuration files in xmonad and use them. In this way, they get to
use real world apps and change them to suit their needs. Maybe attract
some developers.
Compare and Contrast. Blow Your Mind with Haskell and Compare with
Python. -- Starting with a comparison between some Python code and the
equivalent Haskell one we get to cover topics in [4]

Day 3 (11th of July)

Lenses for Updating Details. -- you've guessed it, lenses
Creating Graphical Interfaces. -- GTK2hs or lGTK. I'd like to test the
second one
Static Site Generation. -- Hakyll, config tweaking, generating first site, etc.

Day 4 (12th of July)

Beautiful Diagrams -- diagrams package
Pipes and Conduits for Faster I/O -- pipes
Creating Real-World Web Applications. -- Yesod (because that's what we know)

Day 5 (13th of July)

Hackathon Day

If you have some suggestions, please make them.

Lastly, for the hackathon day we have considered making some bots for
I.GameBot[5] and an IRC bot with features that we'd like on #rosedu
and #haskell-ro (grab, karma, resource location, statistics). If you'd
have some other suggestions which could be implemented in a single day
after the previous courses, please, do share them with us.

Thanks and sorry for the length of the mail.


[1]: http://workshop.rosedu.org/2013/sesiuni/haskell
[2]: http://rosedu.org/
[3]: http://blog.sigfpe.com/2006/08/you-could-have-invented-monads-and.html
[4]: http://www.haskell.org/haskellwiki/Blow_your_mind
[5]: https://github.com/rosedu/I.GameBot

--
MM
"All we have to decide is what we do with the time that is given to us"

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


Re: [Haskell-cafe] accessing a type variable in instance declaration

2013-05-22 Thread TP
Roman Cheplyaka wrote:

> You are confusing type and value variables.
> 
>   c2num order
> 
> means apply the function 'c2num' to the value variable 'order', which is
> not defined.
> 
> To get from a type to a value you can use a type class 'Sing' (for
> 'singleton')
> 
>   class Sing a where
> sing :: a
> 
>   instance Sing Zero where
> sing = Zero
> 
>   instance Sing a => Sing (Succ a) where
> sing = Succ sing
> 
> After adding the appropriate constraint to the instance, you can write
>   
>   show $ c2num $ (sing :: order)

Ok, thanks, I understand. Now, I'm stuck to compile this code (independent 
from my previous post, but related to it):

---
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE KindSignatures #-}

data Nat = Zero | Succ Nat
type One = Succ Zero
type Two = Succ One

-- class Cardinal c where   -- line 1
class Cardinal (c::Nat) where  -- line 2
c2num :: c -> Integer
cpred :: (Succ c) -> c
cpred = undefined

instance Cardinal Zero where
c2num _ = 0

instance (Cardinal c) => Cardinal (Succ c) where
c2num x = 1 + c2num (cpred x)

main = do

print $ show $ c2num (undefined::Succ (Succ Zero))
print $ show $ c2num (undefined::Two)
-

With line 2, I get:

test_nat.hs:11:14:
Kind mis-match
Expected kind `OpenKind', but `c' has kind `Nat'
In the type `c -> Integer'
In the class declaration for `Cardinal'

With line 1 instead, I get:

Kind mis-match
The first argument of `Succ' should have kind `Nat',
but `c' has kind `*'
In the type `(Succ c) -> c'
In the class declaration for `Cardinal'

So, in the first case, c has a too restricted kind, and in the second one, 
it has a too broad kind in the definition of cpred. I have tried several 
things without any success.
How to compile that code?

Thanks,

TP


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


Re: [Haskell-cafe] accessing a type variable in instance declaration

2013-05-22 Thread Roman Cheplyaka
* TP  [2013-05-22 18:45:06+0200]
> Ok, thanks, I understand. Now, I'm stuck to compile this code (independent 
> from my previous post, but related to it):
> 
> ---
> {-# LANGUAGE DataKinds #-}
> {-# LANGUAGE KindSignatures #-}
> 
> data Nat = Zero | Succ Nat
> type One = Succ Zero
> type Two = Succ One
> 
> -- class Cardinal c where   -- line 1
> class Cardinal (c::Nat) where  -- line 2
> c2num :: c -> Integer
> cpred :: (Succ c) -> c
> cpred = undefined
> 
> instance Cardinal Zero where
> c2num _ = 0
> 
> instance (Cardinal c) => Cardinal (Succ c) where
> c2num x = 1 + c2num (cpred x)
> 
> main = do
> 
> print $ show $ c2num (undefined::Succ (Succ Zero))
> print $ show $ c2num (undefined::Two)
> -
> 
> With line 2, I get:
> 
> test_nat.hs:11:14:
> Kind mis-match
> Expected kind `OpenKind', but `c' has kind `Nat'
> In the type `c -> Integer'
> In the class declaration for `Cardinal'
> 
> With line 1 instead, I get:
> 
> Kind mis-match
> The first argument of `Succ' should have kind `Nat',
> but `c' has kind `*'
> In the type `(Succ c) -> c'
> In the class declaration for `Cardinal'
> 
> So, in the first case, c has a too restricted kind, and in the second one, 
> it has a too broad kind in the definition of cpred. I have tried several 
> things without any success.
> How to compile that code?

You seem to assume that Succ Zero will have type 'Succ 'Zero (i.e. the
promoted type), but it's not the case — it still has type Nat, as
always.

On the other hand, the type 'Succ 'Zero has kind 'Nat and doesn't have
any inhabitants — only types of kind * do.

So, how to fix this depends on what you want. For example, you can
change c2num to accept Proxy c instead of c. Or you can establish the
connection between Succ Zero and 'Succ 'Zero — again, using a (slightly
modified) Sing class. In the latter case, take a look at the
'singletons' package — it can do a lot of work for you.

Roman

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


[Haskell-cafe] Functional JavaScript Opportunity in NYC

2013-05-22 Thread Ryan Trinkle
Hi everyone,

Our company, skedge.me, is looking for a full-time front-end developer in
the NYC area.  Our front-end is written in JavaScript, but our back-end is
written in Haskell, so we're looking for people with solid JavaScript
experience but also a strong interest in functional programming.

No work experience in Haskell is required, but we do require all applicants
to submit a small code sample - something on the scale of a Project Euler
problem - in a statically-typed functional language in addition to a more
traditional JavaScript code sample.  We write all of our JavaScript in a
functional style, and we use the Google Closure compiler to provide some
type checking for us, so we're looking for people who enjoy working in an
environment with a bit more structure than the average JavaScript project.

For more information or to apply, visit http://skedge.me/careers or contact
me at r...@skedge.me.


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


Re: [Haskell-cafe] "Haskell from N00b to Real World Programmer"

2013-05-22 Thread amslonewolf
Hi - Please record the sessions and post online.

On Wednesday, May 22, 2013 11:45:05 AM UTC-4, Mihai Maruseac wrote:
>
> Hello, 
>
> As hinted in the previous HCAR, this year we will organize an workshop 
> entitled like the subject of this mail[1]. 
>
> It will be organized by ROSEdu (Romanian Open Source Education) [2] 
> and the newly founded Haskell-Romania group (no link yet, working on 
> that). It is one workshop in a series of summer workshops organized by 
> ROSEdu (go one level up in the wiki, some of them are in Romanian and 
> I don't want to blindly give links to Romanian pages). 
>
> The entire schedule is given on the wiki page at [1] and detailed below: 
>
> Day 1 (8th of July) 
>
> Introduction. History and Syntax. -- basic introduction to the 
> language. Including @lambdabot usage as an example 
> Programming with Static Typing as An Ally. -- designing with types and 
> using GHCI for rapid prototyping and testing type of expressions. 
> Possible to include @djinn 
> Programming with State and Style. -- gentle introduction to monads in 
> the style of "You could have invented monads" [3] 
>
> Day 2 (9th of July) 
>
> Packaging and Distributing Code. -- hackage, cabal, cabal-dev and, 
> maybe, stackage 
> The Awesome xmonad Window Manager -- we'll let them tweak 
> configuration files in xmonad and use them. In this way, they get to 
> use real world apps and change them to suit their needs. Maybe attract 
> some developers. 
> Compare and Contrast. Blow Your Mind with Haskell and Compare with 
> Python. -- Starting with a comparison between some Python code and the 
> equivalent Haskell one we get to cover topics in [4] 
>
> Day 3 (11th of July) 
>
> Lenses for Updating Details. -- you've guessed it, lenses 
> Creating Graphical Interfaces. -- GTK2hs or lGTK. I'd like to test the 
> second one 
> Static Site Generation. -- Hakyll, config tweaking, generating first site, 
> etc. 
>
> Day 4 (12th of July) 
>
> Beautiful Diagrams -- diagrams package 
> Pipes and Conduits for Faster I/O -- pipes 
> Creating Real-World Web Applications. -- Yesod (because that's what we 
> know) 
>
> Day 5 (13th of July) 
>
> Hackathon Day 
>
> If you have some suggestions, please make them. 
>
> Lastly, for the hackathon day we have considered making some bots for 
> I.GameBot[5] and an IRC bot with features that we'd like on #rosedu 
> and #haskell-ro (grab, karma, resource location, statistics). If you'd 
> have some other suggestions which could be implemented in a single day 
> after the previous courses, please, do share them with us. 
>
> Thanks and sorry for the length of the mail. 
>
>
> [1]: http://workshop.rosedu.org/2013/sesiuni/haskell 
> [2]: http://rosedu.org/ 
> [3]: 
> http://blog.sigfpe.com/2006/08/you-could-have-invented-monads-and.html 
> [4]: http://www.haskell.org/haskellwiki/Blow_your_mind 
> [5]: https://github.com/rosedu/I.GameBot 
>
> -- 
> MM 
> "All we have to decide is what we do with the time that is given to us" 
>
> ___ 
> Haskell-Cafe mailing list 
> haskel...@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] Debugging embedded ruby interpreter

2013-05-22 Thread Simon Marechal
Hello,

I am trying to embed a ruby interpreter into my Haskell library. It
didn't seem complicated, and went flawlessly until I tried using it a
lot. Then I got segfaults.

Here is a test program that corrupts the Array object that is being
created :

https://github.com/bartavelle/hruby/blob/271d99e26a5df075b1011e4b30adf6a1c8d2/test/roundtrip.hs

Changing line 46 to this makes it work:

v <- pick (listOf arbitrary :: Gen [Double])

And this version makes it fail again :

v <- pick (listOf subvalue :: Gen [Value])

As you can see, the "frequencies" of "subvalue" are set so that only
JSON Values representing Doubles are generated. As the toRuby and
fromRuby instances for Value are just pure wrappers over the instances
for Double, the non-pure code that is executed should be the same. Am I
wrong here ?

Given that there is almost no documentation for doing this Ruby
embedding, I am unsure that I am doing it right. I looked at the Hubris
code and several other sources on the Internet, but can't find what is
wrong with my implementation.

I have no clue on how to debug this. Valgrind gives me a few
"Conditional jump or move depends on uninitialised value(s)" during
Ruby's gc, but I get more or less the same when just running the native
interpreter. Also running this with the multithreaded runtime makes it
fail immediately.

Anyone has an idea on how I should approach this problem ?

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


[Haskell-cafe] question about type constructors

2013-05-22 Thread TP
Hi,

In the program I am trying to write, I have a problem that can be reduced to 
the following dummy example:

--
{-# LANGUAGE GADTs #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE IncoherentInstances #-}

class PrettyPrint a where
prettify :: a -> String

data Gender = Male | Female | Gender3 | Gender4

data Person :: Gender -> * where
Person :: String -> Person b
Child :: String -> Person a -> Person b -> Person c

instance PrettyPrint (Person a)

instance PrettyPrint (Person Male) where
prettify (Person name) = "My name is " ++ (show name)
  ++ " and I am a male"
prettify (Child name person1 person2) = "My name is " ++ (show name)
  ++ " and my parents are:" ++ (prettify person1) ++ ", "
  ++ (prettify person2)

main = do

let p1 = Person "Jim" :: Person Male
let p2 = Person "Joe" :: Person Male
let p3 = Child "Jack" p1 p2

print $ prettify p1
print $ prettify p2
print $ prettify p3
--

The idea is that I want to implement PrettyPrint only for a subset of the 
possible types in Gender (through promotion process). Why? It would be 
longer to explain (it is a bit more complicated in my real program).

Anyway, in the program above, I have found that with IncoherentInstances 
(and the empty instance definition for (Person a)), it is working, it is 
able to use the most specific instance corresponding to the current type (I 
don't know exactly why). For example, p1 and p2 are correctly printed above, 
because they are of type (Person Male) and because I have implemented 
PrettyPrint for (Person Male).

But it does not work for p3, I obtain an error at runtime:
-
$ runghc test.hs
"My name is \"Jim\" and I am a male"
"My name is \"Joe\" and I am a male"
test_typelost.hs: test_typelost.hs:16:10-31: No instance nor default method 
for class operation Main.prettify
-

The reason is that the information that p1 and p2 are Male seems to be 
"lost" when we construct the child "Child "Jack" p1 p2", probably because 
GHC only sees that in the type signature of Child, we have a more general 
(Person a) -> (Person b). So he tries to find an implementation of prettify 
in PrettyPrint (Person a), but there is none.

Is there any workaround?

Thanks,

TP



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


[Haskell-cafe] Second Call for Papers: Workshop on Functional Art, Music, Modeling, and Design (colocated with ICFP)

2013-05-22 Thread Brent Yorgey
Please submit something to FARM --- the deadline is fast approaching!

==
  FARM 2013: Call for Papers

  ACM SIGPLAN Workshop on Functional Art, Music, Modeling and Design
  Boston, Massachusetts, USA
  28th September, 2013 (directly after ICFP)

  http://www.cis.upenn.edu/~byorgey/farm13/
==

Scope
-

The functional programming community is largely interested in writing
beautiful programs. This workshop is intended to gather researchers and
practitioners interested in writing beautiful programs that generate
beautiful artifacts. Such artifacts may include visual art, music, 3D
sculptures, animations, GUIs, video games, physical models,
architectural models, choreographies for dance, poetry, and even
physical objects such as VLSI layouts, GPU configurations, or mechanical
engineering designs. The framework used need not be purely functional
(“mostly functional” is fine); may be based on abstractions such as
higher-order functions, monads, arrows, or streams; and may be
manifested as a domain specific language or tool. Theoretical
foundations, language design, implementation issues, and applications
are all within the scope of the workshop.

Important dates
---

  - Submissions due: Friday, 14 June 2013, 23:59 UTC-11 (American Samoa
time [1])

  - Author notification: Thursday, 11 July 2013

  - Final papers due: Thursday, 25 July 2013

  - Workshop: Saturday, 28 September 2013 (the day after ICFP)

[1] 
http://www.timeanddate.com/worldclock/fixedtime.html?msg=FARM+submissions+due&iso=20130614T2355&p1=1033

Proceedings
---

There will be a formal proceedings published by ACM Press. Accepted
papers will be included in the ACM Digital Library; see
http://authors.acm.org/main.cfm for information on the options available
to authors. Authors are also encouraged to submit auxiliary material for
publication along with their paper (source code, data, videos, images,
etc.); authors retain all rights to the auxiliary material.

Submission details
--

We solicit submissions in two categories:

  - Full papers. A full paper is limited to 12 pages, and will be
evaluated according to its relevance, correctness, significance,
originality, and clarity. It should explain its contributions,
identify what has been accomplished, explain why it is significant,
and compare it with previous work.

  - "Aesthetic applications". An aesthetic application paper is limited
to 6 pages, and will be judged primarily on the effective and
elegant use of FP to generate aesthetic artifacts (though the
criteria for full papers are still relevant).

Submitted papers should be in portable document format (PDF), formatted
using the ACM SIGPLAN style guidelines. The text should be in a 9-point
font in two columns.

Submissions can be made via EasyChair at

  https://www.easychair.org/conferences/?conf=farm2013

Organizers
--

Workshop Chair: Paul Hudak
Program Chair: Conal Elliott
Publicity Chair: Brent Yorgey

Program Committee
-

Daniel Cukier (University of São Paulo)
Conal Elliott (Tabula) (chair)
Kathleen Fisher (Tufts University)
Richard Gabriel (IBM Research)
George Giorgidze (University of Tübingen)
Paul Hudak (Yale University)
José Pedro Magalhães (University of Oxford)
Alex McLean (University of Leeds)
John Peterson (Western State Colorado University)
Michael Sperber (Active Group)
Henning Thielemann
Brent Yorgey (University of Pennsylvania)

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


[Haskell-cafe] How to throw an error if using "cabal-install" < version XYZ?

2013-05-22 Thread Ryan Newton
A cabal-install bug  was
fixed recently that pertains to building C libraries with profiling.

As a result, I want a certain
packageto
test if cabal-install < 0.17.0 is used, and throw a preemptive error.
 Otherwise this package fails in weird ways at runtime (it's a nasty one).

I noticed with some surprise the following sequence:

*   $ cabal --version*
*   cabal-install version 1.16.0.2*
*   using version 1.16.0.3 of the Cabal library*
*   $ cabal clean*
*   $ cabal install*
*   $ cat dist/build/autogen/cabal_macros.h  | grep VERSION_Cabal*
*   #define VERSION_Cabal "1.17.0"*

Alright, so that, in retrospect, makes sense.  The version is which *my*
library is linked with is the relevant one, not the one cabal-install was
linked with [1].

So the natural next thought is to move the MIN_VERSION_Cabal test into
Setup.hs, and force cabal to use it by setting the build type to Custom.
 But... I just learned from this ticket that the cabal macros are not
available in Setup.hs:

   http://hackage.haskell.org/trac/hackage/ticket/326

Uh oh, what's left?

 -Ryan

[1] P.S. Personally I'm now using a bash function like below, to force the
two versions to be the same:

function safe_cabal_install () {
  VER=`cabal --version | tail -n1 | awk '{ print $3 }'`
  cabal install --constraint="Cabal==$VER" $*
}
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to throw an error if using "cabal-install" < version XYZ?

2013-05-22 Thread Carter Schonwald
Hey Ryan,
I ran into a related issue, heres a a way you can do this safe IN the cabal
file (or at least you can modify my hack for your purposes)

heres a link to the workaround I did for making LLVM-hs work across >= 1.17
and < 1.17 cabal, but you could abuse it to make sure setup.hs barfs on old
cabal https://github.com/bos/llvm/blob/master/base/Setup.hs#L89-L116

heres a quick one off gist that takes my trick and does something helpful
for you variant + makes sure the tool can't build otherwise

https://gist.github.com/cartazio/5632636

I just wrote a snippet that you can just add to your setup.hs and it should
guarantee the setup.hs will barf with a helpful error message on cabal <
1.17.0


On Wed, May 22, 2013 at 10:50 PM, Ryan Newton  wrote:

> A cabal-install bug  was
> fixed recently that pertains to building C libraries with profiling.
>
> As a result, I want a certain 
> packageto test if 
> cabal-install < 0.17.0 is used, and throw a preemptive error.
>  Otherwise this package fails in weird ways at runtime (it's a nasty one).
>
> I noticed with some surprise the following sequence:
>
> *   $ cabal --version*
> *   cabal-install version 1.16.0.2*
> *   using version 1.16.0.3 of the Cabal library*
> *   $ cabal clean*
> *   $ cabal install*
> *   $ cat dist/build/autogen/cabal_macros.h  | grep VERSION_Cabal*
> *   #define VERSION_Cabal "1.17.0"*
>
> Alright, so that, in retrospect, makes sense.  The version is which *my*
> library is linked with is the relevant one, not the one cabal-install was
> linked with [1].
>
> So the natural next thought is to move the MIN_VERSION_Cabal test into
> Setup.hs, and force cabal to use it by setting the build type to Custom.
>  But... I just learned from this ticket that the cabal macros are not
> available in Setup.hs:
>
>http://hackage.haskell.org/trac/hackage/ticket/326
>
> Uh oh, what's left?
>
>  -Ryan
>
> [1] P.S. Personally I'm now using a bash function like below, to force the
> two versions to be the same:
>
> function safe_cabal_install () {
>   VER=`cabal --version | tail -n1 | awk '{ print $3 }'`
>   cabal install --constraint="Cabal==$VER" $*
> }
>
>
> ___
> 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] [ANN] Hac Phi 2013

2013-05-22 Thread Daniel Wagner
Just a quick reminder: the registration deadline is tomorrow (Friday) 
at 1430. If you plan on coming, please let us know so we can buy the 
right amount of mealtime goodies and get you hooked up with sweet, sweet 
Internet!


~d

On 2013-04-26 18:47, Daniel Wagner wrote:

Hac Phi 2013, a Haskell hackathon/get-together, will be held June 7-9
at the University of Pennsylvania in Philadelphia.  The hackathon will
officially kick off at 2:30 Friday afternoon, and go until 5pm on
Sunday (with breaks for sleep, of course).  Last year's Hac Phi was a
lot of fun, drawing more than 30 Haskellers, and many people have
already expressed interest in coming back this year.  Everyone is
welcome - you do not have to be a Haskell guru.  Helping hack on
someone else's project could be a great way to increase your 
Haskell-fu.


If you plan on coming, please officially register [1].  Registration,
travel, lodging and many other details can be found on the Hac Phi
wiki [2].  This year, we are making a public list of attendees' names
and nicks - please let us know if you'd prefer not to be listed when
you register.

We're also looking for a few people interested in giving short (15-20
min.) talks, probably on Saturday afternoon.  Anything of interest to
the Haskell community is fair game - a project you've been working on,
a paper, a quick tutorial.  If you'd like to give a talk, add it on
the wiki [3].

Hope to see you in Philadelphia!

- The Hac Phi team
Brent Yorgey (byorgey)
Daniel Wagner (dmwit)
Chris Casinghino (ccasin)

[1] http://www.haskell.org/haskellwiki/Hac_%CF%86/Register
[2] http://www.haskell.org/haskellwiki/Hac_%CF%86
[3] http://www.haskell.org/haskellwiki/Hac_%CF%86/Talks


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


Re: [Haskell-cafe] How to throw an error if using "cabal-install" < version XYZ?

2013-05-22 Thread Roman Cheplyaka
Perhaps I'm missing something, but why not just

  cabal-version:   >=1.18

?

It will constrain the Cabal version, not cabal-install, but judging from
the fix[1] this is what you actually need.

[1]: 
https://github.com/haskell/cabal/commit/d148336e97cda2e3585c453cf9af61bc3635131a

Roman

* Ryan Newton  [2013-05-22 22:50:08-0400]
> A cabal-install bug  was
> fixed recently that pertains to building C libraries with profiling.
> 
> As a result, I want a certain
> packageto
> test if cabal-install < 0.17.0 is used, and throw a preemptive error.
>  Otherwise this package fails in weird ways at runtime (it's a nasty one).
> 
> I noticed with some surprise the following sequence:
> 
> *   $ cabal --version*
> *   cabal-install version 1.16.0.2*
> *   using version 1.16.0.3 of the Cabal library*
> *   $ cabal clean*
> *   $ cabal install*
> *   $ cat dist/build/autogen/cabal_macros.h  | grep VERSION_Cabal*
> *   #define VERSION_Cabal "1.17.0"*
> 
> Alright, so that, in retrospect, makes sense.  The version is which *my*
> library is linked with is the relevant one, not the one cabal-install was
> linked with [1].
> 
> So the natural next thought is to move the MIN_VERSION_Cabal test into
> Setup.hs, and force cabal to use it by setting the build type to Custom.
>  But... I just learned from this ticket that the cabal macros are not
> available in Setup.hs:
> 
>http://hackage.haskell.org/trac/hackage/ticket/326
> 
> Uh oh, what's left?
> 
>  -Ryan
> 
> [1] P.S. Personally I'm now using a bash function like below, to force the
> two versions to be the same:
> 
> function safe_cabal_install () {
>   VER=`cabal --version | tail -n1 | awk '{ print $3 }'`
>   cabal install --constraint="Cabal==$VER" $*
> }

> ___
> cabal-devel mailing list
> cabal-de...@haskell.org
> http://www.haskell.org/mailman/listinfo/cabal-devel


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


Re: [Haskell-cafe] How to throw an error if using "cabal-install" < version XYZ?

2013-05-22 Thread Carter Schonwald
constraining it to >= 1.17 would be better while 1.18 isn't out yet..


On Thu, May 23, 2013 at 1:42 AM, Roman Cheplyaka  wrote:

> Perhaps I'm missing something, but why not just
>
>   cabal-version:   >=1.18
>
> ?
>
> It will constrain the Cabal version, not cabal-install, but judging from
> the fix[1] this is what you actually need.
>
> [1]:
> https://github.com/haskell/cabal/commit/d148336e97cda2e3585c453cf9af61bc3635131a
>
> Roman
>
> * Ryan Newton  [2013-05-22 22:50:08-0400]
> > A cabal-install bug  was
> > fixed recently that pertains to building C libraries with profiling.
> >
> > As a result, I want a certain
> > packageto
> > test if cabal-install < 0.17.0 is used, and throw a preemptive error.
> >  Otherwise this package fails in weird ways at runtime (it's a nasty
> one).
> >
> > I noticed with some surprise the following sequence:
> >
> > *   $ cabal --version*
> > *   cabal-install version 1.16.0.2*
> > *   using version 1.16.0.3 of the Cabal library*
> > *   $ cabal clean*
> > *   $ cabal install*
> > *   $ cat dist/build/autogen/cabal_macros.h  | grep VERSION_Cabal*
> > *   #define VERSION_Cabal "1.17.0"*
> >
> > Alright, so that, in retrospect, makes sense.  The version is which *my*
> > library is linked with is the relevant one, not the one cabal-install was
> > linked with [1].
> >
> > So the natural next thought is to move the MIN_VERSION_Cabal test into
> > Setup.hs, and force cabal to use it by setting the build type to Custom.
> >  But... I just learned from this ticket that the cabal macros are not
> > available in Setup.hs:
> >
> >http://hackage.haskell.org/trac/hackage/ticket/326
> >
> > Uh oh, what's left?
> >
> >  -Ryan
> >
> > [1] P.S. Personally I'm now using a bash function like below, to force
> the
> > two versions to be the same:
> >
> > function safe_cabal_install () {
> >   VER=`cabal --version | tail -n1 | awk '{ print $3 }'`
> >   cabal install --constraint="Cabal==$VER" $*
> > }
>
> > ___
> > cabal-devel mailing list
> > cabal-de...@haskell.org
> > http://www.haskell.org/mailman/listinfo/cabal-devel
>
>
> ___
> 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] question about type constructors

2013-05-22 Thread Roman Cheplyaka
* TP  [2013-05-23 00:34:57+0200]
> Hi,
> 
> In the program I am trying to write, I have a problem that can be reduced to 
> the following dummy example:
> 
> --
> {-# LANGUAGE GADTs #-}
> {-# LANGUAGE DataKinds #-}
> {-# LANGUAGE KindSignatures #-}
> {-# LANGUAGE FlexibleInstances #-}
> {-# LANGUAGE IncoherentInstances #-}
> 
> class PrettyPrint a where
> prettify :: a -> String
> 
> data Gender = Male | Female | Gender3 | Gender4
> 
> data Person :: Gender -> * where
> Person :: String -> Person b
> Child :: String -> Person a -> Person b -> Person c
> 
> instance PrettyPrint (Person a)
> 
> instance PrettyPrint (Person Male) where
> prettify (Person name) = "My name is " ++ (show name)
>   ++ " and I am a male"
> prettify (Child name person1 person2) = "My name is " ++ (show name)
>   ++ " and my parents are:" ++ (prettify person1) ++ ", "
>   ++ (prettify person2)
> 
> main = do
> 
> let p1 = Person "Jim" :: Person Male
> let p2 = Person "Joe" :: Person Male
> let p3 = Child "Jack" p1 p2
> 
> print $ prettify p1
> print $ prettify p2
> print $ prettify p3
> --
> 
> The idea is that I want to implement PrettyPrint only for a subset of the 
> possible types in Gender (through promotion process). Why? It would be 
> longer to explain (it is a bit more complicated in my real program).
> 
> Anyway, in the program above, I have found that with IncoherentInstances 
> (and the empty instance definition for (Person a)), it is working, it is 
> able to use the most specific instance corresponding to the current type (I 
> don't know exactly why). For example, p1 and p2 are correctly printed above, 
> because they are of type (Person Male) and because I have implemented 
> PrettyPrint for (Person Male).
> 
> But it does not work for p3, I obtain an error at runtime:
> -
> $ runghc test.hs
> "My name is \"Jim\" and I am a male"
> "My name is \"Joe\" and I am a male"
> test_typelost.hs: test_typelost.hs:16:10-31: No instance nor default method 
> for class operation Main.prettify
> -
> 
> The reason is that the information that p1 and p2 are Male seems to be 
> "lost" when we construct the child "Child "Jack" p1 p2", probably because 
> GHC only sees that in the type signature of Child, we have a more general 
> (Person a) -> (Person b). So he tries to find an implementation of prettify 
> in PrettyPrint (Person a), but there is none.
> 
> Is there any workaround?

The rule of thumb is that you should never use IncoherentInstances.

The proper way to do it is:

  data Person :: Gender -> * where
  Person :: String -> Person b
  Child
:: (PrettyPrint a, PrettyPrint b)
=> String -> Person a -> Person b -> Person c

Roman

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


Re: [Haskell-cafe] HTML framework for web-ui

2013-05-22 Thread Vlatko Basic

Hi Heinrich,

Looks simple and interesting. I browsed the git, but not much docs yet.
Just examples, or have I looked at wrong places?


I see that API is still under heavy design. When do you expect the API might 
stabilize?


(BTW, examples in Readme do not work.)

vlatko



Vlatko Basic wrote:

I'd like to start using web pages as the UI for apps. I found out for yesod,
snapp and happstack as the candidates.
Would you recommend any of them as better for app ui (not "classical" web
pages)? Or maybe another one?


Not sure if that's what you are looking for, but with help from Daniel Austin,
I'm currently working on a small GUI library that use the web browser to display
GUI elements.

   

It's derived from Chris Done's former Ji project.

It's not quite ready for public consumption yet, but any feedback is
appreciated, of course.


Best regards,
Heinrich Apfelmus

--
http://apfelmus.nfshost.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