Daryoush Mehrtash | 13 Oct 22:35

couple of questions on monads

Question 1: Why are there lazy and strict modules of some monads?  (e.g. Control.monad.State)  

Question 2:  If I define a new monad (say xyz), does it have to be as  control.monad.xyz  module?

daryoush


_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Andrew Coppin | 13 Oct 20:48

Very silly

{-# LANGUAGE FlexibleInstances #-}

module Overload where

class Silly s where
  go :: s

instance Silly ([x] -> [x]) where
  go = reverse

instance Silly (Int -> Int) where
  go = (+1)

Don't even ask.

Suffice it to say, you *can* make Haskell support arbitrary overloading 
of function names like C++ has, _if_ you abuse the type system violently 
enough. Please, won't somebody think of the children?!?
Matt Morrow | 13 Oct 20:14

Multi-line string literals are both easy /and/ elegant in Haskell

The new QuasiQuotes extension arriving with ghc 6.10 is very exciting,
and handling multi-line string literals is like stealing candy from
a baby. ;)

-----------------------------------------------------------------------------
-- Here.hs
module Here (here) where

import Language.Haskell.TH.Quote
import Language.Haskell.TH.Syntax
import Language.Haskell.TH.Lib

here :: QuasiQuoter
here = QuasiQuoter (litE . stringL) (litP . stringL)
-----------------------------------------------------------------------------

