workspace
stringclasses 4
values | channel
stringclasses 4
values | text
stringlengths 1
3.93k
| ts
stringlengths 26
26
| user
stringlengths 2
11
|
---|---|---|---|---|
elmlang | general | <https://package.elm-lang.org/packages/elm/html/latest/Html-Events#onMouseUp> | 2019-01-12T06:56:19.213500 | Yang |
elmlang | general | is this working just on the element like this: | 2019-01-12T06:56:27.213800 | Yang |
elmlang | general | <https://www.w3schools.com/jsref/event_onmouseup.asp> | 2019-01-12T06:56:33.214000 | Yang |
elmlang | general | or is binded to window? | 2019-01-12T06:56:40.214300 | Yang |
elmlang | general | is for a drag and drop functionality | 2019-01-12T06:56:52.214500 | Yang |
elmlang | general | and i need to catch a mouse up anywere on the screen | 2019-01-12T06:57:03.214900 | Yang |
elmlang | general | any insight ? thansk :slightly_smiling_face: | 2019-01-12T06:57:37.215300 | Yang |
elmlang | general | `Browser.Events.onMouseUp` is definitely what you are after | 2019-01-12T06:58:58.215700 | Lynne |
elmlang | general | perfect, thanks :smile: :hugging_face: | 2019-01-12T07:02:23.216000 | Yang |
elmlang | general | Not surprisingly it was my fault :slightly_smiling_face: | 2019-01-12T08:18:46.216100 | Pauletta |
elmlang | general | For which company do you work <@Rosa>? | 2019-01-12T10:11:32.216300 | Allyn |
elmlang | general | is there an elm implementation of elm-format? Looks like not... | 2019-01-12T12:00:05.217400 | Earnestine |
elmlang | general | It is written in Haskell | 2019-01-12T12:56:28.217700 | Lynne |
elmlang | general | Hello, unfortunaltely, nobody answered in the beginners channel, so I'll try to ask here. Does anybody know export/import debug history working in 0.19 or not? I'm getting 'Looks like this history file is corrupt. I cannot understand it.' when I try to import my exported history. | 2019-01-12T13:03:35.218500 | Geralyn |
elmlang | general | It wasn't working when 0.19 was released, and there have been no patches since. | 2019-01-12T13:28:13.218900 | Elyse |
elmlang | general | Ok./ thank you | 2019-01-12T13:35:13.219100 | Geralyn |
elmlang | general | re-export of types works (via a type alias), re-export of their constructors does not work... right? or do I miss something? | 2019-01-12T15:49:19.220200 | Earnestine |
elmlang | general | That is correct | 2019-01-12T16:11:49.220600 | Bert |
elmlang | general | alright, thx! | 2019-01-12T16:18:46.220900 | Earnestine |
elmlang | general | Hello! I am building a little app that visualizes common list transformations like map, filter, and fold/reduce.
<https://github.com/tmikeschu/see-fp>
I am trying to figure out how to model the different functions that could be passed to, for example, a map function.
I started off with mapping `increment` over a list of numbers, but I want to add `isEven` to the mix now, and all of my `Int -> Int` signatures need to become more flexible obviously.
At a high level, I want to have some signature like
```
transform : a -> Operation (a -> b) -> b
```
I think my main challenge is figuring out how to model `Operation`. I feel like it should be something like:
```
type Operation
= Increment (Int -> Int)
| Decrement (Int -> Int)
| IsEven (Int -> Bool)
```
But I’d love to get some advice about modeling this in a flexible way.
Thanks! | 2019-01-12T18:03:04.226400 | Forrest |
elmlang | general | Cool project! :slightly_smiling_face: I am wondering why for example `Increment` carries a function around with it. Isn’t there only one possible implementation for that anyway? It feels to me that the actual function should not be part of the `Operation` type.
I think the core issue is the fact that your functions can be any unary function which makes it very hard to model in a custom type. It could be that it is impossible to model this generically in Elm.
`transform` is basically `|>`, which in turn is just function application. With that in mind, I am wondering if an operation type is necessary at all, they are just functions.
This is just me rambling, but maybe there is something useful in there somewhere. Also: _“Not Penny’s Boat_“ :wink: | 2019-01-12T18:12:07.226700 | Timika |
elmlang | general | <@Forrest> Do you mean something like this?
```
type Transformation a b
= Mapable (a -> b)
| Filterable (a -> Maybe b)
| Accumulatation b (a -> b -> b)
increment : Transformation Int Int
increment = Mapable (\x -> x + 1)
``` | 2019-01-12T18:19:24.230200 | Earnest |
elmlang | general | Not quite sure what your end goal is though. Do you just want a type for users to select different map actions? | 2019-01-12T18:25:30.231800 | Earnest |
elmlang | general | I understood it as the desire to put all operations into one `List` any be able to apply them somehow generically. Could be wrong though. | 2019-01-12T18:26:30.233500 | Timika |
elmlang | general | <@Forrest> You figure out what you needed? | 2019-01-12T20:31:56.234100 | Earnest |
elmlang | general | Yeah that actually makes a lot of sense!
The whole time I’ve felt weird about trying to model the core of lambda calc as a type haha. It’s great to hear another voice say that’s overkill.
The high level is to try to represent the model in a generic way. Given that I’ll have a variety of input and output types, do you see a way that doesn’t involve separate list types on the model for each output type? | 2019-01-12T23:34:34.238800 | Forrest |
elmlang | general | Thanks for the feedback! <@Timika> picked up what I was putting down. I’m going for representing the selected list and function, whether a -> Bool, a -> b, or other, as generically as possible.
So whether a user picks filter names by length or map cats to humans, the model and updates would be similar if not the same. | 2019-01-12T23:39:31.242700 | Forrest |
elmlang | general | does anyone have a good (and up-to-date) example of url routing in an elm program? basically, what would normally go in the *Synthesis* section of <https://guide.elm-lang.org/webapps/url_parsing.html> | 2019-01-13T00:44:37.243600 | Dee |
elmlang | general | currently mulling questions like, should i have separate entries for the current route AND possible data extracted from said route in my model record | 2019-01-13T00:45:57.244900 | Dee |
elmlang | general | These kind of decisions tend to be application specific. But always try to only store a value once. | 2019-01-13T02:20:15.245300 | Earlean |
elmlang | general | I thought about this and I think there is a solution from a different angle. If all your types are finite you could make a custom type that wraps all possible types in your app. ‘type SeeFpType = IntValue Int | CatValue Cat | ...’. Your functions can then be functions from SeeFpType to SeeFpType. It makes implementation of those functions more complicated as you have to check within those functions if you got the correct input type and handle mismatchs yourself.
But it would allow you to have a List of all functions, because their types are the same. Maybe it’s a route you can go? | 2019-01-13T04:54:32.252200 | Timika |
elmlang | general | Custom types suit well to store both route and data. Given examples from the section "Examples 3" on the page you mentioned the simplest example could be:
```
type Route
= ElmBasics
| ElmMaybe
| ElmList (Maybe String)
```
If you'd want go wilder you could replace `Maybe String` with another type denoting concrete place on the page to show when it is loaded.
It allows to store route and relevant data in single place making your `update` less error-prone, your model thinner, and `view` easier to judge on. And you also get a feature of making impossible state irrepresentable in contrast to separate entries in your model record. | 2019-01-13T05:07:43.252400 | Lynne |
elmlang | general | how to achive a mouseHover text underline in elm-ui?
i have: `mouseOver [ Font.underline ]`
but it doesnt compile
since Font.underline is not a Decoration
<https://package.elm-lang.org/packages/mdgriffith/elm-ui/latest/Element#mouseOver>
<https://package.elm-lang.org/packages/mdgriffith/elm-ui/latest/Element-Font#underline>
how to combine this 2?
thanks ::D | 2019-01-13T09:42:27.253100 | Yang |
elmlang | general | <@Yang> You will probably get more help if you ask in <#C4F9NBLR1|elm-ui> | 2019-01-13T09:46:20.253500 | Lynne |
elmlang | general | already did that thanks, nowbody is around there for now.. though i have more luck here. | 2019-01-13T09:46:48.254100 | Yang |
elmlang | general | same for Font.bold | 2019-01-13T09:46:55.254300 | Yang |
elmlang | general | i want the font to be bold under mouse hover. | 2019-01-13T09:47:07.254700 | Yang |
elmlang | general | Anybody know the date for US elm-conf 2019? Will it be in St. Louis again? | 2019-01-13T12:37:09.256100 | Deann |
elmlang | general | Historically it's always been a pre-conf event that's connected with StrangeLoop | 2019-01-13T12:38:53.257100 | Carman |
elmlang | general | Based on their website, StrangeLoop will occur September 12-14 this year in St. Louis | 2019-01-13T12:39:24.257700 | Carman |
elmlang | general | So going by previous years I'd guess that elm-conf would happen on ~September 11~ | 2019-01-13T12:39:50.258300 | Carman |
elmlang | general | just checked the fine print on <https://www.thestrangeloop.com/>, pre-conf events occur on Sept 12 :slightly_smiling_face: | 2019-01-13T12:40:44.259200 | Carman |
elmlang | general | Hey peeps, could someone help me get my head around opaque types and extensible records. I have the following types:
```
type alias Node a =
{ a | connections : List Connection, id : NodeID, type_ : NodeType }
type alias OscillatorNode
= Node { detune : Float, frequency : Float, waveform : Waveform }
```
and this function:
```
connect : Node a -> String -> Node b -> Connection
connect a dest b =
( a.id, b.id, dest )
```
This is all fine and dandy but I'd like both Node and OscillatorNode to be opaque types as I don't want anyone creating Nodes directly and I already supply a creator function for oscillators. I think I'm just being silly but how do I access the `id` field when the type is opaque? | 2019-01-13T12:50:05.262300 | Danika |
elmlang | general | a pattern match. so
```
case node of
{ id } -> ...
``` | 2019-01-13T12:51:03.262600 | Virgie |
elmlang | general | that would be `Node { id }` if it's wrapped | 2019-01-13T12:51:45.263100 | Virgie |
elmlang | general | Oh really? OK cheers, I'll give that a go. | 2019-01-13T12:52:28.263500 | Danika |
elmlang | general | Looking at your example, the extensible record + `type_` field is a bit of a smell pointing out that a custom type may be a better modeling of your domain. | 2019-01-13T12:57:05.266700 | Carman |
elmlang | general | For example something like:
```
type Node
= OscillatorNode { connections : List Connection, id : NodeId, detune : Float, frequency : Float, waveform : Float }
| OtherTypeOfNode ...
| ...
``` | 2019-01-13T12:57:07.266900 | Carman |
elmlang | general | This allows you to have different node types, keep your type opaque, and vary the fields present on each node type | 2019-01-13T12:57:46.268100 | Carman |
elmlang | general | To make this nicer to use, you may want to alias the record that gets wrapped | 2019-01-13T12:58:11.268800 | Carman |
elmlang | general | Yes I was considering doing something like that. It seemed redundant when all nodes share some common fields, and (I think) allowed for user-defined nodes | 2019-01-13T12:58:35.269100 | Danika |
elmlang | general | I think I probably agree on `type_` being less than ideal (and probably makes my whole "user defined nodes" thing break...) | 2019-01-13T12:59:30.270200 | Danika |
elmlang | general | Using a type like that also means I have to `case` over all the options and perform the exact same operation when I want to have generic `Node` functions, no? | 2019-01-13T13:00:31.271400 | Danika |
elmlang | general | correct | 2019-01-13T13:00:51.271800 | Carman |
elmlang | general | A variation that extracts the common fields could look like this:
```
type Node = Node { connections: List Connection, id : NodeId, details : NodeDetails }
type NodeDetails
= OscillatorDetails { detune : Float, frequency : Float, waveform : Float }
| OtherDetails { .. }
| ...
``` | 2019-01-13T13:01:49.272900 | Carman |
elmlang | general | Hmm looks like I have some options to consider | 2019-01-13T13:04:07.273400 | Danika |
elmlang | general | In my experience, you're better off trying to compose data than trying to fake an inheritance hierarchy via extensible records :slightly_smiling_face: | 2019-01-13T13:05:24.274200 | Carman |
elmlang | general | for some extra context:
```
createOscillatorNode : NodeID -> OscillatorNode
createOscillatorNode id = {
connections = [],
id = id,
type_ = Oscillator,
detune = 0.0,
frequency = 440.0,
waveform = Sine
}
setDetune : Float -> OscillatorNode -> OscillatorNode
setDetune val osc =
{ osc | detune = val }
setFrequency ...
```
which as it stands means I can create oscillator nodes:
```
createOscillatorNode (stringToNodeID "myOsc")
|> setFrequency 220.0
|> ...
``` | 2019-01-13T13:07:20.275600 | Danika |
elmlang | general | I'd like to preserve this | 2019-01-13T13:07:28.275800 | Danika |
elmlang | general | And I think that also breaks down if I use some sort of Node union type | 2019-01-13T13:07:49.276100 | Danika |
elmlang | general | I don't really feel like I'm trying (nor do i want) to hack some sort of OOP solution. But it does strongly seem like an extensible record is the appropriate thing for the `Node` :thinking_face: I shall do some more thinkign with your suggestions in mind | 2019-01-13T13:12:16.277900 | Danika |
elmlang | general | Do you have any functions that are generic to any kind of node? | 2019-01-13T13:13:01.278200 | Carman |
elmlang | general | because if you don't you could just have a bunch of concrete record aliases | 2019-01-13T13:13:35.278900 | Carman |
elmlang | general | `connect` connects two generic nodes together | 2019-01-13T13:13:40.279000 | Danika |
elmlang | general | I think I came up with a solution | 2019-01-13T13:41:14.280700 | Danika |
elmlang | general | Interesting! Thank you. I’ll give that a look!
I’ll let you know if I find any other solutions. Thanks! | 2019-01-13T14:10:49.283700 | Forrest |
elmlang | general | Does there exist something like json decode pipeline but for `elm/bytes`? | 2019-01-13T16:34:18.284800 | Jae |
elmlang | general | you can define the `andMap` function (see <https://github.com/folkertdev/elm-cff/blob/master/src/Decode/Extra.elm#L33>) and then use that to make pipelines (like here <https://github.com/folkertdev/elm-cff/blob/master/src/CompactFontFormat.elm#L72>) | 2019-01-13T18:17:09.284900 | Virgie |
elmlang | general | Does anyone do an ELM debugging service | 2019-01-13T20:04:55.285400 | Grisel |
elmlang | general | Can pay Bitcoin Cash. | 2019-01-13T20:05:05.285700 | Grisel |
elmlang | general | My implementation of SVG is broken… don’t see why | 2019-01-13T20:05:23.286100 | Grisel |
elmlang | general | Hi folks, I got `String.fromFloat (4.1 - 1)` as `"3.0999999999999996"`, how can I got `"3.1"` as expected? | 2019-01-14T02:29:28.287500 | Raymonde |
elmlang | general | This is not trivial. Basically you need a function rounding to N digits after comma (in your case 1 digit). | 2019-01-14T02:45:49.289200 | Lynne |
elmlang | general | This is an example: `String.fromFloat <| (toFloat <| ceiling ((4.1 - 1) * 10.0)) / 10.0` | 2019-01-14T02:45:56.289400 | Lynne |
elmlang | general | You may need to look for some library already defining such functions | 2019-01-14T02:46:14.289600 | Lynne |
elmlang | general | <@Lynne> The problem is the number input from user, so the digits after comma is arbitrary | 2019-01-14T02:50:13.289800 | Raymonde |
elmlang | general | I understand, just replace `4.1` with whatever you parse from that input then | 2019-01-14T02:58:22.290000 | Lynne |
elmlang | general | The most crucial part here is multiplying by 10^N, ceiling and then dividing by 10^N where N is number of digits after comma | 2019-01-14T02:59:12.290200 | Lynne |
elmlang | general | Are you saying that you don't know exactly how many digits after comma you want? | 2019-01-14T02:59:37.290400 | Lynne |
elmlang | general | Yeah | 2019-01-14T02:59:46.290600 | Raymonde |
elmlang | general | I see | 2019-01-14T02:59:50.290800 | Lynne |
elmlang | general | I am actually not sure it is possible to solve this without knowing number of digits | 2019-01-14T03:00:31.291100 | Lynne |
elmlang | general | Due to the nature of floating point numbers | 2019-01-14T03:00:55.291300 | Lynne |
elmlang | general | At some point rounding should happen | 2019-01-14T03:01:26.291500 | Lynne |
elmlang | general | There is <https://package.elm-lang.org/packages/myrho/elm-round/latest/> | 2019-01-14T03:01:44.291700 | Jin |
elmlang | general | So I have to parse the number of digits from the input number first. That’s not ideal. | 2019-01-14T03:02:00.291900 | Raymonde |
elmlang | general | I would actually check what problem you are trying to solve | 2019-01-14T03:04:36.292100 | Lynne |
elmlang | general | For most tasks in the world 4 digits are usually enough | 2019-01-14T03:04:45.292300 | Lynne |
elmlang | general | You already have to turn the textual input into a number, probably. This would be a good place to also check for the significant digits. | 2019-01-14T03:05:02.292600 | Jin |
elmlang | general | For displaying | 2019-01-14T03:05:03.292800 | Lynne |
elmlang | general | If you are not sure, use 5 or 10 digits. Unnecessary zeroes will go anyway so it will cover most of the inputs probably | 2019-01-14T03:05:37.293000 | Lynne |
elmlang | general | I’m implementing a custom input like this, note the `+` is always there, might be `-` according to the number. | 2019-01-14T03:07:52.293200 | Raymonde |
elmlang | general | <@Raymonde> Just to make this clear, this is **not** an Elm-specific issue. The reason this is happening is how floating point numbers arithmetics work in JavaScript (Elm relies on JS numbers at the low level), and a whole lot of other languages including C, Java, and so on. | 2019-01-14T03:09:35.293800 | Bert |
elmlang | general | I think it is an architectural issue. I.e. x86, x64 or whatever else | 2019-01-14T03:10:23.294000 | Lynne |
elmlang | general | Where is the code and how is it broken? | 2019-01-14T03:11:00.294200 | Bert |
elmlang | general | IEEE floating point | 2019-01-14T03:12:00.294400 | Iona |
elmlang | general | Exactly | 2019-01-14T03:12:33.294600 | Lynne |
elmlang | general | OK, got it, I think I can parse the digits number from input to solve this. Not ideal though. | 2019-01-14T03:12:53.294800 | Raymonde |
elmlang | general | You could try <https://package.elm-lang.org/packages/prikhi/decimal/latest/Decimal> too | 2019-01-14T03:16:57.295000 | Bert |
elmlang | general | And use elm-round which <@Jin> suggested. It mentions there still can be issues with multiply/divide approach | 2019-01-14T03:17:07.295200 | Lynne |
Subsets and Splits