Re: [elm-discuss] Support for binary data

2017-07-18 Thread Zachary Kessin
I would really like to have a way to do file uploads in Elm, I needed that
at a project a while back

Zach
ᐧ

On Wed, Jul 12, 2017 at 8:18 PM, Coury Ditch  wrote:

> Here are a couple relevant repos so far - they are mostly barren at the
> moment, as we're trying to solve some hard API problems before we put too
> much code down.
>
> https://github.com/cmditch/elm-web3
> https://github.com/cmditch/elm-truffle-webpack
>
>
> On Sunday, July 9, 2017 at 9:49:46 AM UTC-6, Berry Groenendijk wrote:
>>
>> Coury,
>>
>> I am very interested in an Elm version of web3.js. For exactly the reason
>> you mentioned. Where can I follow the progress on this project?
>>
>> Berry
>>
>> Op zaterdag 8 juli 2017 21:30:53 UTC+2 schreef Coury Ditch:
>>>
>>> Our use case: Pure elm library for cryptographic functions.
>>>
>>> We are creating a pure Elm web3.js equivalent. We think Ethereum
>>> developers and the blockchain developer community at large would benefit
>>> from the strong guarantees of using Elm.
>>>
>>> Thanks
>>>
>>> On Monday, January 11, 2016 at 5:32:43 PM UTC-7, Evan wrote:

 I have been drafting Blob and ArrayBuffer APIs, but I wasn't sure who
 needed them.

 What is your particular use case?

 On Mon, Jan 11, 2016 at 4:55 AM, John Watson 
 wrote:

> Can anyone tell me what the plans are for supporting binary data in
> elm?  I'm thinking of a Byte (and some sort of Byte Array) type and also
> implementing Blob in HTTP responses.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to elm-discuss...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

 --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Zach Kessin
Teaching Web Developers to test code to find more bugs in less time
Skype: zachkessin
+972 54 234 3956 / +44 203 734 9790 / +1 617 778 7213

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] ADT: How to know whether two values have the same constructor?

2017-07-18 Thread Ian Mackenzie
I think I would opt for the very literal

type Bla
= A Int
| B Int


type BlaConstructor
= AConstructor
| BConstructor


blaConstructor : Bla -> BlaConstructor
blaConstructor bla =
case bla of
A _ ->
AConstructor

B _ ->
BConstructor


haveSameConstructor : Bla -> Bla -> Bool
haveSameConstructor firstBla secondBla =
blaConstructor firstBla == blaConstructor secondBla

The compiler will remind you to add a new case to the blaConstructor function 
when you add a new Bla constructor, and that in turn will prompt you to add 
a case to the BlaConstructor type - no tricky tuple matching required. I'm 
also guessing you can come up with a more meaningful name than 
'constructor' (perhaps 'kind' or something) that better indicates what it 
actually means for an object to have a particular constructor.

On Monday, 17 July 2017 13:22:56 UTC-4, David Andrews wrote:
>
> Similar code, with new cases enforced by the compiler
>
> haveSameConstructor : Bla -> Bla -> Bool
> haveSameConstructor first second =
> case (first, second) of
> (A _, A _) -> True
> (B _, B _) -> True
> (A _, _) -> False
> (B _, _) -> False
>
> On Jul 17, 2017 3:34 AM, "Birowsky" > 
> wrote:
>
>> That's not so bad. But the compiler wouldn't be able to nudge me to add a 
>> new comparison when I add a new constructor in the Bla union.
>>
>> Thanx anyways.
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Elm Discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to elm-discuss...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] ADT: How to know whether two values have the same constructor?

2017-07-18 Thread Peter Damoc
In theory you could use the inspection offered by toString:

sameConstructor : a -> a -> Bool
sameConstructor first second =
case ( String.words (toString first), String.words (toString second) )
of
( a :: _, b :: _ ) ->
a == b

_ ->
False


That being said, this might not be a good strategy for the future.
I've heard a rumor that toString might move to Debug and its use be
discouraged in production code.





On Mon, Jul 17, 2017 at 1:33 AM, Birowsky  wrote:

> Given:
>
> type Bla = A Int | B Int
> valA1 = A 1
> valA2 = A 2
>
>
> Is there a way for me to check whether `valA1` has been constructed with
> the constructor of `valA2`?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] ADT: How to know whether two values have the same constructor?

