Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Re: monads do not fit together? (Brandon Allbery)
2. Haskell Group Dresden? (Daniel Trstenjak)
3. Re: [Haskell-cafe] Haskell Group Dresden? (Daniel Trstenjak)
4. How do I give a type for this code? (Todd Wilson)
----------------------------------------------------------------------
Message: 1
Date: Tue, 15 Oct 2013 09:31:24 -0400
From: Brandon Allbery <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] monads do not fit together?
Message-ID:
<CAKFCL4XnNoDGAuma01O=oatkxipj6o1f+_czlmnh6n3qbad...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
On Tue, Oct 15, 2013 at 5:00 AM, Kees Bleijenberg <
[email protected]> wrote:
> I wonder, do you always have to create a monadtransformer if your program
> uses 2 kinds of IO?
>
In one sense the answer is "yes"; but the real answer is "that's not how it
works". There is only one IO. Monad transformers allow you to add
functionality on top of it, but at some point you need to do actual I/O in
the IO monad.
One reason it's done this way is that CGIT could in theory be written such
that you could swap out the raw IO monad for something that lets you do
testing.
--
brandon s allbery kf8nh sine nomine associates
[email protected] [email protected]
unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20131015/28291671/attachment-0001.html>
------------------------------
Message: 2
Date: Tue, 15 Oct 2013 16:23:26 +0200
From: Daniel Trstenjak <[email protected]>
To: [email protected], [email protected]
Subject: [Haskell-beginners] Haskell Group Dresden?
Message-ID: <20131015142326.GA30791@machine>
Content-Type: text/plain; charset=us-ascii
Hi,
is there any interest in having something like a Haskell Group in Dresden?
Perhaps I could say something about the lens library, which would be
more of a practical talk, how to define lenses and working with lenses,
traversals, isos and prisms.
Greetings,
Daniel
------------------------------
Message: 3
Date: Tue, 15 Oct 2013 17:54:41 +0200
From: Daniel Trstenjak <[email protected]>
To: [email protected], [email protected]
Subject: Re: [Haskell-beginners] [Haskell-cafe] Haskell Group Dresden?
Message-ID: <20131015155441.GA32413@machine>
Content-Type: text/plain; charset=us-ascii
Hi Stephan,
> I'm very much interested. Do you need any help organizing a first meeting?
>
> For what it's worth, we once had an event about Yesod at the local CCC
> group[1].
well, normally I'm not the kind of guy who enjoys performing in front of
a lot of people, so I'm trying to find a way to get in touch with some
folks without getting a heart attack =).
So looking at your yesod event, the perception to get filmed, isn't
really helping here :D.
I was thinking about something "more" informal or if someone else wants
to talk, I have no issues to sit somewhere in the back ;).
Ok, but perhaps we can work out something fitting.
Greetings,
Daniel
------------------------------
Message: 4
Date: Tue, 15 Oct 2013 15:11:22 -0700
From: Todd Wilson <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] How do I give a type for this code?
Message-ID:
<ca+-99olkjmrvdjxac+4mc1ta9xcnwparekve3zb3fz6srlw...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
Haskell community,
I'm in one of those situations where I have the code I want to write, but
need to find the right types to get it to typecheck. What follows is a
generic version of my situation.
Suppose I want to represent the finite models of a language (in the sense
of mathematical logic) with a single constant c, unary function symbol f,
and predicate P. I can represent the carrier as a list m, the constant as
an element of m, the function as a list of ordered pairs of elements of m,
and the predicate as the list of the elements in the model that satisfy it:
-- a model is (m, c, f, p)
type Model a = ([a], a, [(a,a)], [a]) -- a is the "base type"
I can then construct particular models and operations on models. The
details aren't important for my question, just the types:
unitModel :: Model ()
unitModel = ([()], (), [((),())], [])
cycleModel :: Int -> Model Int
cycleModel n = ([0..n-1], 0, [(i, (i+1)`mod`n) | i<-[0..n-1]], [0])
-- function application, assuming function is total
ap :: Eq a => [(a,b)] -> a -> b
ap ((x',y'):ps) x = if x == x' then y' else ap ps x
-- cartesian product of models
productModel :: (Eq a, Eq b) => Model a -> Model b -> Model (a,b)
productModel (m1, c1, f1, p1) (m2, c2, f2, p2) = (m12, c12, f12, p12) where
m12 = [(x1,x2) | x1 <- m1, x2 <- m2]
c12 = (c1, c2)
f12 = [(x12, (ap f1 (fst x12), ap f2 (snd x12))) | x12 <- m12]
p12 = [x12 | x12 <- m12, elem (fst x12) p1 && elem (snd x12) p2]
-- powerset of model
powerModel :: (Eq a, Ord a) => Model a -> Model [a]
powerModel (m, c, f, p) = (ms, cs, fs, ps) where
ms = subsequences m
cs = [c]
fs = [(xs, nub (sort (map (ap f) xs))) | xs <- ms]
ps = [xs | xs <- ms, elem c xs]
Now, I want to give a name to all of these models:
data ModName = UnitModel
| CycleModel Int
| Product ModName ModName
| Power ModName
deriving (Show, Eq)
And finally, I want to associate each name with its associated model:
model_of UnitModel = unitModel
model_of (CycleModel n) = cycleModel n
model_of (Product m1 m2) = productModel (model_of m1) (model_of m2)
model_of (Power m1) = powerModel (model_of m1)
I've tried a number of ways of getting this to work, in the sense of
defining types so that I can use exactly this definition of model_of (some
involving GADTs and type families) but haven't found a best way. How
should I do it?
Todd Wilson
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20131015/2aa4d89c/attachment-0001.html>
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 64, Issue 25
*****************************************