From simkestuff at gmail.com Thu Aug 9 08:32:57 2018
From: simkestuff at gmail.com (simkestuff at gmail.com)
Date: Thu, 9 Aug 2018 10:32:57 +0200
Subject: [Haskellbeginners] understanding function signature alignement
MessageID:
Hello,
I'm going through Haskellbook and while doing some exercises I'm stack with
trying to explain myself how types matches in this examples:
meh :: Monad m => [a] > (a > m b) > m [b]
meh [] _ = pure []
meh (x:xs) f = (:) <$> f x <*> meh xs f
flipType :: (Monad m) => [m a] > m [a]
flipType xs = meh xs id
What puzzles me is how id function which is of type (a>a) can fit here
where meh function is requesting function of type (a>m b)?
The function (a > m b) is function that says give me anything and I will
give back anything wrapped up into some monad structure; id ( a > a) on
other hand says give me anything and I will return it back to you. So, to
me, the first function is somehow more restricted than id function because
it puts limitation on what output of that function can be and I'm
struggling to understand how id function can fit here.
I hope someone can help me how to reason about these functions here?
thanks
 next part 
An HTML attachment was scrubbed...
URL:
From tonymorris at gmail.com Thu Aug 9 08:36:50 2018
From: tonymorris at gmail.com (Tony Morris)
Date: Thu, 9 Aug 2018 18:36:50 +1000
Subject: [Haskellbeginners] understanding function signature alignement
InReplyTo:
References:
MessageID: <05598bc0fec9989e1e7fced18f7cf4f2@gmail.com>
The (a) and (b) are different in each case. Let's rewrite it and rename
the variables to emphasise the difference.
meh :: Monad m => [a] > (a > m b) > m [b]
flipType :: (Monad k) => [k x] > k [x]
id :: q > q
This means that id can accept any argument type, as long as it returns
the same argument type. For example:
id :: m b > m b
When it is used like that, then (a) turns into (m b).
Similarly, meh can have this type:
meh :: Monad m => [m b] > (m b > m b) > m [b]
All I did was specialise the (a) typevariable, which can be anything,
as long as they all change. Now it is clear that when I put id into the
second argument position, I get the type [m b] > m [b]
On 09/08/18 18:32, simkestuff at gmail.com wrote:
> Hello,
>
> I'm going through Haskellbook and while doing some exercises I'm stack
> with trying to explain myself how types matches in this examples:
>
> meh :: Monad m => [a] > (a > m b) > m [b]
> meh [] _ = pure []
> meh (x:xs) f = (:) <$> f x <*> meh xs f
>
>
> flipType :: (Monad m) => [m a] > m [a]
> flipType xs = meh xs id
>
> What puzzles me is how id function which is of type (a>a) can fit
> here where meh function is requesting function of type (a>m b)?
>
> The function (a > m b) is function that says give me anything and I
> will give back anything wrapped up into some monad structure; id ( a
> > a) on other hand says give me anything and I will return it back to
> you. So, to me, the first function is somehow more restricted than id
> function because it puts limitation on what output of that function
> can be and I'm struggling to understand how id function can fit here.
>
> I hope someone can help me how to reason about these functions here?
>
> thanks
>
>
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgibin/mailman/listinfo/beginners
 next part 
An HTML attachment was scrubbed...
URL:
 next part 
A nontext attachment was scrubbed...
Name: signature.asc
Type: application/pgpsignature
Size: 488 bytes
Desc: OpenPGP digital signature
URL:
From brutallesale at gmail.com Thu Aug 9 08:47:50 2018
From: brutallesale at gmail.com (sasa bogicevic)
Date: Thu, 9 Aug 2018 10:47:50 +0200
Subject: [Haskellbeginners] understanding function signature alignement
InReplyTo: <05598bc0fec9989e1e7fced18f7cf4f2@gmail.com>
References:
<05598bc0fec9989e1e7fced18f7cf4f2@gmail.com>
MessageID:
You can also put another function as the argument to the id :
ghci > x :: a > m b;x = undefined
ghci > :t (id x)
(id x) :: a > m b
> On 9 Aug 2018, at 10:36, Tony Morris wrote:
>
> The (a) and (b) are different in each case. Let's rewrite it and rename the variables to emphasise the difference.
>
> meh :: Monad m => [a] > (a > m b) > m [b]
>
> flipType :: (Monad k) => [k x] > k [x]
>
> id :: q > q
>
> This means that id can accept any argument type, as long as it returns the same argument type. For example:
>
> id :: m b > m b
>
> When it is used like that, then (a) turns into (m b).
>
> Similarly, meh can have this type:
>
> meh :: Monad m => [m b] > (m b > m b) > m [b]
>
> All I did was specialise the (a) typevariable, which can be anything, as long as they all change. Now it is clear that when I put id into the second argument position, I get the type [m b] > m [b]
>
>
> On 09/08/18 18:32, simkestuff at gmail.com wrote:
>> Hello,
>>
>> I'm going through Haskellbook and while doing some exercises I'm stack with trying to explain myself how types matches in this examples:
>>
>> meh :: Monad m => [a] > (a > m b) > m [b]
>> meh [] _ = pure []
>> meh (x:xs) f = (:) <$> f x <*> meh xs f
>>
>>
>> flipType :: (Monad m) => [m a] > m [a]
>> flipType xs = meh xs id
>>
>> What puzzles me is how id function which is of type (a>a) can fit here where meh function is requesting function of type (a>m b)?
>>
>> The function (a > m b) is function that says give me anything and I will give back anything wrapped up into some monad structure; id ( a > a) on other hand says give me anything and I will return it back to you. So, to me, the first function is somehow more restricted than id function because it puts limitation on what output of that function can be and I'm struggling to understand how id function can fit here.
>>
>> I hope someone can help me how to reason about these functions here?
>>
>> thanks
>>
>>
>>
>>
>> _______________________________________________
>> Beginners mailing list
>> Beginners at haskell.org
>> http://mail.haskell.org/cgibin/mailman/listinfo/beginners
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgibin/mailman/listinfo/beginners
 next part 
An HTML attachment was scrubbed...
URL:
From simkestuff at gmail.com Thu Aug 9 14:22:17 2018
From: simkestuff at gmail.com (simkestuff at gmail.com)
Date: Thu, 9 Aug 2018 16:22:17 +0200
Subject: [Haskellbeginners] understanding function signature alignement
InReplyTo:
References:
MessageID:
>
> Thanks, it is still a bit fuzzy to me ...
I understand what you did but what confuses me is that when i look at
function with signature like
f :: Monad m => c > m d
I always think that return type is somehow restricted in comparison to
input because it demands that output type is wraped inside something (monad
in this case).
For such signature to fit id signature (a > a) , c type shoud be also
wraped inside monad but it is not case here...
Anyhow, I still have to figure it out
thanks
 next part 