2017-07-18 Thread Birowsky
Petre, give it to me straight. Is the potential deprecation of toString the 
only drawback to this approach? We need to be pragmatic here :}



-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] ADT: How to know whether two values have the same constructor?

2017-07-18 Thread Peter Damoc
I cannot think of any other drawback right now.

Maybe with more information about the context where this is needed a better
option can be found.

I'm actually curious what is the use case that prompted this request as it
has a very XYproblem feel to it.




On Tue, Jul 18, 2017 at 9:03 PM, Birowsky  wrote:

> Petre, give it to me straight. Is the potential deprecation of toString
> the only drawback to this approach? We need to be pragmatic here :}
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] ADT: How to know whether two values have the same constructor?

2017-07-18 Thread Birowsky
I agree. Here it goes:


type Route 
  = Route1 SubRoute1
  | Route2 SubRoute2


Routes are coming into the app. I want to detect when the base route 
changes. Example, from Route1_, to Route2 _.

(This is part of solution to a challenge where I need to keep the scroll 
position of a list view upon a navigation to one of it's list items, so 
that when the user goes back, he's faced with the same scroll position. The 
approach that I'm taking is by not destroying the list view in the first 
place. Problem there is that there might happen a buildup of multiple list 
views causing memory pressure, so we still need to decide when is a good 
time to destroy the list view. The way I rationalize: if after the list 
item navigation, the user makes another base navigation, he doesn't care 
about the scroll position of the list view. Ergo,  I want to detect when 
the base route changes. You can check out this behavior in the list views 
in Dscova . I took a different 
approach where I'm tracking the routes history.)

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Support for binary data

2017-07-18 Thread Martin Bailey
What kind of interaction with binary data would you require for your 
projects?

-Blob : black box to store and pass opaque data around (anything that isn't 
a valid Unicode string)
-Byte array : equivalent to char/string for arbitrary bytes
-Bit stream : more flexible mechanism to implement binary protocols or 
binary coding

Byte array would remove the need for blobs and would also allow building a 
clean bitstream library in pure Elm. It needs to be designed properly for 
binary data to be reliable and fun to work with, but that would probably be 
the best abstraction. Haskell calls theirs Data.ByteString.

On Tuesday, July 18, 2017 at 3:10:33 AM UTC-4, Zachary Kessin wrote:
>
> I would really like to have a way to do file uploads in Elm, I needed that 
> at a project a while back
>
> Zach
> ᐧ
>
> On Wed, Jul 12, 2017 at 8:18 PM, Coury Ditch  > wrote:
>
>> Here are a couple relevant repos so far - they are mostly barren at the 
>> moment, as we're trying to solve some hard API problems before we put too 
>> much code down.
>>
>> https://github.com/cmditch/elm-web3
>> https://github.com/cmditch/elm-truffle-webpack
>>
>>
>> On Sunday, July 9, 2017 at 9:49:46 AM UTC-6, Berry Groenendijk wrote:
>>>
>>> Coury,
>>>
>>> I am very interested in an Elm version of web3.js. For exactly the 
>>> reason you mentioned. Where can I follow the progress on this project?
>>>
>>> Berry
>>>
>>> Op zaterdag 8 juli 2017 21:30:53 UTC+2 schreef Coury Ditch:

 Our use case: Pure elm library for cryptographic functions. 

 We are creating a pure Elm web3.js equivalent. We think Ethereum 
 developers and the blockchain developer community at large would benefit 
 from the strong guarantees of using Elm.

 Thanks

 On Monday, January 11, 2016 at 5:32:43 PM UTC-7, Evan wrote:
>
> I have been drafting Blob and ArrayBuffer APIs, but I wasn't sure who 
> needed them.
>
> What is your particular use case?
>
> On Mon, Jan 11, 2016 at 4:55 AM, John Watson  
> wrote:
>
>> Can anyone tell me what the plans are for supporting binary data in 
>> elm?  I'm thinking of a Byte (and some sort of Byte Array) type and also 
>> implementing Blob in HTTP responses. 
>>
>> -- 
>> You received this message because you are subscribed to the Google 
>> Groups "Elm Discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, 
>> send an email to elm-discuss...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Elm Discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to elm-discuss...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Zach Kessin
> Teaching Web Developers to test code to find more bugs in less time
> Skype: zachkessin
> +972 54 234 3956 / +44 203 734 9790 / +1 617 778 7213
>
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.