-----------------------------------------------------------------------------
-- There.hs
{-# LANGUAGE QuasiQuotes #-}
module Main where
import Here (here)
main = putStr [$here|

Shall I say, I have gone at dusk through narrow streets
And watched the smoke that rises from the pipes
Of lonely men in shirt-sleeves, leaning out of windows?

I should have been a pair of ragged claws
Scuttling across the floors of silent seas.

|]
-----------------------------------------------------------------------------

-----------------------------------------------------------------------------
[m <at> ganon a]$ ghc -O2 --make There.hs
[1 of 2] Compiling Here             ( Here.hs, Here.o )
[2 of 2] Compiling Main             ( There.hs, There.o )
Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.
Loading package syb ... linking ... done.
Loading package array-0.2.0.0 ... linking ... done.
Loading package packedstring-0.1.0.1 ... linking ... done.
Loading package containers-0.2.0.0 ... linking ... done.
Loading package pretty-1.0.1.0 ... linking ... done.
Loading package template-haskell ... linking ... done.
Linking There ...
[m <at> ganon a]$ ./There

Shall I say, I have gone at dusk through narrow streets
And watched the smoke that rises from the pipes
Of lonely men in shirt-sleeves, leaning out of windows?

I should have been a pair of ragged claws
Scuttling across the floors of silent seas.

[m <at> ganon a]$
-----------------------------------------------------------------------------
Yakov ZAYTSEV | 13 Oct 17:45

Could not build win32 dll..

Hello,

Sadly, I've found --mk-dll option unrecognized by latest stable GHC 6.8.3..
I'm new to win32 development
How one can make win32 dll at the moment?
I've successfully compiled Adder sources from example from section
11.5.4 of user guide
I need to build dll to be called from foreign application
The only way I see is to use MinGW's gcc which is shipped with GHC
distrib to manually link everything GHC runtime needs
Did I missed something?

TIA

--

-- 
Best wishes,
Y
Martin Hofmann | 13 Oct 17:23

Associated Types and several Classes

> {-# OPTIONS_GHC -fglasgow-exts #-}
> module Test where
>import qualified Data.Set as S

Hi. I try to model the following: Hypotheses are build up from Rules, 
which itself are made of the type Rule. Because I may change the 
implementation later, I want to use type classes, which define the
signature of my functions I will use in other modules. 

>class CRule r 

>class (CRule (CRulesRule r) ) => CRules r where
>    type CRulesRule r

>class (CRule (CHypoRule h), CRules (CHypoRules h) ) => CHypo h where
>    type CHypoRules h
>    type CHypoRule h
>    hypo ::  
>        CHypoRules h ->     
>        CHypoRule h ->      
>        h                   

-- | Rule

>data Rule = Rule Int deriving(Eq,Ord)
>instance CRule Rule 

-- | Rules

>type Rules = S.Set Rule
>instance CRules (S.Set Rule) where
>    type CRulesRule (S.Set Rule) = Rule

-- | Hypothese

>data Hypo  = Hypo { open   :: Rules
>                  , closed :: Rules
>                  }

>instance CHypo Hypo where
>    type CHypoRules Hypo = Rules
>    type CHypoRule Hypo = Rule

>    hypo ro rc = Hypo { open=ro, closed=(S.singleton rc)}

So far so good. But why does now the last of the following lines not
type check?
It says:

    Couldn't match expected type `CHypoRules h'
           against inferred type `S.Set Rule'

    Couldn't match expected type `CHypoRule h'
           against inferred type `Rule'

>rule1 = Rule 1
>rule2 = Rule 2
>rule3 = Rule 3
>rules = S.fromList [rule1,rule2,rule3]
>ahypo = hypo rules rule1

Shouldn't be (CHypoRules Hypo) be associated with Rules and similar
(CHypoRule)
with Rule?

Thanks a lot,

Martin

--

-- 
---------------------------------------------------------------
Dipl.-Wirtsch.Inf. (E.M.B.Sc.) Martin Hofmann
Cognitive Systems Group
Faculty Information Systems and Applied Computer Science
University of Bamberg
http://www.cogsys.wiai.uni-bamberg.de/members/hofmann 
http://www.inductive-programming.org

Arun Suresh | 13 Oct 11:29

Query regarding Type classes

Hello folks,

Im kinda new to haskell. Ive only been fiddling around with it for bout 3 - 4 weeks now.
And for the life of me... i cant seem to figure out why this doesnt work :


class Foo a where
    fooFunc :: a -> Int

data FooData = FData

instance Foo FooData where
    fooFunc _ = 10



class Bar a where
    barFunc :: (Foo b) => a -> b -> Int

data BarData = BData

instance Bar BarData where
    barFunc _ FData = 20



When I compile I get this :
 Couldn't match expected type `b' against inferred type `FooData'
      `b' is a rigid type variable bound by
          the type signature for `barFunc' at Sample.hs:16:20
    In the pattern: FData
    In the definition of `barFunc': barFunc _ FData = 20
    In the definition for method `barFunc'


Think Im missing something really big...
Could somebody kindly help me out here...



Regards
Arun


Could so


_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Janis Voigtlaender | 13 Oct 10:12

Haskell on mobile platforms

Hi all,

there were several discussions on this list about different
implementations of Haskell running on the iPhone and other mobile
platforms over the last three months or so. I would very much like to
see the current state of what is and is not yet possible here reflected
in the "Platforms" section of the upcoming edition of the Haskell
Communities and Activities report.

So please, if you have been working on getting Haskell to run on your
phone, and even more so if you were successful, write a short HCAR
entry about it. For further details, see:

http://article.gmane.org/gmane.comp.lang.haskell.cafe/45967

Thanks, Janis.

--

-- 
Dr. Janis Voigtlaender
http://wwwtcs.inf.tu-dresden.de/~voigt/
mailto:voigt <at> tcs.inf.tu-dresden.de
Ryan Ingram | 13 Oct 09:25

Improving MTL instances (was: Overlapping/Incoherent instances)

On Mon, Oct 13, 2008 at 2:04 AM, J. Garrett Morris
<jgmorris <at> cecs.pdx.edu> wrote:
> Indeed - MTL seems to have been rewritten at some point in the past to
> prefer exhaustive enumeration to overlap.

Indeed, and I actually think this is a weakness of the current
implementation.  Anyone who comes up with a new transformer that
provides different functionality than what is there needs to
explicitly provide all the relevant instances, instead of letting
MonadTrans do its thing.

Consider MonadPrompt (shameless plug, it's on hackage!)  In order to
be fully interoperable with the MTL I'd need to write instances for
MonadState, MonadReader, MonadWriter, MonadError, and MonadCont for
PromptT.  These are unavoidable, although for monads with a "simple
enough" interface, such as State, everything can be accomplished with
"lift".

But I also need to provide the same boilerplate instances for every
other monad transformer in the package to give them instances of
MonadPrompt.  And MonadPrompt *does* have a "simple enough" interface
that it could be accomplished trivially with "lift".

And this ignores interacting with any other transformer library!
Anyone who uses MonadPrompt along with another transformer (like
DatabaseT in the PostgreSQL library) needs to write any instances they
care about themselves, which adds to the difficulty in using the
libraries together.

Of course, the point of this message isn't just to complain.  The
overlap implementation was abhorrent and it *is* better now than it
was before.  But perhaps there is an abstraction we are missing that
would allow for better interoperability.  For example, the
type-compose library documentation at
http://haskell.org/haskellwiki/TypeCompose mentions that (f :. g) is
an applicative functor if both f and g are applicative functors, which
means there is a generic "transformer" for all applicative functors!
The presense of >>=/join for monads make this more difficult, although
there is the "product" definition:

> newtype Product m n a = Prod { runProd :: m (Either a (Product n m a)) }

which handles nesting joins by just nesting the monads recursively.
But in this case it is up to the user to figure out how to untangle
the spaghetti created, so that's no good.

So, does anyone have any good ideas for improving the interoperability of MTL?

  -- ryan
Martin Hofmann | 13 Oct 08:41

Re: Haskell in Artificial Intelligence

Hi Christos, 

We and a colleague from Japan use Haskell for Inductive Functional
Programming, i.e. learn programs from examples. 

However, we just have started to port our program to Haskell:
http://www.cogsys.wiai.uni-bamberg.de/effalip/

Susumu Katayama has already a Haskell library:
http://nautilus.cs.miyazaki-u.ac.jp/~skata/MagicHaskeller.html

More information about IP can be found here:
http://www.inductive-programming.org/

What kind of survey are you doing? Do you have a pointer, too?

Greetings,

Martin
Galchin, Vasili | 13 Oct 05:22

the ghc "reflection" thing?

hello,

   Several months ago I saw on the wiki or maybe it was a discussion on mechanism to get the ghc compiler's state. I can't remember enough to
ask even well. I know there is a wiki entry. Sorry ... I can only "hint" at this ... ??

Thanks, Vasili
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Devin Mullins | 13 Oct 03:01

Error building GHC 6.8.3: "version of ../../compiler/stage1/ghc-inplace could not be determined"

Hi,

I'm trying to build 6.8.3 on Linux PowerPC, based on an old binary of
6.4 (latest build for this arch that I found). stage1 seems to have
built, but from there, building libraries almost immediately fails:

> make -C libraries all
> make[1]: Entering directory `/home/twifkak/arch/ghc/src/ghc-6.8.3/libraries'
> rm -f -f stamp/configure.library.*.base base/unbuildable
> ( cd base && setup/Setup configure \
> 	            --enable-library-profiling --enable-split-objs \
> 	           --prefix=/NONEXISTANT \
> 	           --bindir=/NONEXISTANT \
> 	           --libdir=/NONEXISTANT \
> 	           --libsubdir='$pkgid' \
> 	           --libexecdir=/NONEXISTANT \
> 	           --datadir=/NONEXISTANT \
> 	           --docdir=/NONEXISTANT \
> 	           --htmldir=/NONEXISTANT \
> 	           --interfacedir=/NONEXISTANT \
> 	           --with-compiler=../../compiler/stage1/ghc-inplace \
> 	           --with-hc-pkg=../../utils/ghc-pkg/ghc-pkg-inplace \
> 	           --with-hsc2hs=../../utils/hsc2hs/hsc2hs-inplace \
> 	           --with-ld=/usr/bin/ld \
> 	           --haddock-options="--use-contents=../index.html \
> 	                           --use-index=../doc-index.html" \
> 	              --configure-option='--prefix=/usr'  --configure-option='CFLAGS=-mtune=powerpc -O2 -pipe
-mpowerpc-gfxopt' \
> 	           --configure-option=--with-cc=gcc ) \
> 	      && touch stamp/configure.library.build-profiling-splitting.base || touch base/unbuildable
> Configuring base-3.0.2.0...
> Setup: ghc version >=6.2 is required but the version of ../../compiler/stage1/ghc-inplace could not be determined.
> if ifBuildable/ifBuildable base; then \
> 	  cd base && \
> 	  cmp -s ../Makefile.local Makefile.local || cp ../Makefile.local .; \
> 	  mv GNUmakefile GNUmakefile.tmp; \
> 	  setup/Setup makefile -f GNUmakefile; \
> 	  cmp -s GNUmakefile GNUmakefile.tmp && mv GNUmakefile.tmp GNUmakefile; \
> 	  make -wr && \
> 	  setup/Setup register --inplace; \
> 	fi
> mv: cannot stat `GNUmakefile': No such file or directory
> Setup: error reading dist/setup-config; run "setup configure" command?
> 
> make[2]: Entering directory `/home/twifkak/arch/ghc/src/ghc-6.8.3/libraries/base'
> make[2]: *** No targets specified and no makefile found.  Stop.
> make[2]: Leaving directory `/home/twifkak/arch/ghc/src/ghc-6.8.3/libraries/base'
> make[1]: *** [make.library.base] Error 2
> make[1]: Leaving directory `/home/twifkak/arch/ghc/src/ghc-6.8.3/libraries'
> make: *** [stage1] Error 2

(This particular transcript is from an unclean build, but the same error
occurred on a freshly untarred ghc.)

The subsequent errors seems to stem from the root one of being unable to
configure:

> [twifkak <at> ponyride base]$ setup/Setup configure -v3
> Configuring base-3.0.2.0...
> Creating dist (and its parents)
> /home/twifkak/usr/bin/ghc --numeric-version
> Warning: cannot determine version of /home/twifkak/usr/bin/ghc :
> ""
> Setup: ghc version >=6.2 is required but the version of /home/twifkak/usr/bin/ghc could not be determined.
> [twifkak <at> ponyride base]$ ghc --numeric-version
> 6.4
> [twifkak <at> ponyride base]$ setup/Setup configure
--with-compiler=../../compiler/stage1/ghc-inplace -v3
> Configuring base-3.0.2.0...
> Creating dist (and its parents)
> ../../compiler/stage1/ghc-inplace --numeric-version
> Warning: cannot determine version of ../../compiler/stage1/ghc-inplace :
> ""
> Setup: ghc version >=6.2 is required but the version of ../../compiler/stage1/ghc-inplace could not be determined.
> [twifkak <at> ponyride base]$ ../../compiler/stage1/ghc-inplace --numeric-version
> 6.8.3

What's going wrong? How do I fix it? Is there a better mailing list to
ask?

Thanks,
Devin

Gmane