An HTML attachment was scrubbed...
URL:
From fredericemmanuel.picca at synchrotronsoleil.fr Thu Aug 9 15:37:51 2018
From: fredericemmanuel.picca at synchrotronsoleil.fr (PICCA FredericEmmanuel)
Date: Thu, 9 Aug 2018 15:37:51 +0000
Subject: [Haskellbeginners] How to write the FromJSON instance for CUid
MessageID:
Hello, I try to write the instance for the CUid[1] type
But I do not know what to do.
instance FromJSON CUid where
parseJSON = ...
{# INLINE parseJSON #}
Thansk for your help
[1] https://hackage.haskell.org/package/base4.11.1.0/docs/SystemPosixTypes.html#t:CUid
From toad3k at gmail.com Thu Aug 9 17:06:40 2018
From: toad3k at gmail.com (David McBride)
Date: Thu, 9 Aug 2018 13:06:40 0400
Subject: [Haskellbeginners] How to write the FromJSON instance for CUid
InReplyTo:
References:
MessageID:
You have to worry about json having a floating point number or an integer
that is too large to be represented in a Word32, although you could also
just let it overflow if you don't care too much. There's probably an
easier way to do this, but this is what I came up with.
instance FromJSON CUid where
parseJSON (Number n) = do
case floatingOrInteger n of
Right i  inrange i > return . CUid . fromIntegral $ i
 not an integer, or not in range
_ > mempty
where
inrange :: Integer > Bool
inrange i = fromIntegral i >= (minBound @Word32) &&
fromIntegral i <= (maxBound @Word32)
 not a number
parseJSON _ = mempty
On Thu, Aug 9, 2018 at 11:37 AM, PICCA FredericEmmanuel <
fredericemmanuel.picca at synchrotronsoleil.fr> wrote:
> Hello, I try to write the instance for the CUid[1] type
> But I do not know what to do.
>
> instance FromJSON CUid where
> parseJSON = ...
> {# INLINE parseJSON #}
>
> Thansk for your help
>
>
> [1] https://hackage.haskell.org/package/base4.11.1.0/docs/
> SystemPosixTypes.html#t:CUid
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgibin/mailman/listinfo/beginners
>
 next part 
An HTML attachment was scrubbed...
URL:
From toad3k at gmail.com Thu Aug 9 17:10:48 2018
From: toad3k at gmail.com (David McBride)
Date: Thu, 9 Aug 2018 13:10:48 0400
Subject: [Haskellbeginners] How to write the FromJSON instance for CUid
InReplyTo:
References:
MessageID:
Sorry I really should've tested my code before I hit send.
instance FromJSON CUid where
parseJSON (Number n) = do
case floatingOrInteger n of
Right i  inrange i > return . CUid . fromIntegral $ i
_ > mempty
where
inrange :: Integer > Bool
inrange i = i >= fromIntegral (minBound @Word32) &&
i <= fromIntegral (maxBound @Word32)
parseJSON _ = mempty
On Thu, Aug 9, 2018 at 1:06 PM, David McBride wrote:
> You have to worry about json having a floating point number or an integer
> that is too large to be represented in a Word32, although you could also
> just let it overflow if you don't care too much. There's probably an
> easier way to do this, but this is what I came up with.
>
> instance FromJSON CUid where
> parseJSON (Number n) = do
>
> case floatingOrInteger n of
> Right i  inrange i > return . CUid . fromIntegral $ i
>
>  not an integer, or not in range
> _ > mempty
>
> where
> inrange :: Integer > Bool
> inrange i = fromIntegral i >= (minBound @Word32) &&
> fromIntegral i <= (maxBound @Word32)
>
>  not a number
> parseJSON _ = mempty
>
>
> On Thu, Aug 9, 2018 at 11:37 AM, PICCA FredericEmmanuel <
> fredericemmanuel.picca at synchrotronsoleil.fr> wrote:
>
>> Hello, I try to write the instance for the CUid[1] type
>> But I do not know what to do.
>>
>> instance FromJSON CUid where
>> parseJSON = ...
>> {# INLINE parseJSON #}
>>
>> Thansk for your help
>>
>>
>> [1] https://hackage.haskell.org/package/base4.11.1.0/docs/Syste
>> mPosixTypes.html#t:CUid
>> _______________________________________________
>> Beginners mailing list
>> Beginners at haskell.org
>> http://mail.haskell.org/cgibin/mailman/listinfo/beginners
>>
>
>
 next part 
An HTML attachment was scrubbed...
URL:
From fredericemmanuel.picca at synchrotronsoleil.fr Fri Aug 10 08:05:21 2018
From: fredericemmanuel.picca at synchrotronsoleil.fr (PICCA FredericEmmanuel)
Date: Fri, 10 Aug 2018 08:05:21 +0000
Subject: [Haskellbeginners] How to write the FromJSON instance for CUid
InReplyTo:
References:
,
MessageID:
Hello, and thanks for the reply
What about this
instance FromJSON CGid where
parseJSON x = CGid <$> (parseJSON x :: Parser Word32)
{# INLINE parseJSON #}
Do you think that it deal with all the problem you are trying to prevent ?
Cheers
Fred
From tanuki at gmail.com Fri Aug 10 10:05:44 2018
From: tanuki at gmail.com (Theodore Lief Gannon)
Date: Fri, 10 Aug 2018 03:05:44 0700
Subject: [Haskellbeginners] understanding function signature alignement
InReplyTo:
References:
MessageID:
You're right that the return type is more restricted than the argument, but
it's in an *absolute* sense, not a relative one. It's not possible to relax
`m d` to make it the same type as `c`, but it IS possible to constrain `c`
to be the same as `m d`! And that's how `id` works here: the input in this
case is known to be the same type as the output. You need something wrapped
in a monad, and you already have that, so you just use it asis.
On Thu, Aug 9, 2018, 7:22 AM simkestuff at gmail.com
wrote:
> Thanks, it is still a bit fuzzy to me ...
>
>
> I understand what you did but what confuses me is that when i look at
> function with signature like
>
> f :: Monad m => c > m d
>
> I always think that return type is somehow restricted in comparison to
> input because it demands that output type is wraped inside something (monad
> in this case).
>
> For such signature to fit id signature (a > a) , c type shoud be also
> wraped inside monad but it is not case here...
>
> Anyhow, I still have to figure it out
>
> thanks
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgibin/mailman/listinfo/beginners
>
 next part 
An HTML attachment was scrubbed...
URL:
From toad3k at gmail.com Fri Aug 10 11:40:18 2018
From: toad3k at gmail.com (David McBride)
Date: Fri, 10 Aug 2018 07:40:18 0400
Subject: [Haskellbeginners] How to write the FromJSON instance for CUid
InReplyTo:
References:
MessageID:
Didn't even occur to me that there would already be a Word32 instance.
Looking at the source, it absolutely deals with every case automatically.
On Fri, Aug 10, 2018 at 4:05 AM, PICCA FredericEmmanuel <
fredericemmanuel.picca at synchrotronsoleil.fr> wrote:
> Hello, and thanks for the reply
>
> What about this
>
> instance FromJSON CGid where
> parseJSON x = CGid <$> (parseJSON x :: Parser Word32)
> {# INLINE parseJSON #}
>
>
> Do you think that it deal with all the problem you are trying to prevent ?
>
>
> Cheers
>
> Fred
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgibin/mailman/listinfo/beginners
>
 next part 
An HTML attachment was scrubbed...
URL:
From fredericemmanuel.picca at synchrotronsoleil.fr Fri Aug 10 11:43:23 2018
From: fredericemmanuel.picca at synchrotronsoleil.fr (PICCA FredericEmmanuel)
Date: Fri, 10 Aug 2018 11:43:23 +0000
Subject: [Haskellbeginners] How to write the FromJSON instance for CUid
InReplyTo:
References:
,
MessageID:
> Didn't even occur to me that there would already be a Word32 instance. Looking at the source, it absolutely deals with every case automatically.
Great,
now the real question ;)
I use Generic with aeson and I endup like plenty of other with these orphan instances definietion.
what is the right way to deal with this.
fill a bug against all these types and request instances for these typeclass.
or ?
Cheers
Fred
From simkestuff at gmail.com Fri Aug 10 12:25:56 2018
From: simkestuff at gmail.com (simkestuff at gmail.com)
Date: Fri, 10 Aug 2018 14:25:56 +0200
Subject: [Haskellbeginners] understanding function signature alignement
InReplyTo:
References:
MessageID:
Yes, thinking it the terms that something which is absolutely free to be
whatever, can be restricted and reduced into something else while other way
around is not possible is usefull;
thanks
On Fri, Aug 10, 2018 at 12:06 PM Theodore Lief Gannon
wrote:
> You're right that the return type is more restricted than the argument,
> but it's in an *absolute* sense, not a relative one. It's not possible to
> relax `m d` to make it the same type as `c`, but it IS possible to
> constrain `c` to be the same as `m d`! And that's how `id` works here: the
> input in this case is known to be the same type as the output. You need
> something wrapped in a monad, and you already have that, so you just use it
> asis.
>
> On Thu, Aug 9, 2018, 7:22 AM simkestuff at gmail.com
> wrote:
>
>> Thanks, it is still a bit fuzzy to me ...
>>
>>
>> I understand what you did but what confuses me is that when i look at
>> function with signature like
>>
>> f :: Monad m => c > m d
>>
>> I always think that return type is somehow restricted in comparison to
>> input because it demands that output type is wraped inside something (monad
>> in this case).
>>
>> For such signature to fit id signature (a > a) , c type shoud be also
>> wraped inside monad but it is not case here...
>>
>> Anyhow, I still have to figure it out
>>
>> thanks
>> _______________________________________________
>> Beginners mailing list
>> Beginners at haskell.org
>> http://mail.haskell.org/cgibin/mailman/listinfo/beginners
>>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgibin/mailman/listinfo/beginners
>
 next part 
An HTML attachment was scrubbed...
URL:
From toad3k at gmail.com Fri Aug 10 12:55:09 2018
From: toad3k at gmail.com (David McBride)
Date: Fri, 10 Aug 2018 08:55:09 0400
Subject: [Haskellbeginners] How to write the FromJSON instance for CUid
InReplyTo:
References:
MessageID:
I'm not sure if the maintainers would accept it.
You should keep in mind that these posix types are not necessarily the same
system to system as the word sizes are dependent on the architecture of the
machine involved, thus different machines would have to generate different
instances. If that is the case, it is probably fine to just live with
orphan instances.
But it would be pretty easy to ask them.
On Fri, Aug 10, 2018 at 7:43 AM, PICCA FredericEmmanuel <
fredericemmanuel.picca at synchrotronsoleil.fr> wrote:
> > Didn't even occur to me that there would already be a Word32 instance.
> Looking at the source, it absolutely deals with every case automatically.
>
> Great,
>
> now the real question ;)
>
> I use Generic with aeson and I endup like plenty of other with these
> orphan instances definietion.
>
> what is the right way to deal with this.
>
> fill a bug against all these types and request instances for these
> typeclass.
>
> or ?
>
>
> Cheers
>
> Fred
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgibin/mailman/listinfo/beginners
>
 next part 
An HTML attachment was scrubbed...
URL:
From fredericemmanuel.picca at synchrotronsoleil.fr Fri Aug 10 13:00:32 2018
From: fredericemmanuel.picca at synchrotronsoleil.fr (PICCA FredericEmmanuel)
Date: Fri, 10 Aug 2018 13:00:32 +0000
Subject: [Haskellbeginners] How to write the FromJSON instance for CUid
InReplyTo:
References:
,
MessageID:
> I'm not sure if the maintainers would accept it.
> You should keep in mind that these posix types are not necessarily the same system to system as the word sizes are dependent on the architecture of the machine involved, thus different machines would have to generate different instances. If that is the case, it is probably fine to just live > with orphan instances.
> But it would be pretty easy to ask them.
After some reflection, is it better to ask the aeson maintainer for the instance of the maintainer of the CGid CUid maintainer ?
Cheers
Fred
From toad3k at gmail.com Fri Aug 10 13:39:52 2018
From: toad3k at gmail.com (David McBride)
Date: Fri, 10 Aug 2018 09:39:52 0400
Subject: [Haskellbeginners] How to write the FromJSON instance for CUid
InReplyTo:
References:
MessageID:
Since the posix types are in base, and aeson already depends on base, you
would ask the aeson maintaners.
On Fri, Aug 10, 2018 at 9:00 AM, PICCA FredericEmmanuel <
fredericemmanuel.picca at synchrotronsoleil.fr> wrote:
> > I'm not sure if the maintainers would accept it.
>
> > You should keep in mind that these posix types are not necessarily the
> same system to system as the word sizes are dependent on the architecture
> of the machine involved, thus different machines would have to generate
> different instances. If that is the case, it is probably fine to just live
> > with orphan instances.
>
> > But it would be pretty easy to ask them.
>
> After some reflection, is it better to ask the aeson maintainer for the
> instance of the maintainer of the CGid CUid maintainer ?
>
> Cheers
>
> Fred
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgibin/mailman/listinfo/beginners
>
 next part 
An HTML attachment was scrubbed...
URL:
From fredericemmanuel.picca at synchrotronsoleil.fr Fri Aug 10 13:46:25 2018
From: fredericemmanuel.picca at synchrotronsoleil.fr (PICCA FredericEmmanuel)
Date: Fri, 10 Aug 2018 13:46:25 +0000
Subject: [Haskellbeginners] How to write the FromJSON instance for CUid
InReplyTo:
References:
,
MessageID:
Thanks
Fred
From trent.shipley at gmail.com Wed Aug 15 17:08:29 2018
From: trent.shipley at gmail.com (trent shipley)
Date: Wed, 15 Aug 2018 10:08:29 0700
Subject: [Haskellbeginners] Exercise 7.2a
MessageID:
I am trying to solve Hutton 2016 exercise 7.2a. My attempt gets the same
error message as the one below. The problem with the error message below
is that it is for the book's solved example, so I have no idea how to make
it work. I suspect I have GHCi configured wrong, or an old version that is
buggy on Mac, or such.
Help is appreciated.
Also, at this point I am having trouble reading these function declarations.
all :: (a > Bool) > [Bool] > Bool
all b ls = and (map b ls)
My try:
all ::  name of function defined
(a >  maps to "all"
Bool  maps to boolean function b
) > [Bool]  maps to input ls
> Bool  maps to return type of "all"
all b ls = and (map b ls)
OR (right?)
all ::  name of function defined
(a > Bool) function of type a returns bool
> [Bool]  maps to input ls
> Bool  maps to return type of "all"
all b ls = and (map b ls)

Book example
all :: (a  maps to "all"
> Bool  input function type
) > [Bool]  implied list of things mapped over
> Bool  returned
all p = and . map p
OR (right?)
all ::  name of defined function
(a > Bool)  input function of type a returns type Bool
> [Bool]  implied list to work on
> Bool  return type
all p = and . map p
============================
 CODE
{
2. Without looking at the definitions from the standard prelude, define the
following higherorder library functions on lists.
a.Decide if all elements of a list satisfy a predicate:
all :: (a > Bool) > [Bool] > Bool
b.Decide if any element of a list satisfies a predicate:
any :: (a > Bool) > [Bool] > Bool
c.Select elements from a list while they satisfy a predicate:
takeWhile :: (a > Bool) > [a] > [a]
d.Remove elements from a list while they satisfy a predicate: dropWhile ::
(a > Bool) > [a] > [a]
Note: in the prelude the first two of these functions are generic functions
rather than being specific to the type of lists.
Hutton, Graham. Programming in Haskell (Kindle Locations 28062819).
Cambridge University Press. Kindle Edition.
}
import Prelude hiding (all)
{ My attempt. Presumably bad.
 I swear GHCi was happy with it yesterday.
all :: (a > Bool) > [Bool] > Bool
all b ls = and (map b ls)
}
 from book
all :: (a > Bool) > [Bool] > Bool
all p = and . map p
{
>From GHCi on Mac
Prelude> :r
[1 of 1] Compiling Main ( ex7_2a.hs, interpreted )
ex7_2a.hs:30:9: error:
• Couldn't match type ‘a’ with ‘Bool’
‘a’ is a rigid type variable bound by
the type signature for:
all :: forall a. (a > Bool) > [Bool] > Bool
at ex7_2a.hs:29:136
Expected type: [Bool] > Bool
Actual type: [a] > Bool
• In the expression: and . map p
In an equation for ‘all’: all p = and . map p
• Relevant bindings include
p :: a > Bool (bound at ex7_2a.hs:30:5)
all :: (a > Bool) > [Bool] > Bool (bound at ex7_2a.hs:30:1)

30  all p = and . map p
 ^^^^^^^^^^^
Failed, no modules loaded.
}
 next part 
An HTML attachment was scrubbed...
URL:
From toad3k at gmail.com Wed Aug 15 17:19:57 2018
From: toad3k at gmail.com (David McBride)
Date: Wed, 15 Aug 2018 13:19:57 0400
Subject: [Haskellbeginners] Exercise 7.2a
InReplyTo:
References:
MessageID:
It is because the type of your function all does not match its definition.
The type should be
all :: (a > Bool) > [a] > Bool
You can read it like this, take a function from a to bool, a list of a's
and then give back a bool.
Alternatively you can read it like this. Take a function from a to bool
and return a function that takes a list of a's and returns a bool.
In your original type, the list was restricted to boolean only, but the
function can take any a, and so they don't match, which you can see in the
error message.
On Wed, Aug 15, 2018 at 1:08 PM, trent shipley
wrote:
> I am trying to solve Hutton 2016 exercise 7.2a. My attempt gets the same
> error message as the one below. The problem with the error message below
> is that it is for the book's solved example, so I have no idea how to make
> it work. I suspect I have GHCi configured wrong, or an old version that is
> buggy on Mac, or such.
>
> Help is appreciated.
>
> Also, at this point I am having trouble reading these function
> declarations.
>
> all :: (a > Bool) > [Bool] > Bool
> all b ls = and (map b ls)
>
> My try:
>
> all ::  name of function defined
> (a >  maps to "all"
> Bool  maps to boolean function b
> ) > [Bool]  maps to input ls
> > Bool  maps to return type of "all"
> all b ls = and (map b ls)
>
> OR (right?)
>
> all ::  name of function defined
> (a > Bool) function of type a returns bool
> > [Bool]  maps to input ls
> > Bool  maps to return type of "all"
> all b ls = and (map b ls)
>
> 
>
> Book example
>
> all :: (a  maps to "all"
> > Bool  input function type
> ) > [Bool]  implied list of things mapped over
> > Bool  returned
> all p = and . map p
>
> OR (right?)
>
> all ::  name of defined function
> (a > Bool)  input function of type a returns type Bool
> > [Bool]  implied list to work on
> > Bool  return type
> all p = and . map p
>
>
>
> ============================
>
>  CODE
>
> {
> 2. Without looking at the definitions from the standard prelude, define
> the following higherorder library functions on lists.
>
> a.Decide if all elements of a list satisfy a predicate:
> all :: (a > Bool) > [Bool] > Bool
>
> b.Decide if any element of a list satisfies a predicate:
> any :: (a > Bool) > [Bool] > Bool
>
> c.Select elements from a list while they satisfy a predicate:
> takeWhile :: (a > Bool) > [a] > [a]
>
> d.Remove elements from a list while they satisfy a predicate: dropWhile ::
> (a > Bool) > [a] > [a]
>
> Note: in the prelude the first two of these functions are generic
> functions rather than being specific to the type of lists.
>
> Hutton, Graham. Programming in Haskell (Kindle Locations 28062819).
> Cambridge University Press. Kindle Edition.
> }
>
> import Prelude hiding (all)
>
> { My attempt. Presumably bad.
>  I swear GHCi was happy with it yesterday.
>
> all :: (a > Bool) > [Bool] > Bool
> all b ls = and (map b ls)
>
> }
>
>  from book
>
> all :: (a > Bool) > [Bool] > Bool
> all p = and . map p
>
> {
>
> From GHCi on Mac
>
> Prelude> :r
> [1 of 1] Compiling Main ( ex7_2a.hs, interpreted )
>
> ex7_2a.hs:30:9: error:
> • Couldn't match type ‘a’ with ‘Bool’
> ‘a’ is a rigid type variable bound by
> the type signature for:
> all :: forall a. (a > Bool) > [Bool] > Bool
> at ex7_2a.hs:29:136
> Expected type: [Bool] > Bool
> Actual type: [a] > Bool
> • In the expression: and . map p
> In an equation for ‘all’: all p = and . map p
> • Relevant bindings include
> p :: a > Bool (bound at ex7_2a.hs:30:5)
> all :: (a > Bool) > [Bool] > Bool (bound at ex7_2a.hs:30:1)
> 
> 30  all p = and . map p
>  ^^^^^^^^^^^
> Failed, no modules loaded.
>
> }
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgibin/mailman/listinfo/beginners
>
>
 next part 
An HTML attachment was scrubbed...
URL:
From faml at ariis.it Wed Aug 15 17:22:03 2018
From: faml at ariis.it (Francesco Ariis)
Date: Wed, 15 Aug 2018 19:22:03 +0200
Subject: [Haskellbeginners] Exercise 7.2a
InReplyTo:
References:
MessageID: <20180815172203.jiwzadu7evfdxvfe@x60s.casa>
Hello Trent,
On Wed, Aug 15, 2018 at 10:08:29AM 0700, trent shipley wrote:
> Also, at this point I am having trouble reading these function declarations.
>
> all :: (a > Bool) > [Bool] > Bool
> all b ls = and (map b ls)
There must be a typo in the text. The correct signature is
all :: (a > Bool) > [a] > Bool
Which is logical:
 we take a list of `a`s (`[a]`)
 we pass them through a function `a > Bool`,
obtaining `[Bool]`
 we check if the resulting list is all comprised of `True`s.
Does that help?
From trent.shipley at gmail.com Wed Aug 15 17:58:15 2018
From: trent.shipley at gmail.com (trent shipley)
Date: Wed, 15 Aug 2018 10:58:15 0700
Subject: [Haskellbeginners] Exercise 7.2a
InReplyTo: <20180815172203.jiwzadu7evfdxvfe@x60s.casa>
References:
<20180815172203.jiwzadu7evfdxvfe@x60s.casa>
MessageID:
That helps IMMENSELY!
I shall see if there is errata on the book's web presence.
Thanks,
Trent.
On Wed, Aug 15, 2018 at 10:22 AM Francesco Ariis wrote:
> Hello Trent,
>
> On Wed, Aug 15, 2018 at 10:08:29AM 0700, trent shipley wrote:
> > Also, at this point I am having trouble reading these function
> declarations.
> >
> > all :: (a > Bool) > [Bool] > Bool
> > all b ls = and (map b ls)
>
> There must be a typo in the text. The correct signature is
>
> all :: (a > Bool) > [a] > Bool
>
> Which is logical:
>  we take a list of `a`s (`[a]`)
>  we pass them through a function `a > Bool`,
> obtaining `[Bool]`
>  we check if the resulting list is all comprised of `True`s.
>
> Does that help?
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgibin/mailman/listinfo/beginners
>
 next part 
An HTML attachment was scrubbed...
URL:
From anthonynlee at gmail.com Fri Aug 17 10:46:52 2018
From: anthonynlee at gmail.com (Anthony Lee)
Date: Fri, 17 Aug 2018 06:46:52 0400
Subject: [Haskellbeginners] Bound library questions
MessageID:
In Scope.hs there are some functions I feel difficult to understand,
Why fmap/foldmap/traverse is applied three times?
instance Functor f => Functor (Scope b f) where
fmap f (Scope a) = Scope (fmap (fmap (fmap f)) a)
{# INLINE fmap #}
  @'toList'@ is provides a list (with duplicates) of the free variables
instance Foldable f => Foldable (Scope b f) where
foldMap f (Scope a) = foldMap (foldMap (foldMap f)) a
{# INLINE foldMap #}
instance Traversable f => Traversable (Scope b f) where
traverse f (Scope a) = Scope <$> traverse (traverse (traverse f)) a
{# INLINE traverse #}
 next part 
An HTML attachment was scrubbed...
URL:
From anthonynlee at gmail.com Fri Aug 17 13:21:47 2018
From: anthonynlee at gmail.com (Anthony Lee)
Date: Fri, 17 Aug 2018 09:21:47 0400
Subject: [Haskellbeginners] Beginners Digest, Vol 122, Issue 6
InReplyTo:
References:
MessageID:
The source code is here: https://github.com/ekmett/bound/
On Fri, Aug 17, 2018 at 8:41 AM wrote:
> Send Beginners mailing list submissions to
> beginners at haskell.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://mail.haskell.org/cgibin/mailman/listinfo/beginners
> or, via email, send a message with subject or body 'help' to
> beginnersrequest at haskell.org
>
> You can reach the person managing the list at
> beginnersowner at haskell.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Beginners digest..."
>
>
> Today's Topics:
>
> 1. Bound library questions (Anthony Lee)
>
>
> 
>
> Message: 1
> Date: Fri, 17 Aug 2018 06:46:52 0400
> From: Anthony Lee
> To: beginners at haskell.org
> Subject: [Haskellbeginners] Bound library questions
> MessageID:
> c3sqkAgc0m5Q at mail.gmail.com>
> ContentType: text/plain; charset="utf8"
>
> In Scope.hs there are some functions I feel difficult to understand,
> Why fmap/foldmap/traverse is applied three times?
>
> instance Functor f => Functor (Scope b f) where
> fmap f (Scope a) = Scope (fmap (fmap (fmap f)) a)
> {# INLINE fmap #}
>
>   @'toList'@ is provides a list (with duplicates) of the free variables
> instance Foldable f => Foldable (Scope b f) where
> foldMap f (Scope a) = foldMap (foldMap (foldMap f)) a
> {# INLINE foldMap #}
>
> instance Traversable f => Traversable (Scope b f) where
> traverse f (Scope a) = Scope <$> traverse (traverse (traverse f)) a
> {# INLINE traverse #}
>  next part 
> An HTML attachment was scrubbed...
> URL: <
> http://mail.haskell.org/pipermail/beginners/attachments/20180817/429114c8/attachment0001.html
> >
>
> 
>
> Subject: Digest Footer
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgibin/mailman/listinfo/beginners
>
>
> 
>
> End of Beginners Digest, Vol 122, Issue 6
> *****************************************
>
 next part 
An HTML attachment was scrubbed...
URL:
From toad3k at gmail.com Fri Aug 17 14:23:53 2018
From: toad3k at gmail.com (David McBride)
Date: Fri, 17 Aug 2018 10:23:53 0400
Subject: [Haskellbeginners] Bound library questions
InReplyTo:
References:
MessageID:
The code as it currently stands only has two nested fmaps / foldMaps /
traverses.
The reason he can do that is because Scope is defined as an "f (Var b a)".
Since Scope is only a functor if f is also functor, that means you can fmap
over f, regardless of what it is. But in addition to that Var is also a
functor. So you can fmap over f, and then fmap over the Var inside the f,
which ends up being two nested fmaps. That same condition exists for
foldable and traversable.
On Fri, Aug 17, 2018 at 6:46 AM, Anthony Lee wrote:
> In Scope.hs there are some functions I feel difficult to understand,
> Why fmap/foldmap/traverse is applied three times?
>
> instance Functor f => Functor (Scope b f) where
> fmap f (Scope a) = Scope (fmap (fmap (fmap f)) a)
> {# INLINE fmap #}
>
>   @'toList'@ is provides a list (with duplicates) of the free variables
> instance Foldable f => Foldable (Scope b f) where
> foldMap f (Scope a) = foldMap (foldMap (foldMap f)) a
> {# INLINE foldMap #}
>
> instance Traversable f => Traversable (Scope b f) where
> traverse f (Scope a) = Scope <$> traverse (traverse (traverse f)) a
> {# INLINE traverse #}
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgibin/mailman/listinfo/beginners
>
>
 next part 
An HTML attachment was scrubbed...
URL:
From trent.shipley at gmail.com Sat Aug 18 09:13:25 2018
From: trent.shipley at gmail.com (trent shipley)
Date: Sat, 18 Aug 2018 02:13:25 0700
Subject: [Haskellbeginners] Empty list and null
MessageID:
Why does Haskell so often seem to treat [] as a general null.
For example I know 0 : 1 : [] gives [0, 1].
But shouldn't it produce a type fault in a consistent world?
Int:Int:List isn't properly a list. It mixes types.
I expect something like:
Let GSN mean general_scalar_null.
1 : 2 : GSN  works
1 : 2 : []  type fault, cannot mix int and empty list in the same list.
And why does [] == [] : []
instead of [[], []] == [] : []
What sorts of nullity are there in core Haskell?
Trent.
 next part 
An HTML attachment was scrubbed...
URL:
From utprimum at gmail.com Sat Aug 18 09:34:23 2018
From: utprimum at gmail.com (Ut Primum)
Date: Sat, 18 Aug 2018 11:34:23 +0200
Subject: [Haskellbeginners] Empty list and null
InReplyTo:
References:
MessageID:
If you consider the type of the operator *(:)* you have:
Prelude> :t (:)
(:) :: a > [a] > [a]
So it takes an element of type a and a list. So if you write 1:[2,3,4] the
type is correct, because you give an integer 1 and a list of integers
[2,3,4]. You will obtain the list of integers [1,2,3,4]. Similarly, writing
1:[] is correct and gives you [1] as result.
Then, if you write
0 : 1 : []
(as in your example), is the same as
0 : (1 : [])
so it means 0 : [1], which is [0,1]. So, the operator (:) is right
associative.
If it was left associative, your example would give an error. Indeed
(0 : 1) : []
is not correct in Haskell.
Furthermore, your final examples are both false:
Prelude> [] == [] : []
False
[[], []] == [] : []
False
The following is True:
Prelude> [[]] == [] : []
True
Indeed if you write [] : [] youy mean you want to build a list whose first
element (head) is [] and whose "tail" (i.e. the rest of the list) is the
empty list.
So, if 1:[] is [1], then []:[] is [[]].
Ut
20180818 11:13 GMT+02:00 trent shipley :
> Why does Haskell so often seem to treat [] as a general null.
>
> For example I know 0 : 1 : [] gives [0, 1].
>
> But shouldn't it produce a type fault in a consistent world?
>
> Int:Int:List isn't properly a list. It mixes types.
>
> I expect something like:
>
> Let GSN mean general_scalar_null.
>
> 1 : 2 : GSN  works
>
> 1 : 2 : []  type fault, cannot mix int and empty list in the same list.
>
> And why does [] == [] : []
> instead of [[], []] == [] : []
>
> What sorts of nullity are there in core Haskell?
>
> Trent.
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgibin/mailman/listinfo/beginners
>
>
 next part 
An HTML attachment was scrubbed...
URL:
From faml at ariis.it Sat Aug 18 09:36:56 2018
From: faml at ariis.it (Francesco Ariis)
Date: Sat, 18 Aug 2018 11:36:56 +0200
Subject: [Haskellbeginners] Empty list and null
InReplyTo:
References:
MessageID: <20180818093656.gd2iejhgx7jbvga2@x60s.casa>
Hello Trent,
On Sat, Aug 18, 2018 at 02:13:25AM 0700, trent shipley wrote:
> Why does Haskell so often seem to treat [] as a general null.
>
> For example I know 0 : 1 : [] gives [0, 1].
>
> But shouldn't it produce a type fault in a consistent world?
>
> Int:Int:List isn't properly a list. It mixes types.
`:` is not syntactic sugar, but a data constructor and behaves like one!
λ> :type (:)
(:) :: a > [a] > [a]
"Give me an `a` and a list of `a`, I will return a list."
The `empty list` ([]) is polymorphic:
λ> :t []
[] :: [a]
(it could be an empty list of strings, of ints, of dromedaries),
so `3:[]` is well typed.
Note that `3:[]:4` will not typecheck and that to build a list, you
*have* to start with a `[]`.
From trent.shipley at gmail.com Sat Aug 18 10:08:37 2018
From: trent.shipley at gmail.com (trent shipley)
Date: Sat, 18 Aug 2018 03:08:37 0700
Subject: [Haskellbeginners] Empty list and null
InReplyTo: <20180818093656.gd2iejhgx7jbvga2@x60s.casa>
References:
<20180818093656.gd2iejhgx7jbvga2@x60s.casa>
MessageID:
OK. That makes total sense. And a little experimentation with GHCi or
reading the prelude would have prevented my spamming the list.
What about the tacked on question about nullity in "core" Haskell?
On Sat, Aug 18, 2018 at 2:37 AM Francesco Ariis wrote:
> Hello Trent,
>
> On Sat, Aug 18, 2018 at 02:13:25AM 0700, trent shipley wrote:
> > Why does Haskell so often seem to treat [] as a general null.
> >
> > For example I know 0 : 1 : [] gives [0, 1].
> >
> > But shouldn't it produce a type fault in a consistent world?
> >
> > Int:Int:List isn't properly a list. It mixes types.
>
> `:` is not syntactic sugar, but a data constructor and behaves like one!
>
> λ> :type (:)
> (:) :: a > [a] > [a]
>
> "Give me an `a` and a list of `a`, I will return a list."
>
> The `empty list` ([]) is polymorphic:
>
> λ> :t []
> [] :: [a]
>
> (it could be an empty list of strings, of ints, of dromedaries),
> so `3:[]` is well typed.
>
> Note that `3:[]:4` will not typecheck and that to build a list, you
> *have* to start with a `[]`.
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgibin/mailman/listinfo/beginners
>
 next part 
An HTML attachment was scrubbed...
URL:
From tanuki at gmail.com Sat Aug 18 10:35:40 2018
From: tanuki at gmail.com (Theodore Lief Gannon)
Date: Sat, 18 Aug 2018 03:35:40 0700
Subject: [Haskellbeginners] Empty list and null
InReplyTo:
References:
<20180818093656.gd2iejhgx7jbvga2@x60s.casa>
MessageID:
The nullary constructor, as far as the term has meaning in most languages,
is () a.k.a. unit. It takes no arguments, and returns a valid data type.
There is, however, an even less populated type: Void has no legal values at
all! If nullary is arity 0, this is roughly arity i. It is still useful as
a typelevel encoding of "impossible outcome" in parametric code.
On Sat, Aug 18, 2018, 3:09 AM trent shipley wrote:
> OK. That makes total sense. And a little experimentation with GHCi or
> reading the prelude would have prevented my spamming the list.
>
> What about the tacked on question about nullity in "core" Haskell?
>
> On Sat, Aug 18, 2018 at 2:37 AM Francesco Ariis wrote:
>
>> Hello Trent,
>>
>> On Sat, Aug 18, 2018 at 02:13:25AM 0700, trent shipley wrote:
>> > Why does Haskell so often seem to treat [] as a general null.
>> >
>> > For example I know 0 : 1 : [] gives [0, 1].
>> >
>> > But shouldn't it produce a type fault in a consistent world?
>> >
>> > Int:Int:List isn't properly a list. It mixes types.
>>
>> `:` is not syntactic sugar, but a data constructor and behaves like one!
>>
>> λ> :type (:)
>> (:) :: a > [a] > [a]
>>
>> "Give me an `a` and a list of `a`, I will return a list."
>>
>> The `empty list` ([]) is polymorphic:
>>
>> λ> :t []
>> [] :: [a]
>>
>> (it could be an empty list of strings, of ints, of dromedaries),
>> so `3:[]` is well typed.
>>
>> Note that `3:[]:4` will not typecheck and that to build a list, you
>> *have* to start with a `[]`.
>>
>> _______________________________________________
>> Beginners mailing list
>> Beginners at haskell.org
>> http://mail.haskell.org/cgibin/mailman/listinfo/beginners
>>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgibin/mailman/listinfo/beginners
>
 next part 
An HTML attachment was scrubbed...
URL:
From anthonynlee at gmail.com Sat Aug 18 15:11:20 2018
From: anthonynlee at gmail.com (Anthony Lee)
Date: Sat, 18 Aug 2018 11:11:20 0400
Subject: [Haskellbeginners] Bound library questions (David McBride)
InReplyTo:
References:
MessageID:
Now I understand it.
Thanks a lot!
Anthony
On Sat, Aug 18, 2018 at 5:34 AM wrote:
> Send Beginners mailing list submissions to
> beginners at haskell.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://mail.haskell.org/cgibin/mailman/listinfo/beginners
> or, via email, send a message with subject or body 'help' to
> beginnersrequest at haskell.org
>
> You can reach the person managing the list at
> beginnersowner at haskell.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Beginners digest..."
>
>
> Today's Topics:
>
> 1. Re: Beginners Digest, Vol 122, Issue 6 (Anthony Lee)
> 2. Re: Bound library questions (David McBride)
> 3. Empty list and null (trent shipley)
> 4. Re: Empty list and null (Ut Primum)
>
>
> 
>
> Message: 1
> Date: Fri, 17 Aug 2018 09:21:47 0400
> From: Anthony Lee
> To: beginners at haskell.org
> Subject: Re: [Haskellbeginners] Beginners Digest, Vol 122, Issue 6
> MessageID:
> L9bONcCb0y+UPSGq6jpVgq60ouKUNk4xNv3w at mail.gmail.com>
> ContentType: text/plain; charset="utf8"
>
> The source code is here: https://github.com/ekmett/bound/
>
> On Fri, Aug 17, 2018 at 8:41 AM wrote:
>
> > Send Beginners mailing list submissions to
> > beginners at haskell.org
> >
> > To subscribe or unsubscribe via the World Wide Web, visit
> > http://mail.haskell.org/cgibin/mailman/listinfo/beginners
> > or, via email, send a message with subject or body 'help' to
> > beginnersrequest at haskell.org
> >
> > You can reach the person managing the list at
> > beginnersowner at haskell.org
> >
> > When replying, please edit your Subject line so it is more specific
> > than "Re: Contents of Beginners digest..."
> >
> >
> > Today's Topics:
> >
> > 1. Bound library questions (Anthony Lee)
> >
> >
> > 
> >
> > Message: 1
> > Date: Fri, 17 Aug 2018 06:46:52 0400
> > From: Anthony Lee
> > To: beginners at haskell.org
> > Subject: [Haskellbeginners] Bound library questions
> > MessageID:
> > > c3sqkAgc0m5Q at mail.gmail.com>
> > ContentType: text/plain; charset="utf8"
> >
> > In Scope.hs there are some functions I feel difficult to understand,
> > Why fmap/foldmap/traverse is applied three times?
> >
> > instance Functor f => Functor (Scope b f) where
> > fmap f (Scope a) = Scope (fmap (fmap (fmap f)) a)
> > {# INLINE fmap #}
> >
> >   @'toList'@ is provides a list (with duplicates) of the free
> variables
> > instance Foldable f => Foldable (Scope b f) where
> > foldMap f (Scope a) = foldMap (foldMap (foldMap f)) a
> > {# INLINE foldMap #}
> >
> > instance Traversable f => Traversable (Scope b f) where
> > traverse f (Scope a) = Scope <$> traverse (traverse (traverse f)) a
> > {# INLINE traverse #}
> >  next part 
> > An HTML attachment was scrubbed...
> > URL: <
> >
> http://mail.haskell.org/pipermail/beginners/attachments/20180817/429114c8/attachment0001.html
> > >
> >
> > 
> >
> > Subject: Digest Footer
> >
> > _______________________________________________
> > Beginners mailing list
> > Beginners at haskell.org
> > http://mail.haskell.org/cgibin/mailman/listinfo/beginners
> >
> >
> > 
> >
> > End of Beginners Digest, Vol 122, Issue 6
> > *****************************************
> >
>  next part 
> An HTML attachment was scrubbed...
> URL: <
> http://mail.haskell.org/pipermail/beginners/attachments/20180817/2112c0e7/attachment0001.html
> >
>
> 
>
> Message: 2
> Date: Fri, 17 Aug 2018 10:23:53 0400
> From: David McBride
> To: The HaskellBeginners Mailing List  Discussion of primarily
> beginnerlevel topics related to Haskell
> Subject: Re: [Haskellbeginners] Bound library questions
> MessageID:
> JrmRR5ToPm93jw at mail.gmail.com>
> ContentType: text/plain; charset="utf8"
>
> The code as it currently stands only has two nested fmaps / foldMaps /
> traverses.
>
> The reason he can do that is because Scope is defined as an "f (Var b a)".
> Since Scope is only a functor if f is also functor, that means you can fmap
> over f, regardless of what it is. But in addition to that Var is also a
> functor. So you can fmap over f, and then fmap over the Var inside the f,
> which ends up being two nested fmaps. That same condition exists for
> foldable and traversable.
>
> On Fri, Aug 17, 2018 at 6:46 AM, Anthony Lee
> wrote:
>
> > In Scope.hs there are some functions I feel difficult to understand,
> > Why fmap/foldmap/traverse is applied three times?
> >
> > instance Functor f => Functor (Scope b f) where
> > fmap f (Scope a) = Scope (fmap (fmap (fmap f)) a)
> > {# INLINE fmap #}
> >
> >   @'toList'@ is provides a list (with duplicates) of the free
> variables
> > instance Foldable f => Foldable (Scope b f) where
> > foldMap f (Scope a) = foldMap (foldMap (foldMap f)) a
> > {# INLINE foldMap #}
> >
> > instance Traversable f => Traversable (Scope b f) where
> > traverse f (Scope a) = Scope <$> traverse (traverse (traverse f)) a
> > {# INLINE traverse #}
> >
> > _______________________________________________
> > Beginners mailing list
> > Beginners at haskell.org
> > http://mail.haskell.org/cgibin/mailman/listinfo/beginners
> >
> >
>  next part 
> An HTML attachment was scrubbed...
> URL: <
> http://mail.haskell.org/pipermail/beginners/attachments/20180817/e0fbde97/attachment0001.html
> >
>
> 
>
> Message: 3
> Date: Sat, 18 Aug 2018 02:13:25 0700
> From: trent shipley
> To: Haskell Beginners
> Subject: [Haskellbeginners] Empty list and null
> MessageID:
> Q2A at mail.gmail.com>
> ContentType: text/plain; charset="utf8"
>
> Why does Haskell so often seem to treat [] as a general null.
>
> For example I know 0 : 1 : [] gives [0, 1].
>
> But shouldn't it produce a type fault in a consistent world?
>
> Int:Int:List isn't properly a list. It mixes types.
>
> I expect something like:
>
> Let GSN mean general_scalar_null.
>
> 1 : 2 : GSN  works
>
> 1 : 2 : []  type fault, cannot mix int and empty list in the same list.
>
> And why does [] == [] : []
> instead of [[], []] == [] : []
>
> What sorts of nullity are there in core Haskell?
>
> Trent.
>  next part 
> An HTML attachment was scrubbed...
> URL: <
> http://mail.haskell.org/pipermail/beginners/attachments/20180818/dd3bff19/attachment0001.html
> >
>
> 
>
> Message: 4
> Date: Sat, 18 Aug 2018 11:34:23 +0200
> From: Ut Primum
> To: The HaskellBeginners Mailing List  Discussion of primarily
> beginnerlevel topics related to Haskell
> Subject: Re: [Haskellbeginners] Empty list and null
> MessageID:
> xW0WLe_MF5MJ7sn_+yF6WBCGVmQ at mail.gmail.com>
> ContentType: text/plain; charset="utf8"
>
> If you consider the type of the operator *(:)* you have:
>
> Prelude> :t (:)
> (:) :: a > [a] > [a]
>
> So it takes an element of type a and a list. So if you write 1:[2,3,4] the
> type is correct, because you give an integer 1 and a list of integers
> [2,3,4]. You will obtain the list of integers [1,2,3,4]. Similarly, writing
> 1:[] is correct and gives you [1] as result.
>
> Then, if you write
> 0 : 1 : []
> (as in your example), is the same as
> 0 : (1 : [])
> so it means 0 : [1], which is [0,1]. So, the operator (:) is right
> associative.
>
> If it was left associative, your example would give an error. Indeed
> (0 : 1) : []
> is not correct in Haskell.
>
> Furthermore, your final examples are both false:
>
> Prelude> [] == [] : []
> False
>
> [[], []] == [] : []
> False
>
> The following is True:
> Prelude> [[]] == [] : []
> True
>
> Indeed if you write [] : [] youy mean you want to build a list whose first
> element (head) is [] and whose "tail" (i.e. the rest of the list) is the
> empty list.
> So, if 1:[] is [1], then []:[] is [[]].
>
> Ut
>
> 20180818 11:13 GMT+02:00 trent shipley :
>
> > Why does Haskell so often seem to treat [] as a general null.
> >
> > For example I know 0 : 1 : [] gives [0, 1].
> >
> > But shouldn't it produce a type fault in a consistent world?
> >
> > Int:Int:List isn't properly a list. It mixes types.
> >
> > I expect something like:
> >
> > Let GSN mean general_scalar_null.
> >
> > 1 : 2 : GSN  works
> >
> > 1 : 2 : []  type fault, cannot mix int and empty list in the same
> list.
> >
> > And why does [] == [] : []
> > instead of [[], []] == [] : []
> >
> > What sorts of nullity are there in core Haskell?
> >
> > Trent.
> >
> >
> > _______________________________________________
> > Beginners mailing list
> > Beginners at haskell.org
> > http://mail.haskell.org/cgibin/mailman/listinfo/beginners
> >
> >
>  next part 
> An HTML attachment was scrubbed...
> URL: <
> http://mail.haskell.org/pipermail/beginners/attachments/20180818/0eebd5a6/attachment.html
> >
>
> 
>
> Subject: Digest Footer
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgibin/mailman/listinfo/beginners
>
>
> 
>
> End of Beginners Digest, Vol 122, Issue 7
> *****************************************
>
 next part 
An HTML attachment was scrubbed...
URL:
From anthonynlee at gmail.com Sun Aug 19 20:31:57 2018
From: anthonynlee at gmail.com (Anthony Lee)
Date: Sun, 19 Aug 2018 16:31:57 0400
Subject: [Haskellbeginners] What should be inside the Monad or MonadTrans's
type declaration? Bound library question2.
MessageID:
Hi,
In Scope.hs there is one instance of Monad and one instance of MonadTrans
for Scope,
For the Monad instance, it is defined like this: Monad (Scope b f);
For the MonadTrans instance, it is like this: MonadTrans (Scope b);
Does it mean:
In ">>=" the e represents (a) of (Scope b f a)?
In lift function the m represents (f a) of (Scope b f a)?
https://github.com/ekmett/bound/blob/master/src/Bound/Scope.hs
========================Scope.hs================================
instance Monad f => Monad (Scope b f) where
#if !MIN_VERSION_base(4,8,0)
return a = Scope (return (F (return a)))
{# INLINE return #}
#endif
Scope e >>= f = Scope $ e >>= \v > case v of
B b > return (B b)
F ea > ea >>= unscope . f
{# INLINE (>>=) #}
instance MonadTrans (Scope b) where
lift m = Scope (return (F m))
{# INLINE lift #}
 next part 
An HTML attachment was scrubbed...
URL:
From toad3k at gmail.com Sun Aug 19 21:20:05 2018
From: toad3k at gmail.com (David McBride)
Date: Sun, 19 Aug 2018 17:20:05 0400
Subject: [Haskellbeginners] What should be inside the Monad or
MonadTrans's type declaration? Bound library question2.
InReplyTo:
References:
MessageID:
When you are defining a class, the actual type that the class will accept
can be further restricted. For example
:i Num
class Num a where
is shorthand for
class Num (a :: *) where
When you see the *, you should say in your head the word "type". Off
topic, but In fact in future ghc releases, you will stop using * and use
the Type type in its place, because it is clearer. So any Num instances
require a single Type to be complete.
That means that only types that can be an instance of Num must have a kind
*. Things that have that type are plain types that don't have extra
variables, such as Int, (), and Char. If you tried to make Maybe an
instance of Num it just wouldn't work.
Monad takes a different type
:i Monad
class Applicative m => Monad (m :: * > *) where
It says that the only Monad instances take a Type and return a Type. For
example Maybe takes a * and returns a *. That means you can apply Int, (),
and Char to Maybe and you will get back a complete Type (ie. Maybe Int).
So while Maybe can't be a num, Maybe Int absolutely can be an instance of
Num. Other types that can be Monads  IO, [] (list) for example.
MonadTrans is even more involed
class MonadTrans (t :: (* > *) > * > *) where
So, in this case it takes a type that is like Maybe or IO, and then also
takes another that is like Int or Char. The standard example is StateT.
newtype StateT s (m :: * > *) a
instance [safe] MonadTrans (StateT s)
So you can see how the types fit together. MonadTrans requires a type that
has the right shape, and StateT s without the extra paramters fits
perfectly.
So when you have a
newtype Scope b f a = Scope { unscope :: f (Var b (f a)) }
You can see that if a is a monomorphic type like Char or Int, then f has
to be something like Maybe [], or IO, or Maybe. So you can see how Scope
fits into both Monad and MonadTrans.
instance Monad f => Monad (Scope b f) where
instance MonadTrans (Scope b) where
Hopefully this gives you some intuition on how it works?
On Sun, Aug 19, 2018 at 4:31 PM, Anthony Lee wrote:
> Hi,
> In Scope.hs there is one instance of Monad and one instance of MonadTrans
> for Scope,
> For the Monad instance, it is defined like this: Monad (Scope b f);
> For the MonadTrans instance, it is like this: MonadTrans (Scope b);
> Does it mean:
> In ">>=" the e represents (a) of (Scope b f a)?
> In lift function the m represents (f a) of (Scope b f a)?
>
> https://github.com/ekmett/bound/blob/master/src/Bound/Scope.hs
> ========================Scope.hs================================
> instance Monad f => Monad (Scope b f) where
> #if !MIN_VERSION_base(4,8,0)
> return a = Scope (return (F (return a)))
> {# INLINE return #}
> #endif
> Scope e >>= f = Scope $ e >>= \v > case v of
> B b > return (B b)
> F ea > ea >>= unscope . f
> {# INLINE (>>=) #}
>
> instance MonadTrans (Scope b) where
> lift m = Scope (return (F m))
> {# INLINE lift #}
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgibin/mailman/listinfo/beginners
>
>
 next part 
An HTML attachment was scrubbed...
URL:
From 50295 at web.de Tue Aug 21 00:04:01 2018
From: 50295 at web.de (Olumide)
Date: Tue, 21 Aug 2018 01:04:01 +0100
Subject: [Haskellbeginners] Need better explanation of the 'flipThree'
example in LYAH
MessageID: <83c66b35f9344a09427424585cb0d3bb@web.de>
Dear List,
I'm trying to understand the following example from LYAH
import Data.List (all)
flipThree :: Prob Bool
flipThree = do
a < coin
b < coin
c < loadedCoin
return (all (==Tails) [a,b,c])
Where
import Data.Ratio
newtype Prob a = Prob { getProb :: [(a,Rational)] } deriving Show
and
data Coin = Heads  Tails deriving (Show, Eq)
coin :: Prob Coin
coin = Prob [(Heads,1%2),(Tails,1%2)]
loadedCoin :: Prob Coin
loadedCoin = Prob [(Heads,1%10),(Tails,9%10)]
The result:
ghci> getProb flipThree
[(False,1 % 40),(False,9 % 40),(False,1 % 40),(False,9 % 40),
(False,1 % 40),(False,9 % 40),(False,1 % 40),(True,9 % 40)]
See http://learnyouahaskell.com/forafewmonadsmore#makingmonads.
My understanding of what's going on here is sketchy at best. One of
several explanations that I am considering is that all combination of a,
b and c are evaluated in (==Tails) [a,b,c] but I cannot explain how the
all function creates 'fuses' the list [f a, f b, f c]. I know that all f
xs = and . map f xs (the definition on hackage is a lot more
complicated) but, again, I cannot explain how the and function 'fuses'
the list [f a, f b, f c].
If I'm on the right track I realize that I'm going to have to study the
list the between list comprehensions and the donotation in order how
all the return function create one Prob.
Regards,
 Olumide
From faml at ariis.it Tue Aug 21 01:00:57 2018
From: faml at ariis.it (Francesco Ariis)
Date: Tue, 21 Aug 2018 03:00:57 +0200
Subject: [Haskellbeginners] Need better explanation of the 'flipThree'
example in LYAH
InReplyTo: <83c66b35f9344a09427424585cb0d3bb@web.de>
References: <83c66b35f9344a09427424585cb0d3bb@web.de>
MessageID: <20180821010057.cyu6pg6mdb5fq5ff@x60s.casa>
Hello Olumide,
On Tue, Aug 21, 2018 at 01:04:01AM +0100, Olumide wrote:
> My understanding of what's going on here is sketchy at best. One of several
> explanations that I am considering is that all combination of a, b and c are
> evaluated in (==Tails) [a,b,c] but I cannot explain how the all function
> creates 'fuses' the list [f a, f b, f c]. I know that all f xs = and . map f
> xs (the definition on hackage is a lot more complicated) but, again, I
> cannot explain how the and function 'fuses' the list [f a, f b, f c].
Let's copy the relevant monad instance:
instance Monad Prob where
return x = Prob [(x,1%1)]
m >>= f = flatten (fmap f m)
and desugar `flipThree:
flipThree = coin >>= \a >
coin >>= \b >
loadedCoin >>= \c >
return (all (==Tails) [a,b,c])
Now it should be clearer: `coin >>= \a > ...something...` takes `coin`
(Prob [(Heads,1%2),(Tails,1%2)]), applies a function (\a > ...) to all
of its elements, flattens (probability wise) the result.
So approximately we have:
1. some list ([a, b])
2. nested lists after applying `\a > ...` [[a1, a2], [b1, b2]]
3. some more flattened list [a1, a2, b1, b2]
`\a > ...` itself contains `\b >` which cointains `\c >`, those are
nested rounds of the same (>>=) trick we saw above.
At each time the intermediate result is bound to a variable (\a, \b
and \c), so for each triplet we can use `all`.
> If I'm on the right track I realize that I'm going to have to study the list
> the between list comprehensions and the donotation in order how all the
> return function create one Prob.
Indeed I recall working the example on paper the first time I read it:
once you do it, it should stick!
From trent.shipley at gmail.com Wed Aug 22 11:00:29 2018
From: trent.shipley at gmail.com (trent shipley)
Date: Wed, 22 Aug 2018 04:00:29 0700
Subject: [Haskellbeginners] Hutton 2nd ed, ex 7.6
MessageID:
1. I got through the problem without getting so stuck I had to ask this
list. But, I am disappointed in how much I had to cheat by looking up
solutions on Google after making my best attempt. This higher order
functions chapter is giving more trouble than any chapter so far.
2. Since getting tutoring on how to read function declarations, I'm doing
better at deciphering simple declarations, but writing them myself is
beyond me more often than not.
3. I feel like Hutton introduces concepts well, but with more brevity and
fewer examples than would be best for me. Unfortunately, he leaves out
almost all the ancillary pragmatics as exemplified by the need for "null"
and "const" below. My bet is that when Hutton 2nd ed is used as a textbook
in college those practical lacks get covered in lecture, problem sessions,
and in mutual aid between students.
Does anyone have any idea on how I might improve my performance. I am not
used to having difficulty learning a computer language. (Prolog and Java
Swing being exceptions.)
{
6. A higherorder function unfold that encapsulates a simple pattern of
recursion for producing a list can be defined as follows:
unfold p h t x  p x = []
 otherwise = h x : unfold p h t (t x)
That is, the function unfold p h t produces the empty list if the predicate
p is true of the argument value, and otherwise produces a nonempty list by
applying the function h to this value to give the head, and the function t
to generate another argument that is recursively processed in the same way
to produce the tail of the list. For example, the function int2bin can be
rewritten more compactly using unfold as follows:
int2bin = unfold (==0) (‘mod‘ 2) (‘div‘ 2)
Redefine the functions chop8, map f and iterate f using unfold.
Hutton, Graham. Programming in Haskell (Kindle Locations 28302842).
Cambridge University Press. Kindle Edition.
Basically, what you do to develop and test this question is to copy and
paste extended example 7.6 Binary String Transmittter from the chapter into
your text editor. Then you alter large chunks of it to use the unfold
function.
}
import Data.Char
import Prelude hiding (iterate, map)
type Bit = Int
 I had to crib the type signature
unfold :: (b > Bool) > (b > a) > (b > b) > b > [a]
unfold p h t x  p x = []
 otherwise = h x : unfold p h t (t x)
 Hutton, Graham. Programming in Haskell (Kindle Location 2329). Cambridge
University Press. Kindle Edition.
 cribbed type signature
 Had to copy (f . head), my attempt was (f head).
 I had no idea the function "null" existed before Googling the solution.
 Is Googling to learn the existence of "null" accepted pedagological
practice?
 Is it a lacuna on Hutton's part?
map :: (a > b) > [a] > [b]
map f = unfold null (f . head) tail
 had to copy the signature, although I didn't try hard to come up with it
on my own.
 I had tried to use (==[]). I got the solution "False" by copying from
the internet.
 I would not have gotten the word "const" without cheating from the
internet. It is nowhere in Hutton's book up to this point.
iterate :: (a > a) > a > [a]
iterate f = unfold (const False) id f
 chop8 :: [Bit] > [[Bit]]
 chop8 [] = []
 chop8 bits = take 8 bits : chop8 (drop 8 bits)
 Hutton, Graham. Programming in Haskell (Kindle Locations 26812683).
Cambridge University Press. Kindle Edition.
 I attempted this first, and i pretty much got it on my own.
chop8 :: [Bit] > [[Bit]]
chop8 bits = unfold (==[]) (take 8) (drop 8) bits
 next part 
An HTML attachment was scrubbed...
URL:
From toad3k at gmail.com Wed Aug 22 12:35:37 2018
From: toad3k at gmail.com (David McBride)
Date: Wed, 22 Aug 2018 08:35:37 0400
Subject: [Haskellbeginners] Hutton 2nd ed, ex 7.6
InReplyTo:
References:
MessageID:
It sounds to me like you are just lacking a familiarity with the standard
library. All of the list functions (such as null) are detailed on hackage (
http://hackage.haskell.org/package/base/docs/DataList.html) with
reasonable examples.
There is also hoogle https://www.haskell.org/hoogle/, which allows you to
search both for function names as well as types and operators like (.), all
of which link to the documentation.
As for unfold's type signature, the first thing any haskell programmer
would have done is load it into ghci, and type :t unfold. I could get it
from his description of the function, and perhaps that would have been good
practice, but there's no need to turn to google for that.
:t unfold
unfold :: (t > Bool) > (t > a) > (t > t) > t > [a]
Haskell's a pretty different language from most of the mainstream
languages. I wouldn't feel bad because your previous experience barely
applies and also these exercises are not the easiest I've ever seen.
Unfold is not a standard function in haskell and so being able to derive
standard functions from it is more of an algorithmic problem than a
learning haskell problem. In any case, I think based on what you've
written that you are doing just fine.
On Wed, Aug 22, 2018 at 7:00 AM, trent shipley
wrote:
> 1. I got through the problem without getting so stuck I had to ask this
> list. But, I am disappointed in how much I had to cheat by looking up
> solutions on Google after making my best attempt. This higher order
> functions chapter is giving more trouble than any chapter so far.
>
> 2. Since getting tutoring on how to read function declarations, I'm doing
> better at deciphering simple declarations, but writing them myself is
> beyond me more often than not.
>
> 3. I feel like Hutton introduces concepts well, but with more brevity and
> fewer examples than would be best for me. Unfortunately, he leaves out
> almost all the ancillary pragmatics as exemplified by the need for "null"
> and "const" below. My bet is that when Hutton 2nd ed is used as a textbook
> in college those practical lacks get covered in lecture, problem sessions,
> and in mutual aid between students.
>
> Does anyone have any idea on how I might improve my performance. I am not
> used to having difficulty learning a computer language. (Prolog and Java
> Swing being exceptions.)
>
>
> {
>
> 6. A higherorder function unfold that encapsulates a simple pattern of
> recursion for producing a list can be defined as follows:
>
> unfold p h t x  p x = []
>  otherwise = h x : unfold p h t (t x)
>
> That is, the function unfold p h t produces the empty list if the
> predicate p is true of the argument value, and otherwise produces a
> nonempty list by applying the function h to this value to give the head,
> and the function t to generate another argument that is recursively
> processed in the same way to produce the tail of the list. For example, the
> function int2bin can be rewritten more compactly using unfold as follows:
>
> int2bin = unfold (==0) (‘mod‘ 2) (‘div‘ 2)
>
> Redefine the functions chop8, map f and iterate f using unfold.
>
> Hutton, Graham. Programming in Haskell (Kindle Locations 28302842).
> Cambridge University Press. Kindle Edition.
>
> Basically, what you do to develop and test this question is to copy and
> paste extended example 7.6 Binary String Transmittter from the chapter into
> your text editor. Then you alter large chunks of it to use the unfold
> function.
>
> }
>
> import Data.Char
> import Prelude hiding (iterate, map)
>
> type Bit = Int
>
>
>  I had to crib the type signature
>
> unfold :: (b > Bool) > (b > a) > (b > b) > b > [a]
> unfold p h t x  p x = []
>  otherwise = h x : unfold p h t (t x)
>
>
>  Hutton, Graham. Programming in Haskell (Kindle Location 2329).
> Cambridge University Press. Kindle Edition.
>
>  cribbed type signature
>  Had to copy (f . head), my attempt was (f head).
>  I had no idea the function "null" existed before Googling the solution.
>  Is Googling to learn the existence of "null" accepted pedagological
> practice?
>  Is it a lacuna on Hutton's part?
>
> map :: (a > b) > [a] > [b]
> map f = unfold null (f . head) tail
>
>  had to copy the signature, although I didn't try hard to come up with
> it on my own.
>  I had tried to use (==[]). I got the solution "False" by copying from
> the internet.
>  I would not have gotten the word "const" without cheating from the
> internet. It is nowhere in Hutton's book up to this point.
>
> iterate :: (a > a) > a > [a]
> iterate f = unfold (const False) id f
>
>  chop8 :: [Bit] > [[Bit]]
>  chop8 [] = []
>  chop8 bits = take 8 bits : chop8 (drop 8 bits)
>
>  Hutton, Graham. Programming in Haskell (Kindle Locations 26812683).
> Cambridge University Press. Kindle Edition.
>
>  I attempted this first, and i pretty much got it on my own.
>
> chop8 :: [Bit] > [[Bit]]
> chop8 bits = unfold (==[]) (take 8) (drop 8) bits
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgibin/mailman/listinfo/beginners
>
>
 next part 
An HTML attachment was scrubbed...
URL:
From tanuki at gmail.com Wed Aug 22 22:23:11 2018
From: tanuki at gmail.com (Theodore Lief Gannon)
Date: Wed, 22 Aug 2018 15:23:11 0700
Subject: [Haskellbeginners] Hutton 2nd ed, ex 7.6
InReplyTo:
References:
MessageID:
I'm not familiar with Hutton, and I agree that unless one of the book's
exercises was "read the Prelude docs" it shouldn't be expecting you to use
functions it hasn't introduced. In all fairness, though, both null and
const have inline expansions that you probably could have come up with. In
fact, you DID come up with null, just in the wrong context: specialized to
lists, it's (==[]). And you can write (const False) as a lambda: (\_ >
False)
On Wed, Aug 22, 2018, 5:36 AM David McBride wrote:
> It sounds to me like you are just lacking a familiarity with the standard
> library. All of the list functions (such as null) are detailed on hackage (
> http://hackage.haskell.org/package/base/docs/DataList.html) with
> reasonable examples.
>
> There is also hoogle https://www.haskell.org/hoogle/, which allows you to
> search both for function names as well as types and operators like (.), all
> of which link to the documentation.
>
> As for unfold's type signature, the first thing any haskell programmer
> would have done is load it into ghci, and type :t unfold. I could get it
> from his description of the function, and perhaps that would have been good
> practice, but there's no need to turn to google for that.
> :t unfold
> unfold :: (t > Bool) > (t > a) > (t > t) > t > [a]
>
> Haskell's a pretty different language from most of the mainstream
> languages. I wouldn't feel bad because your previous experience barely
> applies and also these exercises are not the easiest I've ever seen.
> Unfold is not a standard function in haskell and so being able to derive
> standard functions from it is more of an algorithmic problem than a
> learning haskell problem. In any case, I think based on what you've
> written that you are doing just fine.
>
> On Wed, Aug 22, 2018 at 7:00 AM, trent shipley
> wrote:
>
>> 1. I got through the problem without getting so stuck I had to ask this
>> list. But, I am disappointed in how much I had to cheat by looking up
>> solutions on Google after making my best attempt. This higher order
>> functions chapter is giving more trouble than any chapter so far.
>>
>> 2. Since getting tutoring on how to read function declarations, I'm doing
>> better at deciphering simple declarations, but writing them myself is
>> beyond me more often than not.
>>
>> 3. I feel like Hutton introduces concepts well, but with more brevity and
>> fewer examples than would be best for me. Unfortunately, he leaves out
>> almost all the ancillary pragmatics as exemplified by the need for "null"
>> and "const" below. My bet is that when Hutton 2nd ed is used as a textbook
>> in college those practical lacks get covered in lecture, problem sessions,
>> and in mutual aid between students.
>>
>> Does anyone have any idea on how I might improve my performance. I am
>> not used to having difficulty learning a computer language. (Prolog and
>> Java Swing being exceptions.)
>>
>>
>> {
>>
>> 6. A higherorder function unfold that encapsulates a simple pattern of
>> recursion for producing a list can be defined as follows:
>>
>> unfold p h t x  p x = []
>>  otherwise = h x : unfold p h t (t x)
>>
>> That is, the function unfold p h t produces the empty list if the
>> predicate p is true of the argument value, and otherwise produces a
>> nonempty list by applying the function h to this value to give the head,
>> and the function t to generate another argument that is recursively
>> processed in the same way to produce the tail of the list. For example, the
>> function int2bin can be rewritten more compactly using unfold as follows:
>>
>> int2bin = unfold (==0) (‘mod‘ 2) (‘div‘ 2)
>>
>> Redefine the functions chop8, map f and iterate f using unfold.
>>
>> Hutton, Graham. Programming in Haskell (Kindle Locations 28302842).
>> Cambridge University Press. Kindle Edition.
>>
>> Basically, what you do to develop and test this question is to copy and
>> paste extended example 7.6 Binary String Transmittter from the chapter into
>> your text editor. Then you alter large chunks of it to use the unfold
>> function.
>>
>> }
>>
>> import Data.Char
>> import Prelude hiding (iterate, map)
>>
>> type Bit = Int
>>
>>
>>  I had to crib the type signature
>>
>> unfold :: (b > Bool) > (b > a) > (b > b) > b > [a]
>> unfold p h t x  p x = []
>>  otherwise = h x : unfold p h t (t x)
>>
>>
>>  Hutton, Graham. Programming in Haskell (Kindle Location 2329).
>> Cambridge University Press. Kindle Edition.
>>
>>  cribbed type signature
>>  Had to copy (f . head), my attempt was (f head).
>>  I had no idea the function "null" existed before Googling the
>> solution.
>>  Is Googling to learn the existence of "null" accepted pedagological
>> practice?
>>  Is it a lacuna on Hutton's part?
>>
>> map :: (a > b) > [a] > [b]
>> map f = unfold null (f . head) tail
>>
>>  had to copy the signature, although I didn't try hard to come up with
>> it on my own.
>>  I had tried to use (==[]). I got the solution "False" by copying from
>> the internet.
>>  I would not have gotten the word "const" without cheating from the
>> internet. It is nowhere in Hutton's book up to this point.
>>
>> iterate :: (a > a) > a > [a]
>> iterate f = unfold (const False) id f
>>
>>  chop8 :: [Bit] > [[Bit]]
>>  chop8 [] = []
>>  chop8 bits = take 8 bits : chop8 (drop 8 bits)
>>
>>  Hutton, Graham. Programming in Haskell (Kindle Locations 26812683).
>> Cambridge University Press. Kindle Edition.
>>
>>  I attempted this first, and i pretty much got it on my own.
>>
>> chop8 :: [Bit] > [[Bit]]
>> chop8 bits = unfold (==[]) (take 8) (drop 8) bits
>>
>>
>> _______________________________________________
>> Beginners mailing list
>> Beginners at haskell.org
>> http://mail.haskell.org/cgibin/mailman/listinfo/beginners
>>
>>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgibin/mailman/listinfo/beginners
>
 next part 
An HTML attachment was scrubbed...
URL:
From jack.vice at gmail.com Thu Aug 23 10:26:05 2018
From: jack.vice at gmail.com (Jack Vice)
Date: Thu, 23 Aug 2018 06:26:05 0400
Subject: [Haskellbeginners] =?utf8?q?Runtime_error_=E2=80=9CCould_not_de?=
=?utf8?q?duce_=28Integral_Float=29_arising_from_a_use_of=2E=2E?=
=?utf8?b?4oCd?=
MessageID:
I am trying to calculate the standard deviation for each index in a list of
lists of floats. Using Ubuntu 18.04, ghc 8.0.2. I am getting the following
runtime error which I have googled and still don't understand what
"Integral Float" is exactly or even which parameter is causing the trouble.
*Main> let z = stdDev 0 2 y x
:250:9: error:
• Could not deduce (Integral Float) arising from a use of ‘stdDev’
from the context: Floating a
bound by the inferred type of z :: Floating a => [a]
at :250:538
• In the expression: stdDev 0 (length (head (x))) y x
In an equation for ‘z’: z = stdDev 0 (length (head (x))) y x
Code:
 i is start index, l is length of each list, ms is list of means,
 xs is Matrix
stdDev i l ms xs
 i < l = sqrt(fromIntegral(sumOfMinusMeans i (ms!!i) xs) /
fromIntegral(l)):(stdDev (i+1) l ms xs)
 otherwise = []
i is index, m is mean for the index
sumOfMinusMeans i m (x:xs)
 xs == [] = (x!!i  m)**2
 i < length x = (x!!i  m)**2 + (sumOfMinusMeans i m xs)
 otherwise = 0
Types:
*Main> :t stdDev
stdDev
:: (Floating a1, Floating a, Integral a1) =>
Int > Int > [a1] > [[a1]] > [a]
*Main> :t sumOfMinusMeans
sumOfMinusMeans :: (Eq t, Floating t) => Int > t > [[t]] > t
Variables:
*Main> y
[380.0,1.0]
*Main> x
[[600.0,1.0],[400.0,1.0],[170.0,1.0],[430.0,1.0],[300.0,1.0]]
 next part 
An HTML attachment was scrubbed...
URL:
From orclev at gmail.com Thu Aug 23 12:10:35 2018
From: orclev at gmail.com (Kyle Murphy)
Date: Thu, 23 Aug 2018 08:10:35 0400
Subject: [Haskellbeginners]
=?utf8?q?Runtime_error_=E2=80=9CCould_not_de?=
=?utf8?q?duce_=28Integral_Float=29_arising_from_a_use_of=2E=2E?=
=?utf8?b?4oCd?=
InReplyTo:
References:
MessageID:
GHC has deduced that the third and fourth arguments of stdDev must be
members of both the Floating and Integral classes based on the functions
used on them. GHC has also deduced that the types of y and x are [Float]
and [[Float]] respectively. The error is that GHC has no definition in
scope that would make Float a member of the Integral class.
How to fix this is a bit more than I can go into right now, but will likely
involve carefully converting from type to type at particular points in
stdDev. As a first step, it's always a good idea to explicitly tell GHC
what YOU think the types are for a function, and then let it tell you where
it disagrees.
On Thu, Aug 23, 2018, 6:26 AM Jack Vice wrote:
> I am trying to calculate the standard deviation for each index in a list
> of lists of floats. Using Ubuntu 18.04, ghc 8.0.2. I am getting the
> following runtime error which I have googled and still don't understand
> what "Integral Float" is exactly or even which parameter is causing the
> trouble.
>
> *Main> let z = stdDev 0 2 y x
> :250:9: error:
> • Could not deduce (Integral Float) arising from a use of ‘stdDev’
> from the context: Floating a
> bound by the inferred type of z :: Floating a => [a]
> at :250:538
> • In the expression: stdDev 0 (length (head (x))) y x
> In an equation for ‘z’: z = stdDev 0 (length (head (x))) y x
>
> Code:
>
>  i is start index, l is length of each list, ms is list of means,
>  xs is Matrix
> stdDev i l ms xs
>  i < l = sqrt(fromIntegral(sumOfMinusMeans i (ms!!i) xs) /
> fromIntegral(l)):(stdDev (i+1) l ms xs)
>  otherwise = []
>
> i is index, m is mean for the index
> sumOfMinusMeans i m (x:xs)
>  xs == [] = (x!!i  m)**2
>  i < length x = (x!!i  m)**2 + (sumOfMinusMeans i m xs)
>  otherwise = 0
>
> Types:
>
> *Main> :t stdDev
> stdDev
> :: (Floating a1, Floating a, Integral a1) =>
> Int > Int > [a1] > [[a1]] > [a]
>
> *Main> :t sumOfMinusMeans
> sumOfMinusMeans :: (Eq t, Floating t) => Int > t > [[t]] > t
>
> Variables:
>
> *Main> y
> [380.0,1.0]
> *Main> x
> [[600.0,1.0],[400.0,1.0],[170.0,1.0],[430.0,1.0],[300.0,1.0]]
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgibin/mailman/listinfo/beginners
>
 next part 
An HTML attachment was scrubbed...
URL:
From toad3k at gmail.com Thu Aug 23 12:35:26 2018
From: toad3k at gmail.com (David McBride)
Date: Thu, 23 Aug 2018 08:35:26 0400
Subject: [Haskellbeginners]
=?utf8?q?Runtime_error_=E2=80=9CCould_not_de?=
=?utf8?q?duce_=28Integral_Float=29_arising_from_a_use_of=2E=2E?=
=?utf8?b?4oCd?=
InReplyTo:
References:
MessageID:
Floating is the type class of types that are floating point. The two most
common instances are Float and Double. Integral is the class of integer
types. Most commonly Int and Integer.
stdDev
:: (Floating a1, Floating a, Integral a1) =>
When you see a type like that it means type a1 is both a Floating and also
an Integral. Intellectually that is impossible, but as far as ghc is
concerned there could be a type that is an instance of both classes, so it
allows it. But when you try to call it, there's no type in scope that you
can affix to a1 to please it, so it will always error.
The reason it has both Floating and Integral on the same type is that you
are using several functions on various arguments of your function that
imply that the types of those arguments must be instances of various
classes.
fromIntegral :: (Integral a, Num b) => a > b
sumOfMinusMeans :: (Eq t, Floating t) => Int > t > [[t]] > t
sqrt :: Floating a => a > a  (this function may not be a factor)
I strongly recommend you write out a type for stdDev, but fix a1 to a
concrete type and then ghc can tell you why that type won't work.
stdDev :: Int > Int > [Double] > [[Double]] > [Double]
• No instance for (Integral Double)
arising from a use of ‘fromIntegral’
stdDev :: Int > Int > [Integer] > [[Integer]] > [Double]
• No instance for (Floating Integer)
arising from a use of ‘sumOfMinusMeans’
And then think really hard about what types you want stdDev to accept.
Rework its the definition until the compiler is happy. I suspect it is an
extraneous fromIntegral.
On Thu, Aug 23, 2018 at 6:26 AM, Jack Vice wrote:
> I am trying to calculate the standard deviation for each index in a list
> of lists of floats. Using Ubuntu 18.04, ghc 8.0.2. I am getting the
> following runtime error which I have googled and still don't understand
> what "Integral Float" is exactly or even which parameter is causing the
> trouble.
>
> *Main> let z = stdDev 0 2 y x
> :250:9: error:
> • Could not deduce (Integral Float) arising from a use of ‘stdDev’
> from the context: Floating a
> bound by the inferred type of z :: Floating a => [a]
> at :250:538
> • In the expression: stdDev 0 (length (head (x))) y x
> In an equation for ‘z’: z = stdDev 0 (length (head (x))) y x
>
> Code:
>
>  i is start index, l is length of each list, ms is list of means,
>  xs is Matrix
> stdDev i l ms xs
>  i < l = sqrt(fromIntegral(sumOfMinusMeans i (ms!!i) xs) /
> fromIntegral(l)):(stdDev (i+1) l ms xs)
>  otherwise = []
>
> i is index, m is mean for the index
> sumOfMinusMeans i m (x:xs)
>  xs == [] = (x!!i  m)**2
>  i < length x = (x!!i  m)**2 + (sumOfMinusMeans i m xs)
>  otherwise = 0
>
> Types:
>
> *Main> :t stdDev
> stdDev
> :: (Floating a1, Floating a, Integral a1) =>
> Int > Int > [a1] > [[a1]] > [a]
>
> *Main> :t sumOfMinusMeans
> sumOfMinusMeans :: (Eq t, Floating t) => Int > t > [[t]] > t
>
> Variables:
>
> *Main> y
> [380.0,1.0]
> *Main> x
> [[600.0,1.0],[400.0,1.0],[170.0,1.0],[430.0,1.0],[300.0,1.0]]
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgibin/mailman/listinfo/beginners
>
>
 next part 
An HTML attachment was scrubbed...
URL:
From jack.vice at gmail.com Thu Aug 23 14:35:22 2018
From: jack.vice at gmail.com (Jack Vice)
Date: Thu, 23 Aug 2018 10:35:22 0400
Subject: [Haskellbeginners]
=?utf8?q?Runtime_error_=E2=80=9CCould_not_de?=
=?utf8?q?duce_=28Integral_Float=29_arising_from_a_use_of=2E=2E?=
=?utf8?b?4oCd?=
InReplyTo:
References:
MessageID:
David and Kyle, Thank you both. I declared the types and added a
'fromIntegral' and got things working!
On Thu, Aug 23, 2018 at 8:35 AM David McBride wrote:
> Floating is the type class of types that are floating point. The two most
> common instances are Float and Double. Integral is the class of integer
> types. Most commonly Int and Integer.
>
> stdDev
> :: (Floating a1, Floating a, Integral a1) =>
>
> When you see a type like that it means type a1 is both a Floating and also
> an Integral. Intellectually that is impossible, but as far as ghc is
> concerned there could be a type that is an instance of both classes, so it
> allows it. But when you try to call it, there's no type in scope that you
> can affix to a1 to please it, so it will always error.
>
> The reason it has both Floating and Integral on the same type is that you
> are using several functions on various arguments of your function that
> imply that the types of those arguments must be instances of various
> classes.
>
> fromIntegral :: (Integral a, Num b) => a > b
> sumOfMinusMeans :: (Eq t, Floating t) => Int > t > [[t]] > t
> sqrt :: Floating a => a > a  (this function may not be a factor)
>
> I strongly recommend you write out a type for stdDev, but fix a1 to a
> concrete type and then ghc can tell you why that type won't work.
> stdDev :: Int > Int > [Double] > [[Double]] > [Double]
>
> • No instance for (Integral Double)
> arising from a use of ‘fromIntegral’
>
> stdDev :: Int > Int > [Integer] > [[Integer]] > [Double]
>
> • No instance for (Floating Integer)
> arising from a use of ‘sumOfMinusMeans’
>
> And then think really hard about what types you want stdDev to accept.
> Rework its the definition until the compiler is happy. I suspect it is an
> extraneous fromIntegral.
>
> On Thu, Aug 23, 2018 at 6:26 AM, Jack Vice wrote:
>
>> I am trying to calculate the standard deviation for each index in a list
>> of lists of floats. Using Ubuntu 18.04, ghc 8.0.2. I am getting the
>> following runtime error which I have googled and still don't understand
>> what "Integral Float" is exactly or even which parameter is causing the
>> trouble.
>>
>> *Main> let z = stdDev 0 2 y x
>> :250:9: error:
>> • Could not deduce (Integral Float) arising from a use of ‘stdDev’
>> from the context: Floating a
>> bound by the inferred type of z :: Floating a => [a]
>> at :250:538
>> • In the expression: stdDev 0 (length (head (x))) y x
>> In an equation for ‘z’: z = stdDev 0 (length (head (x))) y x
>>
>> Code:
>>
>>  i is start index, l is length of each list, ms is list of means,
>>  xs is Matrix
>> stdDev i l ms xs
>>  i < l = sqrt(fromIntegral(sumOfMinusMeans i (ms!!i) xs) /
>> fromIntegral(l)):(stdDev (i+1) l ms xs)
>>  otherwise = []
>>
>> i is index, m is mean for the index
>> sumOfMinusMeans i m (x:xs)
>>  xs == [] = (x!!i  m)**2
>>  i < length x = (x!!i  m)**2 + (sumOfMinusMeans i m xs)
>>  otherwise = 0
>>
>> Types:
>>
>> *Main> :t stdDev
>> stdDev
>> :: (Floating a1, Floating a, Integral a1) =>
>> Int > Int > [a1] > [[a1]] > [a]
>>
>> *Main> :t sumOfMinusMeans
>> sumOfMinusMeans :: (Eq t, Floating t) => Int > t > [[t]] > t
>>
>> Variables:
>>
>> *Main> y
>> [380.0,1.0]
>> *Main> x
>> [[600.0,1.0],[400.0,1.0],[170.0,1.0],[430.0,1.0],[300.0,1.0]]
>>
>>
>> _______________________________________________
>> Beginners mailing list
>> Beginners at haskell.org
>> http://mail.haskell.org/cgibin/mailman/listinfo/beginners
>>
>>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgibin/mailman/listinfo/beginners
>
 next part 
An HTML attachment was scrubbed...
URL:
From trent.shipley at gmail.com Fri Aug 24 09:45:46 2018
From: trent.shipley at gmail.com (trent shipley)
Date: Fri, 24 Aug 2018 02:45:46 0700
Subject: [Haskellbeginners] Hutton ex 7.7 and 7.8
MessageID:
My attempt not only compiled, but seems to run OK. (Really, a just gave it
a couple of trivial tests, and said good enough. I didn't really mess with
corner cases like empty lists. It was late, and I didn't want to tempt
fate.)
THUS,
I am mostly looking for style feedback, although if there are any obvious
logic errors, I'd be "happy" to learn about those too.
{
7. Modify the binary string transmitter example to detect simple
transmission errors using the concept of parity bits. That is, each
eightbit binary number produced during encoding is extended with a parity
bit, set to one if the number contains an odd number of ones, and to zero
otherwise. In turn, each resulting ninebit binary number consumed during
decoding is checked to ensure that its parity bit is correct, with the
parity bit being discarded if this is the case, and a parity error being
reported otherwise. Hint: the library function error :: String > a
displays the given string as an error message and terminates the program;
the polymorphic result type ensures that error can be used in any context.
8. Test your new string transmitter program from the previous exercise
using a faulty communication channel that forgets the first bit, which can
be modelled using the tail function on lists of bits.
Hutton, Graham. Programming in Haskell (Kindle Locations 28422851).
Cambridge University Press. Kindle Edition.
}
import Data.Char
type Bit = Int
byte :: Int
byte = 8
parityByte :: Int
parityByte = 9
bin2int :: [Bit] > Int
bin2int = foldr (\x y > x + 2 * y) 0
 Hutton, Graham. Programming in Haskell (Kindle Locations 26472649).
Cambridge University Press. Kindle Edition.
int2bin :: Int > [Bit]
int2bin 0 = []
int2bin n = n `mod` 2 : int2bin (n `div` 2)
 Hutton, Graham. Programming in Haskell (Kindle Locations 26542656).
Cambridge University Press. Kindle Edition.
make8 :: [Bit] > [Bit]
make8 bits = addParity (take byte (bits ++ repeat 0))
 Parity functions
addParity :: [Bit] > [Bit]
addParity xs = if even (sum xs)
then xs ++ [0]
else xs ++ [1]
checkParity :: [Bit] > Bool
checkParity xs = (((even . sum) (take ((length xs)  1) xs)) ==
((even . last) xs)) 
(((odd . sum) (take ((length xs)  1) xs)) ==
((odd . last) xs))
errorParity :: [Bit] > ([Bit], Bool)
errorParity xs = if checkParity xs
then (xs, checkParity xs)
else error "Parity error"
dropParity :: [Bit] > [Bit]
dropParity xs = take ((length xs)  1) xs
 Hutton, Graham. Programming in Haskell (Kindle Locations 26622663).
Cambridge University Press. Kindle Edition.
 TRANSMISSION
encode :: String > [Bit]
encode = concat . map (make8 . int2bin . ord)
 Hutton, Graham. Programming in Haskell (Kindle Locations 26732675).
Cambridge University Press. Kindle Edition.
chop8 :: [Bit] > [[Bit]]
chop8 [] = []
chop8 bits = (dropParity . fst . errorParity) (take parityByte bits) :
chop8 (drop parityByte bits)
 Hutton, Graham. Programming in Haskell (Kindle Locations 26812683).
Cambridge University Press. Kindle Edition.
decode :: [Bit] > String
decode = map (chr . bin2int) . chop8
 Hutton, Graham. Programming in Haskell (Kindle Locations 26862688).
Cambridge University Press. Kindle Edition.
 channel :: [Bit] > [Bit]
 channel = id
channel :: [Bit] > [Bit]
channel = tail
 Hutton, Graham. Programming in Haskell (Kindle Locations 26962697).
Cambridge University Press. Kindle Edition.
transmit :: String > String
transmit = decode . channel . encode
 Hutton, Graham. Programming in Haskell (Kindle Locations 26942695).
Cambridge University Press. Kindle Edition.
 next part 
An HTML attachment was scrubbed...
URL:
From faml at ariis.it Fri Aug 24 10:00:27 2018
From: faml at ariis.it (Francesco Ariis)
Date: Fri, 24 Aug 2018 12:00:27 +0200
Subject: [Haskellbeginners] Hutton ex 7.7 and 7.8
InReplyTo:
References:
MessageID: <20180824100027.njrjma56ahrijjj6@x60s.casa>
Hello Trent,
On Fri, Aug 24, 2018 at 02:45:46AM 0700, trent shipley wrote:
> I am mostly looking for style feedback, although if there are any obvious
> logic errors, I'd be "happy" to learn about those too.
Running hlint is always useful. e.g. it will spot redundant brackets:
p.hs:35:40: Suggestion: Redundant bracket
Found:
(length xs)  1
Why not:
length xs  1
and unidiomatic expressions like
p.hs:54:10: Warning: Use concatMap
Found:
concat . map (make8 . int2bin . ord)
Why not:
concatMap (make8 . int2bin . ord)
From fraybauhaus at gmail.com Fri Aug 24 11:58:22 2018
From: fraybauhaus at gmail.com (Paum B.)
Date: Fri, 24 Aug 2018 13:58:22 +0200
Subject: [Haskellbeginners] send string to stack ghc
MessageID:
Hi List,
It is possibile to run:
stack ghc  interactive XOverloadedStrings
and then send to it strings (commands) externally?
Thanks
paum
 next part 
An HTML attachment was scrubbed...
URL:
From aquagnu at gmail.com Fri Aug 24 12:01:17 2018
From: aquagnu at gmail.com (Paul)
Date: Fri, 24 Aug 2018 15:01:17 +0300
Subject: [Haskellbeginners] send string to stack ghc
InReplyTo:
References:
MessageID: <4c7e5cd3b16750df71002089948f68f5@gmail.com>
Sure. I remember old days Tcl/Tk utility "expect" for such interactive
scripting sessions. Open a pipes and communicate with process :) Today
there are tools similar to "expect" for scripting command line utilities.
Also Emacs works with GHCi (interro) in such way. Also Dante IMHO.
Visual Studio Code Haskelly and Haskerro, etc..
24.08.2018 14:58, Paum B. wrote:
> Hi List,
>
> It is possibile to run:
>
> stack ghc  interactive XOverloadedStrings
>
> and then send to it strings (commands) externally?
> Thanks
>
> paum
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgibin/mailman/listinfo/beginners
 next part 
An HTML attachment was scrubbed...
URL:
From fraybauhaus at gmail.com Fri Aug 24 12:08:28 2018
From: fraybauhaus at gmail.com (Paum B.)
Date: Fri, 24 Aug 2018 14:08:28 +0200
Subject: [Haskellbeginners] send string to stack ghc
InReplyTo: <4c7e5cd3b16750df71002089948f68f5@gmail.com>
References:
<4c7e5cd3b16750df71002089948f68f5@gmail.com>
MessageID:
oh, thats good  thank you!
is there any example in bash?
thnx
On Fri, Aug 24, 2018 at 2:02 PM Paul wrote:
> Sure. I remember old days Tcl/Tk utility "expect" for such interactive
> scripting sessions. Open a pipes and communicate with process :) Today
> there are tools similar to "expect" for scripting command line utilities.
>
> Also Emacs works with GHCi (interro) in such way. Also Dante IMHO. Visual
> Studio Code Haskelly and Haskerro, etc..
>
>
>
> 24.08.2018 14:58, Paum B. wrote:
>
> Hi List,
>
> It is possibile to run:
>
> stack ghc  interactive XOverloadedStrings
>
> and then send to it strings (commands) externally?
> Thanks
>
> paum
>
>
> _______________________________________________
> Beginners mailing listBeginners at haskell.orghttp://mail.haskell.org/cgibin/mailman/listinfo/beginners
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgibin/mailman/listinfo/beginners
>
 next part 
An HTML attachment was scrubbed...
URL:
From fraybauhaus at gmail.com Fri Aug 24 12:21:41 2018
From: fraybauhaus at gmail.com (Paum B.)
Date: Fri, 24 Aug 2018 14:21:41 +0200
Subject: [Haskellbeginners] send string to stack ghc
InReplyTo:
References:
<4c7e5cd3b16750df71002089948f68f5@gmail.com>
MessageID:
Actually, I dont know if I have asked good question to what I need.
So, I would like to run the process:
stack ghc  interactive XOverloadedStrings
and then, somehow from 'outside' push string commands to it...
On Fri, Aug 24, 2018 at 2:08 PM Paum B. wrote:
> oh, thats good  thank you!
>
> is there any example in bash?
>
> thnx
>
> On Fri, Aug 24, 2018 at 2:02 PM Paul wrote:
>
>> Sure. I remember old days Tcl/Tk utility "expect" for such interactive
>> scripting sessions. Open a pipes and communicate with process :) Today
>> there are tools similar to "expect" for scripting command line utilities.
>>
>> Also Emacs works with GHCi (interro) in such way. Also Dante IMHO. Visual
>> Studio Code Haskelly and Haskerro, etc..
>>
>>
>>
>> 24.08.2018 14:58, Paum B. wrote:
>>
>> Hi List,
>>
>> It is possibile to run:
>>
>> stack ghc  interactive XOverloadedStrings
>>
>> and then send to it strings (commands) externally?
>> Thanks
>>
>> paum
>>
>>
>> _______________________________________________
>> Beginners mailing listBeginners at haskell.orghttp://mail.haskell.org/cgibin/mailman/listinfo/beginners
>>
>>
>> _______________________________________________
>> Beginners mailing list
>> Beginners at haskell.org
>> http://mail.haskell.org/cgibin/mailman/listinfo/beginners
>>
>
 next part 
An HTML attachment was scrubbed...
URL:
From toad3k at gmail.com Fri Aug 24 12:27:56 2018
From: toad3k at gmail.com (David McBride)
Date: Fri, 24 Aug 2018 08:27:56 0400
Subject: [Haskellbeginners] send string to stack ghc
InReplyTo:
References:
<4c7e5cd3b16750df71002089948f68f5@gmail.com>
MessageID:
You should be able to run something like this:
echo 'putStrLn "hi"'  stack exec  ghci XOverloadedStrings
On Fri, Aug 24, 2018 at 8:21 AM, Paum B. wrote:
> Actually, I dont know if I have asked good question to what I need.
> So, I would like to run the process:
>
> stack ghc  interactive XOverloadedStrings
>
> and then, somehow from 'outside' push string commands to it...
>
> On Fri, Aug 24, 2018 at 2:08 PM Paum B. wrote:
>
>> oh, thats good  thank you!
>>
>> is there any example in bash?
>>
>> thnx
>>
>> On Fri, Aug 24, 2018 at 2:02 PM Paul wrote:
>>
>>> Sure. I remember old days Tcl/Tk utility "expect" for such interactive
>>> scripting sessions. Open a pipes and communicate with process :) Today
>>> there are tools similar to "expect" for scripting command line utilities.
>>>
>>> Also Emacs works with GHCi (interro) in such way. Also Dante IMHO.
>>> Visual Studio Code Haskelly and Haskerro, etc..
>>>
>>>
>>>
>>> 24.08.2018 14:58, Paum B. wrote:
>>>
>>> Hi List,
>>>
>>> It is possibile to run:
>>>
>>> stack ghc  interactive XOverloadedStrings
>>>
>>> and then send to it strings (commands) externally?
>>> Thanks
>>>
>>> paum
>>>
>>>
>>> _______________________________________________
>>> Beginners mailing listBeginners at haskell.orghttp://mail.haskell.org/cgibin/mailman/listinfo/beginners
>>>
>>>
>>> _______________________________________________
>>> Beginners mailing list
>>> Beginners at haskell.org
>>> http://mail.haskell.org/cgibin/mailman/listinfo/beginners
>>>
>>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgibin/mailman/listinfo/beginners
>
>
 next part 
An HTML attachment was scrubbed...
URL:
From fraybauhaus at gmail.com Fri Aug 24 12:35:44 2018
From: fraybauhaus at gmail.com (Paum B.)
Date: Fri, 24 Aug 2018 14:35:44 +0200
Subject: [Haskellbeginners] send string to stack ghc
InReplyTo:
References:
<4c7e5cd3b16750df71002089948f68f5@gmail.com>
MessageID:
yes, nice.
but after the process is over. I need to hold it running (dtill the same
one) until command to end it.
again, thankx!
On Fri, Aug 24, 2018 at 2:28 PM David McBride wrote:
> You should be able to run something like this:
>
> echo 'putStrLn "hi"'  stack exec  ghci XOverloadedStrings
>
> On Fri, Aug 24, 2018 at 8:21 AM, Paum B. wrote:
>
>> Actually, I dont know if I have asked good question to what I need.
>> So, I would like to run the process:
>>
>> stack ghc  interactive XOverloadedStrings
>>
>> and then, somehow from 'outside' push string commands to it...
>>
>> On Fri, Aug 24, 2018 at 2:08 PM Paum B. wrote:
>>
>>> oh, thats good  thank you!
>>>
>>> is there any example in bash?
>>>
>>> thnx
>>>
>>> On Fri, Aug 24, 2018 at 2:02 PM Paul