Home freenode/#haskell: Logs Calendar

Logs: freenode/#haskell

←Prev  Next→ 502,152 events total
2020-11-13 11:14:04 <ski> (seems `runFSM' doesn't use the `out' part .. so you could probably set it to `undefined', so far)
2020-11-13 11:15:15 <ski> you could use other types (e.g. user-defined) for the state type, and the input and output symbol/token types, if you wanted to
2020-11-13 11:15:27 <ski> e.g. you could define
2020-11-13 11:16:04 <ski> data ExampleState = S0 | S1 | S2 | S3 | S4 deriving (Eq,Show)
2020-11-13 11:16:15 <ski> and then use `ExampleState' in place of `Int'
2020-11-13 11:16:36 <royal_screwup21> ahh I see, for now I'd prefer using the built in types to keep things simple :)
2020-11-13 11:16:42 ski nods
2020-11-13 11:17:36 <vilpan> merijn: you mentioned 20+ Haskell openings in EU. Is there a dedicated site/aggregator?
2020-11-13 11:18:19 × howdoi quits (uid224@gateway/web/irccloud.com/x-odsmdwwzesbrmhor) (Quit: Connection closed for inactivity)
2020-11-13 11:18:28 jakalx joins (~jakalx@base.jakalx.net)
2020-11-13 11:19:15 <royal_screwup21> ski I've got this so far https://ideone.com/pH4Czq do I have to define my custom arbitrary function for trans?
2020-11-13 11:19:23 dbmikus__ joins (~dbmikus@cpe-76-167-86-219.natsow.res.rr.com)
2020-11-13 11:20:00 <ski> yes
2020-11-13 11:20:24 <royal_screwup21> hmm
2020-11-13 11:21:08 bitmagie joins (~Thunderbi@200116b8068f010041b23aab865e3023.dip.versatel-1u1.de)
2020-11-13 11:22:12 × alp quits (~alp@2a01:e0a:58b:4920:3450:37c2:436b:8f86) (Ping timeout: 260 seconds)
2020-11-13 11:22:16 <ski> `trans' needs to be able to handle the state `0', and any states that can be reached from that state (by using `trans')
2020-11-13 11:22:57 <Uniaika> (“fuck the state” – trans people)
2020-11-13 11:23:09 <royal_screwup21> ski I just did trans state input = state + 1
2020-11-13 11:24:17 × dbmikus__ quits (~dbmikus@cpe-76-167-86-219.natsow.res.rr.com) (Ping timeout: 260 seconds)
2020-11-13 11:25:11 <ski> hm, in that case you don't really have *finite* number of states, do you ?
2020-11-13 11:25:25 <ski> @quote is.no.state
2020-11-13 11:25:25 <lambdabot> MonadState says: Do not try to change the state; that's impossible. Instead only try to realize the truth: There is no state.
2020-11-13 11:28:04 <ski> royal_screwup21 : you could cap the state at some number, like `9' e.g.
2020-11-13 11:28:28 <ski> > iterate (\n -> min 9 (n + 1)) 0
2020-11-13 11:28:31 <lambdabot> [0,1,2,3,4,5,6,7,8,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9...
2020-11-13 11:31:39 <royal_screwup21> ski I've found an example like so https://ideone.com/UKDuIo all I want to do is run it against the runFSM function, just to get a feel fro what's happening
2020-11-13 11:32:42 cfricke joins (~cfricke@unaffiliated/cfricke)
2020-11-13 11:33:37 × Yumasi quits (~guillaume@2a01cb09b06b29ea5faf5572fb93fcc2.ipv6.abo.wanadoo.fr) (Ping timeout: 260 seconds)
2020-11-13 11:34:49 <ski> royal_screwup21> runFSM isEven [Zero,Zero,One,Zero,One]
2020-11-13 11:35:02 × acidjnk_new quits (~acidjnk@p200300d0c718f669e4bb3e68b1aef453.dip0.t-ipconnect.de) (Ping timeout: 260 seconds)
2020-11-13 11:35:14 <ski> (btw, i would write `Moore (const ())')
2020-11-13 11:35:38 jamm_ joins (~jamm@unaffiliated/jamm)
2020-11-13 11:37:45 <royal_screwup21> ski thanks a lot for the pointers :)
2020-11-13 11:38:02 <royal_screwup21> I don't quite understand what's going on in this line: `out = Moore $ const ()`
2020-11-13 11:39:44 <ski> replace it by :
2020-11-13 11:39:50 <ski> out = Moore (const ())
2020-11-13 11:39:52 <ski> or
2020-11-13 11:40:03 <ski> out = Moore (\_ -> ())
2020-11-13 11:40:06 <ski> or
2020-11-13 11:40:10 <ski> out = Moore moore
2020-11-13 11:40:10 × Sanchayan quits (~Sanchayan@2401:4900:3309:dec3:efb6:6366:cb4:cbe4) (Quit: leaving)
2020-11-13 11:40:13 <ski> where
2020-11-13 11:40:19 <ski> moore _ = ()
2020-11-13 11:40:39 <ski> royal_screwup21 : do any of those three versions make it clearer ?
2020-11-13 11:40:59 × revprez_anzio quits (~revprez_a@pool-108-49-213-40.bstnma.fios.verizon.net) (Quit: Lost terminal)
2020-11-13 11:41:03 <royal_screwup21> so it's a function that takes something and returns...()?
2020-11-13 11:41:14 <royal_screwup21> what is the ()? Is it null in haskell?
2020-11-13 11:41:31 <royal_screwup21> (hard to google :( )
2020-11-13 11:41:32 <ski> oh, well, i suppose you'd have to put the `moore _ = ()' part after the `where' above where you define `trans'
2020-11-13 11:41:44 <ski> there is no "null" in Haskell
2020-11-13 11:41:59 <ski> `()' is the empty tuple, the zero-tuple
2020-11-13 11:42:17 <ski> just like `(x,y)' is the two-tuple, the pair, containing `x' and `y' as components
2020-11-13 11:42:21 <royal_screwup21> ah ok
2020-11-13 11:42:42 <ski> an `n'-tuple has `n' components. a pair, a two-tuple has two components, a zero-tuple has zero components
2020-11-13 11:43:30 <royal_screwup21> yup gotcha, thanks :)
2020-11-13 11:43:45 <royal_screwup21> I don't really get that definiton though:
2020-11-13 11:43:46 <royal_screwup21> data OutFunc state input output
2020-11-13 11:43:47 <royal_screwup21> = Moore (state -> output)
2020-11-13 11:43:47 <royal_screwup21> | Mealy (state -> input -> output)
2020-11-13 11:44:02 <royal_screwup21> like, how am I meant to instantiate it and then apply it?
2020-11-13 11:44:16 <ski> (if you have done any linear algebra with matrices and vectors, you could compare the zero-tuple to an "empty" vector with no coefficients in it, being a vector in ⌜ℝ⁰⌝, a zero-dimensional vector space)
2020-11-13 11:44:58 <royal_screwup21> so I know I can do something like `thing = Moore (\x -> x)`
2020-11-13 11:45:14 <royal_screwup21> but now how do I actually run it against an input?
2020-11-13 11:46:28 <ski> the type `()' corresponds more or less to the type `void' in C,C++,Java,C#. also to empty `struct' type (`struct {}', no components), in C,C++,C# (or rather, extensions that allow it). it has a single value (also written `()', in Haskell)
2020-11-13 11:47:03 <ski> you'd typically use `()' as an output (or part of an output), when you don't have any interesting information to put there
2020-11-13 11:47:07 martinsos joins (~user@cpe-188-129-116-164.dynamic.amis.hr)
2020-11-13 11:47:18 <royal_screwup21> yup all that makes sense, it's just an empty tuple
2020-11-13 11:47:18 martinsos parts (~user@cpe-188-129-116-164.dynamic.amis.hr) ()
2020-11-13 11:47:59 <ski> `thing = Moore (\x -> x)' would not work, if you have `isEven :: FSM EvenState Binary ()'
2020-11-13 11:48:27 <royal_screwup21> ski I just created an arbitrary function, not related to isEeven
2020-11-13 11:48:43 <royal_screwup21> I just want to understand how to run `thing` some input
2020-11-13 11:48:52 <ski> because then your `state' type is `EvenState' and your `output' type is `()', and your moore function should have type `state -> output', that is `EvenState -> ()', but `\x -> x' does not have this type
2020-11-13 11:49:26 <ski> <royal_screwup21> but now how do I actually run it against an input?
2020-11-13 11:49:32 <ski> i already answered this :
2020-11-13 11:49:33 <ski> <ski> royal_screwup21> runFSM isEven [Zero,Zero,One,Zero,One]
2020-11-13 11:50:21 <royal_screwup21> but that's the runFSM function. I want to run `thing` which of type `thing :: OutFunc output input output`
2020-11-13 11:51:40 × niko quits (~niko@freenode/staff/ubuntu.member.niko) (Ping timeout: 619 seconds)
2020-11-13 11:52:29 <ski> oh
2020-11-13 11:53:05 <ski> well, it could be a `Mealy' transition function
2020-11-13 11:53:33 <ski> so, i think you'd have to provide both a state and an input
2020-11-13 11:53:50 <ski> er, s/transition/output/
2020-11-13 11:54:01 carlomagno joins (~cararell@148.87.23.6)
2020-11-13 11:54:07 <ski> you could try to define
2020-11-13 11:54:08 alp joins (~alp@2a01:e0a:58b:4920:ed84:e1ea:bd3d:3a34)
2020-11-13 11:54:22 <ski> output :: OutFunc state input output -> state -> input -> output
2020-11-13 11:54:42 roconnor joins (~roconnor@host-184-164-7-99.dyn.295.ca)
2020-11-13 11:54:52 <royal_screwup21> hmm so I've done this on ghci: thing = Moore (\x -> x). My understand is that I've defined a function (wrapped in a variant) that takes an x and returns back an x
2020-11-13 11:54:55 <ski> and then you could call `output thing E0 Zero', e.g.
2020-11-13 11:55:07 <royal_screwup21> basically, how do I run that function?
2020-11-13 11:55:12 × ubert quits (~Thunderbi@p200300ecdf1e535be6b318fffe838f33.dip0.t-ipconnect.de) (Ping timeout: 260 seconds)
2020-11-13 11:55:33 <ski> you need to pattern-match, to extract the function from the variant alternative, from the data constructor
2020-11-13 11:55:41 <royal_screwup21> ahh ok
2020-11-13 11:55:57 <ski> but in general, it could be either a `Moore' or a `Mealy', and you should most probably cover both cases
2020-11-13 11:55:57 <royal_screwup21> that makes sense, thanks!
2020-11-13 11:56:12 <ski> and defining a function like `output' may help with this
2020-11-13 11:56:16 <royal_screwup21> I'm not really sure what the point is of having it in the fsm...
2020-11-13 11:56:24 × carlomagno1 quits (~cararell@148.87.23.13) (Ping timeout: 272 seconds)
2020-11-13 11:56:32 <royal_screwup21> the runFSM function doesn't seem to use it
2020-11-13 11:56:46 <royal_screwup21> is it just there to confuse the beginner?

All times are in UTC.