Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Re: [Haskell-cafe] Mathematical functions with multiple
arguments (Sumit Sahrawat, Maths & Computing, IIT (BHU))
2. Re: [Haskell-cafe] Mathematical functions with multiple
arguments (Sumit Sahrawat, Maths & Computing, IIT (BHU))
3. Re: [Haskell-cafe] Mathematical functions with multiple
arguments (Konstantine Rybnikov)
4. Re: [Haskell-cafe] Mathematical functions with multiple
arguments (Sumit Sahrawat, Maths & Computing, IIT (BHU))
----------------------------------------------------------------------
Message: 1
Date: Thu, 12 Mar 2015 04:46:42 +0530
From: "Sumit Sahrawat, Maths & Computing, IIT (BHU)"
<[email protected]>
To: David Feuer <[email protected]>
Cc: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] [Haskell-cafe] Mathematical functions
with multiple arguments
Message-ID:
<cajbew8n9g6xf-p-mpsznnzcabxksifqmrbehm9wcawmoyrn...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
The fixed-vector package uses a similar technique. The only trouble I'm
having is with converting Vec v (Double, Double) to [(Double, Double)] for
further use. I don't want to change all the code, but only the part where
the user provides me with arguments.
I'll keep looking into it. Thanks for the help.
On 12 March 2015 at 04:44, David Feuer <[email protected]> wrote:
> There are a lot of ways to do this sort of thing, and which one you choose
> will depend on exactly what you're trying to do. For example, you can write
> something vaguely like
>
> data Nat = Z | S Nat
> data SL (n :: Nat) a where
> Nil :: SL Z
> Cons :: a -> SL n a -> SL (S n) a
>
> plot :: forall (n::Nat) . (SL n Double -> Double) ->
> SL n (Double, Double) -> IO ()
> On Mar 11, 2015 5:45 PM, "Sumit Sahrawat, Maths & Computing, IIT (BHU)" <
> [email protected]> wrote:
>
>> Hi everybody,
>>
>> I have a function of type
>>
>> plot :: ([Double] -> Double) -- A function to plot
>> -> [(Double, Double)] -- Range for all arguments
>> -> IO ()
>>
>> I want to enforce the fact that ranges for all arguments should be
>> provided.
>> Is there a way to make the type system enforce it?
>>
>> --
>> Regards
>>
>> Sumit Sahrawat
>>
>> _______________________________________________
>> Haskell-Cafe mailing list
>> [email protected]
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>>
>>
--
Regards
Sumit Sahrawat
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150312/48204b95/attachment-0001.html>
------------------------------
Message: 2
Date: Thu, 12 Mar 2015 05:49:25 +0530
From: "Sumit Sahrawat, Maths & Computing, IIT (BHU)"
<[email protected]>
To: David Feuer <[email protected]>
Cc: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] [Haskell-cafe] Mathematical functions
with multiple arguments
Message-ID:
<cajbew8mbzftm0oaqkp_euh_ofsijb11co3zjh+mphzwarxk...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
It's done. fixed-vector provides many implementations for Vec. The one I
was using (Primitive) requires primitive constraint on data types. I
shifted to Unboxed ones, and now it's working.
This means that I am able to use toList with Vec v (Double, Double), which
was previously complaining of missing constraints.
Also, I'll slowly convert the whole thing. I wanted to just see if it works
initially.
Thanks, once again.
On 12 March 2015 at 04:58, David Feuer <[email protected]> wrote:
> I'd urge you to *try* to maintain that safety throughout, but you can try
> something like this if necessary (I'm not at my computer, so I can't test
> it):
>
> {-#LANGUAGE FlexibleContexts, FlexibleInstances #-}
> instance Foldable (SL Z) where
> foldr _ n Nil = n
>
> instance Foldable (SL n) => Foldable (SL (S n)) where
> foldr c n (Cons x xs) = c x (foldr c n xs)
>
> In fact, I would expect whatever package you're looking at to offer this.
> Then you can just use Data.Foldable.toList.
> On Mar 11, 2015 7:16 PM, "Sumit Sahrawat, Maths & Computing, IIT (BHU)" <
> [email protected]> wrote:
>
>> The fixed-vector package uses a similar technique. The only trouble I'm
>> having is with converting Vec v (Double, Double) to [(Double, Double)] for
>> further use. I don't want to change all the code, but only the part where
>> the user provides me with arguments.
>>
>> I'll keep looking into it. Thanks for the help.
>>
>> On 12 March 2015 at 04:44, David Feuer <[email protected]> wrote:
>>
>>> There are a lot of ways to do this sort of thing, and which one you
>>> choose will depend on exactly what you're trying to do. For example, you
>>> can write something vaguely like
>>>
>>> data Nat = Z | S Nat
>>> data SL (n :: Nat) a where
>>> Nil :: SL Z
>>> Cons :: a -> SL n a -> SL (S n) a
>>>
>>> plot :: forall (n::Nat) . (SL n Double -> Double) ->
>>> SL n (Double, Double) -> IO ()
>>> On Mar 11, 2015 5:45 PM, "Sumit Sahrawat, Maths & Computing, IIT (BHU)" <
>>> [email protected]> wrote:
>>>
>>>> Hi everybody,
>>>>
>>>> I have a function of type
>>>>
>>>> plot :: ([Double] -> Double) -- A function to plot
>>>> -> [(Double, Double)] -- Range for all arguments
>>>> -> IO ()
>>>>
>>>> I want to enforce the fact that ranges for all arguments should be
>>>> provided.
>>>> Is there a way to make the type system enforce it?
>>>>
>>>> --
>>>> Regards
>>>>
>>>> Sumit Sahrawat
>>>>
>>>> _______________________________________________
>>>> Haskell-Cafe mailing list
>>>> [email protected]
>>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>>>>
>>>>
>>
>>
>> --
>> Regards
>>
>> Sumit Sahrawat
>>
>
--
Regards
Sumit Sahrawat
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150312/f3c51926/attachment-0001.html>
------------------------------
Message: 3
Date: Thu, 12 Mar 2015 09:05:05 +0200
From: Konstantine Rybnikov <[email protected]>
To: [email protected], The Haskell-Beginners Mailing
List - Discussion of primarily beginner-level topics related to
Haskell <[email protected]>
Cc: David Feuer <[email protected]>
Subject: Re: [Haskell-beginners] [Haskell-cafe] Mathematical functions
with multiple arguments
Message-ID:
<caabahfsacap7cr7vayo-ohqry_f5hakk6anrpof4gmrtqwi...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Is `Data.Vector.Fixed.toList` is what you're looking for?
On Thu, Mar 12, 2015 at 1:16 AM, Sumit Sahrawat, Maths & Computing, IIT
(BHU) <[email protected]> wrote:
> The fixed-vector package uses a similar technique. The only trouble I'm
> having is with converting Vec v (Double, Double) to [(Double, Double)] for
> further use. I don't want to change all the code, but only the part where
> the user provides me with arguments.
>
> I'll keep looking into it. Thanks for the help.
>
> On 12 March 2015 at 04:44, David Feuer <[email protected]> wrote:
>
>> There are a lot of ways to do this sort of thing, and which one you
>> choose will depend on exactly what you're trying to do. For example, you
>> can write something vaguely like
>>
>> data Nat = Z | S Nat
>> data SL (n :: Nat) a where
>> Nil :: SL Z
>> Cons :: a -> SL n a -> SL (S n) a
>>
>> plot :: forall (n::Nat) . (SL n Double -> Double) ->
>> SL n (Double, Double) -> IO ()
>> On Mar 11, 2015 5:45 PM, "Sumit Sahrawat, Maths & Computing, IIT (BHU)" <
>> [email protected]> wrote:
>>
>>> Hi everybody,
>>>
>>> I have a function of type
>>>
>>> plot :: ([Double] -> Double) -- A function to plot
>>> -> [(Double, Double)] -- Range for all arguments
>>> -> IO ()
>>>
>>> I want to enforce the fact that ranges for all arguments should be
>>> provided.
>>> Is there a way to make the type system enforce it?
>>>
>>> --
>>> Regards
>>>
>>> Sumit Sahrawat
>>>
>>> _______________________________________________
>>> Haskell-Cafe mailing list
>>> [email protected]
>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>>>
>>>
>
>
> --
> Regards
>
> Sumit Sahrawat
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150312/4fb956dc/attachment-0001.html>
------------------------------
Message: 4
Date: Thu, 12 Mar 2015 14:12:29 +0530
From: "Sumit Sahrawat, Maths & Computing, IIT (BHU)"
<[email protected]>
To: Konstantine Rybnikov <[email protected]>
Cc: David Feuer <[email protected]>, The Haskell-Beginners Mailing
List - Discussion of primarily beginner-level topics related to
Haskell <[email protected]>
Subject: Re: [Haskell-beginners] [Haskell-cafe] Mathematical functions
with multiple arguments
Message-ID:
<CAJbEW8MXuJXUPc=fT_mr0H9ak6Zhm5fzH7Z0i8LufPjACQ=o...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Yeah, Data.Vector.Fixed.toList worked. I had found it previously, but it
didn't work for Vec imported from Data.Fixed.Vector.Primitive (as (Double,
Double) doesn't have a Prim instance).
Then I had to switch to Data.Fixed.Vector.Unboxed, and it works now.
Also, those shingles look interesting too. Thanks everybody.
On 12 March 2015 at 12:35, Konstantine Rybnikov <[email protected]> wrote:
> Is `Data.Vector.Fixed.toList` is what you're looking for?
>
> On Thu, Mar 12, 2015 at 1:16 AM, Sumit Sahrawat, Maths & Computing, IIT
> (BHU) <[email protected]> wrote:
>
>> The fixed-vector package uses a similar technique. The only trouble I'm
>> having is with converting Vec v (Double, Double) to [(Double, Double)] for
>> further use. I don't want to change all the code, but only the part where
>> the user provides me with arguments.
>>
>> I'll keep looking into it. Thanks for the help.
>>
>> On 12 March 2015 at 04:44, David Feuer <[email protected]> wrote:
>>
>>> There are a lot of ways to do this sort of thing, and which one you
>>> choose will depend on exactly what you're trying to do. For example, you
>>> can write something vaguely like
>>>
>>> data Nat = Z | S Nat
>>> data SL (n :: Nat) a where
>>> Nil :: SL Z
>>> Cons :: a -> SL n a -> SL (S n) a
>>>
>>> plot :: forall (n::Nat) . (SL n Double -> Double) ->
>>> SL n (Double, Double) -> IO ()
>>> On Mar 11, 2015 5:45 PM, "Sumit Sahrawat, Maths & Computing, IIT (BHU)" <
>>> [email protected]> wrote:
>>>
>>>> Hi everybody,
>>>>
>>>> I have a function of type
>>>>
>>>> plot :: ([Double] -> Double) -- A function to plot
>>>> -> [(Double, Double)] -- Range for all arguments
>>>> -> IO ()
>>>>
>>>> I want to enforce the fact that ranges for all arguments should be
>>>> provided.
>>>> Is there a way to make the type system enforce it?
>>>>
>>>> --
>>>> Regards
>>>>
>>>> Sumit Sahrawat
>>>>
>>>> _______________________________________________
>>>> Haskell-Cafe mailing list
>>>> [email protected]
>>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>>>>
>>>>
>>
>>
>> --
>> Regards
>>
>> Sumit Sahrawat
>>
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>>
>>
>
--
Regards
Sumit Sahrawat
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150312/b0bf9761/attachment.html>
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 81, Issue 38
*****************************************