[Haskell-cafe] Fwd: [Haskell-beginners] Monad instances and type synonyms

2013-04-13 Thread Christopher Howard

I asked this question in Haskell-beginners, but I haven't heard anything
yet, so I'm forwarding to Cafe.

 Original Message 
Subject: [Haskell-beginners] Monad instances and type synonyms
Date: Sat, 13 Apr 2013 17:03:57 -0800
From: Christopher Howard 
Reply-To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell 
To: Haskell Beginners 

I am playing around with some trivial code (for learning purposes) I
wanted to take

code:

-- SaleVariables a concrete type defined early

-- `Adjustment' represents adjustment in a price calculation
-- Allows functions of type (a -> Adjustment a) to be composed
-- with an appropriate composition function
type Adjustment a = SaleVariables -> a


And put it into

code:

instance Monad Adjustment where

  (>>=) = ...
  return = ...


If I try this, I get

code:

Type synonym `Adjustment' should have 1 argument, but has been given none
In the instance declaration for `Monad Adjustment'


But if I give an argument, then it doesn't compile either (it becomes a
"*" kind). And I didn't want to make the type with a regular "data"
declaration either, because then I have to give it a constructor, which
doesn't fit with what I want the type to do.

-- 
frigidcode.com




___
Beginners mailing list
beginn...@haskell.org
http://www.haskell.org/mailman/listinfo/beginners



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


Re: [Haskell-cafe] GSoC proposal: Data Visualization

2013-04-13 Thread Carter Schonwald
Heinrich, you hit the nail on the head.

for an interactive plotting story to work well, we wind up needing to have
better tools in the ecosystem on the gui / computational notebook side.


on the other hand, similar work was done last summer, as heinrich mentions,
in the form of ghc live https://github.com/shapr/ghclive, by
a very strong GSOC participant, and while it works, its not really being
used, and is still quite immature.

Additionally, the folks at FPcomplete have their browser based haskell
interaction tool thats seeing quite a lot of use by folks learning haskell,
which in turn raises the quality bar that any other effort must achieve to
see serious usage.

its also worth wondering if the scala notebook port of the ipython notebook
could be used to guid writing a similar tools for haskell.

 Either way,  would require a very concrete plan of attack to be a
tractable GSOC project

-Carter




On Sat, Apr 13, 2013 at 4:33 AM, Heinrich Apfelmus <
apfel...@quantentunnel.de> wrote:

> Ernesto Rodriguez wrote:
>
>> Dear Haskell Community,
>>
>> During the last months I used Haskell for machine learning, particularly
>> in
>> the field of Echo State Neural Networks. The main drawback I encountered
>> is
>> that its difficult to visualize and plot data in Haskell in spite the fact
>> there are a couple of plotting libraries. Data visualization is very
>> important in the field of machine learning research (not so much in
>> machine
>> learning implementation) since humans are very efficient to analyze
>> graphical input to figure out what is going on in order to determine
>> possible adjustments. I was wondering if other members of the community
>> have experienced this drawback and would be interested in improved data
>> visualization for Haskell, especially if there is interest to use Haskell
>> for machine learning research. I collected my ideas in the following page:
>>  
>> https://github.com/netogallo/**Visualizer.
>>  Please provide me with feedback
>> because if the proposal is interesting for the community I would start
>> working with it, even if it doesn't make it to this GSoC, but a project
>> like this will need a lot of collaboration for it to be successful.
>>
>
> Your project is very ambitious! In fact, too ambitious.
>
> Essentially, you want to build an interactive environment for evaluating
> Haskell expressions. The use case you have in mind is data visualization
> for machine learning, but that is just a special case. If you can zoom in
> and out of plots of infinite time series, you can zoom in and out of audio
> data, and then why not add an interactive synthesizer widget to create that
> audio data in the first place.
>
> Your idea decomposes into many parts, each of which would easily fill an
> entire GSoC project on their own.
>
> * GUI. Actually, we currently don't have a GUI library that is easy to
> install for everyone. Choosing wxHaskell or gtk2hs immediately separates
> your user base into three disjoint parts. I think it's possible to use the
> web browser as GUI instead ( HeinrichApfelmus/threepenny-**gui
> >).
>
> * Displaying Haskell values in a UI. You mentioned that you want matrices
> to come with a contextual menu where you can select different
> transformations on them. It's just a minor step to allow any Haskell
> function operating on them. I have a couple of ideas on how to do this is
> in a generic fashion. Unfortunately, the project from last year <
> http://hackage.haskell.org/**trac/summer-of-code/ticket/**1609>
> did not succeed satisfactorily. There were some other efforts, but I
> haven't seen anything released.
>
> * UI programming is hard. You could easily spend an entire project on
> implementing a single visualization, for instance an infinite time series
> with responsive zoom. It's not difficult to implement something, but adding
> the right level of polish so that people want to use it takes effort.
> There's a reason that Matlab costs money, and there's a reason that your
> mentor relies on it.
>
> * Functionality specific to machine learning. Converting Vector to a
> format suitable for representation of matrices, etc. This is your primary
> interest.
>
>
> Note that, unfortunately, the parts depend on each other from top to
> bottom. It's possible to write functionality specific to machine learning,
> but it would be of little impact if it doesn't come with a good UI.
>
>
> 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:/

Re: [Haskell-cafe] case switch covering all possible constructor but still fails

2013-04-13 Thread Nathan Hüsken

Oh, so obvious. That was it, thanks.

On 04/13/2013 12:08 PM, Daniel Trstenjak wrote:


Hi Nathan,


DataAlt c | Right tag <- genDataConTag c -> return $ Cond tag


Are you sure, that genDataConTag always returns a 'Right'?
If it returns a 'Left', than the pattern won't match.


Greetings,
Daniel

___
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] NaN as Integer value

2013-04-13 Thread Jerzy Karczmarczuk

Franco answers a question :

Hello haskellers,is there a reason why Integer doesn't have 'NaN' as

value?I think it would be very convenient to be able to handle (1 `div` 0)
as regular NaN value and not as exception.Thanks.
I think because, if you need NaN like values, `Maybe Int` does the same job
without tainting the definition of `Int`.
This is not a Haskell problem. For Ints, ALL representations are valid 
numbers, a NaN is a specific float object, unless I'm mistaken, so the 
introduction of such an abnormal number would require some serious 
modifications of the representation.


Jerzy Karczmarczuk


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


Re: [Haskell-cafe] NaN as Integer value

2013-04-13 Thread Daniel Díaz Casanueva
You can always use the Maybe type as a follows:

intDiv :: Integer -> Integer -> Maybe Integer
intDiv _ 0 = Nothing
intDiv n m = Just (div n m)

This allows you to pattern match results of divisions:

example :: Integer -> Integer -> Maybe Integer
example n m =
 case intDiv 4 n of
  Nothing -> Nothing
  Just n' ->
case intDiv 5 m of
  Nothing -> Nothing
  Just m' -> Just (n' + m')

Or even better using the do notation:

example2 :: Integer -> Integer -> Maybe Integer
example2 n m = do
n' <- intDiv 4 n
m' <- intDiv 5 m
return (n' + m')

Note that example and example2 both do the same thing.

I think this is cleaner solution add NaN as a value to the Integer type.

Good luck,
Daniel Díaz.


On Sat, Apr 13, 2013 at 12:16 PM, Алексей Егоров  wrote:

> Hello haskellers,
>
> is there a reason why Integer doesn't have 'NaN' as value?
> I think it would be very convenient to be able to handle (1 `div` 0) as
> regular NaN value and not as exception.
>
> Thanks.
>
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>


-- 
E-mail sent by Daniel Díaz Casanueva

let f x = x in x
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] NaN as Integer value

2013-04-13 Thread Franco
> Hello haskellers,is there a reason why Integer doesn't have 'NaN' as
value?I think it would be very convenient to be able to handle (1 `div` 0)
as regular NaN value and not as exception.Thanks.
> 

I think because, if you need NaN like values, `Maybe Int` does the same job
without tainting the definition of `Int`.



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


[Haskell-cafe] NaN as Integer value

2013-04-13 Thread Алексей Егоров
 Hello haskellers,

is there a reason why Integer doesn't have 'NaN' as value?
I think it would be very convenient to be able to handle (1 `div` 0) as regular 
NaN value and not as exception.

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


Re: [Haskell-cafe] ANNOUNCE: monoid-subclasses-0.1.1, incremental-parser-0.2.2, and SCC-0.8

2013-04-13 Thread Alberto G. Corona
Thanks

The cancelative monoid is the right class for rolling back transactions, by
the way.


2013/3/22 Mario Blažević 

> The new package monoid-subclasses [1] exports a number of classes that
> sit between monoids and groups: ReductiveMonoid, CancellativeMonoid,
> GCDMonoid, MonoidNull, and FactorialMonoid among others. The package also
> comes with class instances for all applicable data types from base, vector,
> containers, bytestring, and text packages.
>
> These classes were initially a part of the incremental-parser package
> [2] but they've moved, so incremental-parser-0.2.2 now depends on
> monoid-subclasses which has added more class methods and instances. The
> parsers constructed using the incremental-parser library generally work on
> any ReductiveMonoid, FactorialMonoid or TextualMonoid. You can thus
> construct a generic parser that operates on String, ByteString, or Text
> input, or even on Product Integer or a Map if you are so inclined.
>
> The version 0.8 of Streaming Component Combinators (a.k.a. SCC) has
> also been re-designed from the ground up. In the earlier versions, as in
> the pipes and conduit packages, the types of streams and stream-processing
> components were
> parametrized by the type of the individual items flowing through. All
> sources and sinks are now parametrized instead by the type of the monoid
> they produce or consume. As a consequence, SCC coroutines can now
> communicate in chunks of
> ByteString or Text instead of just lists, and these chunks can be of
> arbitrary size. The boundaries of producer's chunks are invisible to the
> consumer (excepting some low-level functions), which must specify the
> amount of data it wants to receive using a ReadRequest. This change at the
> heart of SCC has had a positive impact on outer layers, and especially on
> the Splitter component type which has become much simpler.
>
> [1] 
> http://hackage.haskell.org/**package/monoid-subclasses-0.1.**1
> [2] 
> http://hackage.haskell.org/**package/incremental-parser-0.**2.2
> [3] 
> http://hackage.haskell.org/**package/scc-0.8
>
>
> __**_
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/**mailman/listinfo/haskell-cafe
>



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


[Haskell-cafe] multivariate normal distribution in Haskell?

2013-04-13 Thread Bas de Haas

Dear List,

I’m implementing a probabilistic model for recognising musical chords in 
Haskell. This model relies on a multivariate normal distribution. I’ve 
been searching the internet and mainly hackage for a Haskell library to 
do this for me, but so far I’ve been unsuccessful.


What I’m looking for is a Haskell function that does exactly what the 
mvnpdf function in matlab does: 
http://www.mathworks.nl/help/stats/multivariate-normal-distribution.html


Does anyone know a library that can help me out?

Thanks.

Kind regards,
Bas de Haas

--
dr. W. Bas de Haas
Department of Information and Computing Sciences
Utrecht University

E: w.b.deh...@uu.nl
T: +31 30 253 5965
I: http://www.uu.nl/staff/WBdeHaas/

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


Re: [Haskell-cafe] case switch covering all possible constructor but still fails

2013-04-13 Thread Daniel Trstenjak

Hi Nathan,

> DataAlt c | Right tag <- genDataConTag c -> return $ Cond tag

Are you sure, that genDataConTag always returns a 'Right'?
If it returns a 'Left', than the pattern won't match.


Greetings,
Daniel

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


Re: [Haskell-cafe] case switch covering all possible constructor but still fails

2013-04-13 Thread Niklas Larsson
>
> What I do not understand: The case switch covers all possibilities of
> AltCon. So how can this happen?
>
>
There is a guard on the DataAlt case so all alternatives doesn't have to be
covered.

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


Re: [Haskell-cafe] GSoC proposal: Data Visualization

2013-04-13 Thread Ernesto Rodriguez
Hi Hienrich,

It is indeed a big scope as you mentioned. Matlab has been working for
years to get this functionality right. On the other hand, the project you
linked is interesting. For me it would already be a huge advantage if I
could edit and re-evaluate expressions interactively (in a comfortable GUI,
not ghci). Also a plot widget with sliders would also help. I was wondering
if you know any reason the project has not been worked on for various
months (as I see in the repo). Is there anyone working in this project and
has a later version? I mean these are features that are even available in
free math packages such as Sage.

Best regards,

Ernesto Rodriguez

On Sat, Apr 13, 2013 at 10:33 AM, Heinrich Apfelmus <
apfel...@quantentunnel.de> wrote:

> Ernesto Rodriguez wrote:
>
>> Dear Haskell Community,
>>
>> During the last months I used Haskell for machine learning, particularly
>> in
>> the field of Echo State Neural Networks. The main drawback I encountered
>> is
>> that its difficult to visualize and plot data in Haskell in spite the fact
>> there are a couple of plotting libraries. Data visualization is very
>> important in the field of machine learning research (not so much in
>> machine
>> learning implementation) since humans are very efficient to analyze
>> graphical input to figure out what is going on in order to determine
>> possible adjustments. I was wondering if other members of the community
>> have experienced this drawback and would be interested in improved data
>> visualization for Haskell, especially if there is interest to use Haskell
>> for machine learning research. I collected my ideas in the following page:
>>  
>> https://github.com/netogallo/**Visualizer.
>>  Please provide me with feedback
>> because if the proposal is interesting for the community I would start
>> working with it, even if it doesn't make it to this GSoC, but a project
>> like this will need a lot of collaboration for it to be successful.
>>
>
> Your project is very ambitious! In fact, too ambitious.
>
> Essentially, you want to build an interactive environment for evaluating
> Haskell expressions. The use case you have in mind is data visualization
> for machine learning, but that is just a special case. If you can zoom in
> and out of plots of infinite time series, you can zoom in and out of audio
> data, and then why not add an interactive synthesizer widget to create that
> audio data in the first place.
>
> Your idea decomposes into many parts, each of which would easily fill an
> entire GSoC project on their own.
>
> * GUI. Actually, we currently don't have a GUI library that is easy to
> install for everyone. Choosing wxHaskell or gtk2hs immediately separates
> your user base into three disjoint parts. I think it's possible to use the
> web browser as GUI instead ( HeinrichApfelmus/threepenny-**gui
> >).
>
> * Displaying Haskell values in a UI. You mentioned that you want matrices
> to come with a contextual menu where you can select different
> transformations on them. It's just a minor step to allow any Haskell
> function operating on them. I have a couple of ideas on how to do this is
> in a generic fashion. Unfortunately, the project from last year <
> http://hackage.haskell.org/**trac/summer-of-code/ticket/**1609>
> did not succeed satisfactorily. There were some other efforts, but I
> haven't seen anything released.
>
> * UI programming is hard. You could easily spend an entire project on
> implementing a single visualization, for instance an infinite time series
> with responsive zoom. It's not difficult to implement something, but adding
> the right level of polish so that people want to use it takes effort.
> There's a reason that Matlab costs money, and there's a reason that your
> mentor relies on it.
>
> * Functionality specific to machine learning. Converting Vector to a
> format suitable for representation of matrices, etc. This is your primary
> interest.
>
>
> Note that, unfortunately, the parts depend on each other from top to
> bottom. It's possible to write functionality specific to machine learning,
> but it would be of little impact if it doesn't come with a good UI.
>
>
> Best regards,
> Heinrich Apfelmus
>
> --
> http://apfelmus.nfshost.com
>
>
>
> __**_
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/**mailman/listinfo/haskell-cafe
>



-- 
Ernesto Rodriguez

Bachelor of Computer Science - Class of 2013
Jacobs University Bremen
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] case switch covering all possible constructor but still fails

2013-04-13 Thread Nathan Hüsken

Hey,

I am trying to fix (or at least get my head around) this: 
https://github.com/valderman/haste-compiler/issues/27
Which is an issue of the haste haskell->javascript compiler. Doing so I 
encounter this problem which makes me think I am not understanding 
something fundamental here (and I believe this not to be haste specific)...


OK, the problem is that this code:

genAlt :: Bool -> JSVar -> JSVar -> StgAlt -> JSGen Config JSAlt
genAlt tailpos scrut res (con, args, used, body) =  do
  construct <- case con of
DEFAULT  -> return Def
LitAlt l -> Cond <$> genLit l
DataAlt c | Right tag <- genDataConTag c -> return $ Cond tag
_ -> error "Bad data constructor tag generated!"

Looking at StgAlt, I conclude that con must be of type AltCon, which is 
defined like this (from CoreSyn.lhs of the ghc source):


data AltCon
  = DataAlt DataCon
  | LitAlt  Literal
  | DEFAULT
deriving (Eq, Ord, Data, Typeable)

What I do not understand: The case switch covers all possibilities of 
AltCon. So how can this happen?


Using trace, the con seemed to have the type "GHC.Integer.Type.S#" in 
the case of the erro.


Thanks!
Nathan

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


[Haskell-cafe] When - O'Reilly book on Parallel and Concurrent Haskell

2013-04-13 Thread amslonewolf
Are there updates on when Simon Marlow's  O'Reilly book on Parallel and 
Concurrent Haskell is going to be released?

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


Re: [Haskell-cafe] GSoC proposal: Data Visualization

2013-04-13 Thread Heinrich Apfelmus

Ernesto Rodriguez wrote:

Dear Haskell Community,

During the last months I used Haskell for machine learning, particularly in
the field of Echo State Neural Networks. The main drawback I encountered is
that its difficult to visualize and plot data in Haskell in spite the fact
there are a couple of plotting libraries. Data visualization is very
important in the field of machine learning research (not so much in machine
learning implementation) since humans are very efficient to analyze
graphical input to figure out what is going on in order to determine
possible adjustments. I was wondering if other members of the community
have experienced this drawback and would be interested in improved data
visualization for Haskell, especially if there is interest to use Haskell
for machine learning research. I collected my ideas in the following page:
 https://github.com/netogallo/Visualizer . Please provide me with feedback
because if the proposal is interesting for the community I would start
working with it, even if it doesn't make it to this GSoC, but a project
like this will need a lot of collaboration for it to be successful.


Your project is very ambitious! In fact, too ambitious.

Essentially, you want to build an interactive environment for evaluating 
Haskell expressions. The use case you have in mind is data visualization 
for machine learning, but that is just a special case. If you can zoom 
in and out of plots of infinite time series, you can zoom in and out of 
audio data, and then why not add an interactive synthesizer widget to 
create that audio data in the first place.


Your idea decomposes into many parts, each of which would easily fill an 
entire GSoC project on their own.


* GUI. Actually, we currently don't have a GUI library that is easy to 
install for everyone. Choosing wxHaskell or gtk2hs immediately separates 
your user base into three disjoint parts. I think it's possible to use 
the web browser as GUI instead 
().


* Displaying Haskell values in a UI. You mentioned that you want 
matrices to come with a contextual menu where you can select different 
transformations on them. It's just a minor step to allow any Haskell 
function operating on them. I have a couple of ideas on how to do this 
is in a generic fashion. Unfortunately, the project from last year 
 did not 
succeed satisfactorily. There were some other efforts, but I haven't 
seen anything released.


* UI programming is hard. You could easily spend an entire project on 
implementing a single visualization, for instance an infinite time 
series with responsive zoom. It's not difficult to implement something, 
but adding the right level of polish so that people want to use it takes 
effort. There's a reason that Matlab costs money, and there's a reason 
that your mentor relies on it.


* Functionality specific to machine learning. Converting Vector to a 
format suitable for representation of matrices, etc. This is your 
primary interest.



Note that, unfortunately, the parts depend on each other from top to 
bottom. It's possible to write functionality specific to machine 
learning, but it would be of little impact if it doesn't come with a 
good UI.



Best regards,
Heinrich Apfelmus

--
http://apfelmus.nfshost.com


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