Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
Valeyard
Mar 30, 2012


Grimey Drawer

gonadic io posted:

io is literally the reason that monads exist in haskell.

I wasn't following it then, but there was a system before monads used to delimit io and stop you using io unsafely. Then somebody suggested monads and we've never looked back.

drat I knew it was one way or the other but couldnt remember which way

Adbot
ADBOT LOVES YOU

AWWNAW
Dec 30, 2008

Plorkyeran posted:

like the whole point of ?. and >>= is to let you call a function from A -> B on a value of A? and get a result of B?

no, it's a null-safe dereferencing helper, butt.?trash.?poo poo.?smegma all of those intermediate properties can be of any type, and i'm pretty sure any ultimate result is going to be nullable

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

Plorkyeran posted:

like the whole point of ?. and >>= is to let you call a function from A -> B on a value of A? and get a result of B?

you just described what haskell calls a functor. think like mapping over a list

>>= is to let you call a function from A -> B? on a value of A? and get a B?

Bloody
Mar 3, 2013

pretty sure ?. is basically snytactic sugar for
if(lhs != null) return lhs.rhs; else return null;
which, yeah, is basically the same as Maybe a >>= a -> Maybe b

CPColin
Sep 9, 2003

Big ol' smile.

Awia posted:

that's cheating

Is it just me or does it smell like "amonad" in here?

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

Bloody posted:

pretty sure ?. is basically snytactic sugar for
if(lhs != null) return lhs.rhs; else return null;
which, yeah, is basically the same as Maybe a >>= a -> Maybe b

the definition on Maybe is like
code:
x >>= f =
  case x of
    Nothing -> Nothing
    Just x' -> f x'

fart simpson fucked around with this message at 20:24 on Mar 21, 2016

gonadic io
Feb 16, 2011

>>=
E: nvm

gonadic io fucked around with this message at 20:27 on Mar 21, 2016

Deep Dish Fuckfest
Sep 6, 2006

Advanced
Computer Touching


Toilet Rascal

hackbunny posted:

you want a technical windows debugger with an arcane command language, try windbg. it's not as nice as vs, it's only really good for debugging native code where vs will let you debug scripts and tsql and .net and whatnot, but it's super low level, in some regards lower than even gdb. it has surprising uses too, like you can use it as a disassembler (by loading an executable as a crash dump), you can debug the live kernel (can't set breakpoints ofc) to read low level system data, you can diagnose bsods by loading crash dumps and using the !analyze extension. it used to be available as a standalone but it seems nowadays you have to download the whole driver development kit to get it

i did take a look at it out of curiosity before, but i don't have any use for it that would make it worthwhile to spend time learning it. the only feature the vs debugger doesn't have (last time i checked) which i wish it did, but which windbg does have, is automatically attaching to all processes spawned by a process which you're already attached to. learning windbg just for that is kind of overkill, even if it would make things a lot easier sometimes

i do know that when there's a bug that seems to be coming from some microsoft code, they'll sometimes ask to attach windbg and tell you to type in some incomprehensible series of character that makes perl look normal and then send them the result

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

gonadic io posted:

That's the definition of map, >>= doesn't insert a Just at the end and instead lets f decide to return a Just or a Nothing

oh yah i wrote the wrong thing and just edited it

gonadic io
Feb 16, 2011

>>=
Hey Bloody, a good exercise is implementing Functor and Monad (and applicative) for a bunch of Base types like Maybe, List and Identity

Applicative on lists has two possible valid but different ways of doing it that behave totally differently

data Identity a = Iden a

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

fart simpson posted:

oh yah i wrote the wrong thing and just edited it

this is why i like haskell btw, if i was actually writing that it wouldnt compile and i would have seen the problem right away

Bloody
Mar 3, 2013

i have no idea how to parse but i made a type for representing verilog numeric literals and defined a function to convert them to actual numbers :3:

Bloody
Mar 3, 2013

code:
numericToInteger (Hex _ a) = sum . reverse . map (\(x, y) -> 16^x * y) . zip [0..] . reverse . map digitToInt $ a
lol

this was the first rube goldbergian attempt that actually worked

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

gonadic io posted:

Hey Bloody, a good exercise is implementing Functor and Monad (and applicative) for a bunch of Base types like Maybe, List and Identity

Applicative on lists has two possible valid but different ways of doing it that behave totally differently

data Identity a = Iden a

thats easy
code:
import Control.Monad.Free
...

Bloody
Mar 3, 2013

itt liveblogging haskell learning time

oh no blimp issue
Feb 23, 2011

http://www.imada.sdu.dk/~rolf/Edu/DM22/F06/haskell-operatorer.pdf
i found that useful when i was learning haskell

gonadic io
Feb 16, 2011

>>=

gonadic io posted:

Hey Bloody, a good exercise is implementing Functor and Monad (and applicative) for a bunch of Base types like Maybe, List and Identity

Applicative on lists has two possible valid but different ways of doing it that behave totally differently

data Identity a = Iden a

I should reiterate that this is in no way necessary to use Haskell, only to make it less magical.

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:


ive never used some of those

gonadic io
Feb 16, 2011

>>=
>@> wtf lol, never heard of tht before. it's not in control.monad.

gonadic io
Feb 16, 2011

>>=
p.s. if anybody was curious about io pre monads, there essentially wasn't any: http://stackoverflow.com/questions/17002119/haskell-pre-monadic-i-o

gonadic io
Feb 16, 2011

>>=

Bloody posted:

code:
numericToInteger (Hex _ a) = sum . reverse . map (\(x, y) -> 16^x * y) . zip [0..] . reverse . map digitToInt $ a
lol

this was the first rube goldbergian attempt that actually worked

p.s. don't reverse right before summing.


(unless you're using a really wacky integral type for which + isn't associative but I doubt this)

i'd go with

code:
numericToInteger (Hex _ bits) = sum $ zipWith f [0..] $ reverse bits
    where f x y = 16^x * digitToInt y
(and give f a better name)

but what you came up with was not at all terrible

gonadic io fucked around with this message at 21:10 on Mar 21, 2016

Bloody
Mar 3, 2013

Oh yeah good point

there's probably a better way with zero reverses tbh

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

if you reverse your indexes so instead of starting from 0 and going up you start from len - 1 and go down then you wont need to reverse will you?

gonadic io
Feb 16, 2011

>>=

Bloody posted:

Oh yeah good point

there's probably a better way with zero reverses tbh

lists being singly linked makes this harder than you think. you could zip with "iterate (negate 1) (length a -1)" to get a list counting down but length is O(n) anyway so there's no point.

e: if you're using a type where length doesn't traverse the whole collection then it's for sure better (or if you know your length ahead of time) but the default list type won't see an improvement using length

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

default lists in haskell seem like the wrong choice for a lot of things

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

like String

gonadic io
Feb 16, 2011

>>=

fart simpson posted:

default lists in haskell seem like the wrong choice for a lot of things

yes. really yes. parsing? poo poo. string operations? poo poo. unicode? unusable. anything at all that isn't iterating once over them? poo poo.

there's a reason that the first answer on every single SO "why is this haskell code slow?" is to stop using the default lists

they are easily remimplementable by beginners though. on the other hand, most other langs have opaque types just fine so i don't see this as much of an advantage.

god haskell's lists get me mad

one of valeyard's questions when he was learning was "how to do string replace"? the answer is literally to convert to data.text, do the op, and then go back again. or use the regex library which i'm sure does the same thing with worse syntax.

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

the actual answer is to just use Data.Text instead of using String at all

VikingofRock
Aug 24, 2008




Bloody posted:

Oh yeah good point

there's probably a better way with zero reverses tbh

I'd do this:

code:
numericToInteger :: String -> Int
numericToInteger = foldl' step 0
    where step x y = x*16 + digitToInt y
possibly with better naming. You can also pretty trivially make this work with Text instead by using Text.foldl' instead.

Progressive JPEG
Feb 19, 2003

i think gdb is ok but ive mainly used it on server code in controlled scenarios like tracing a deadlock in a stress test across multiple multithreaded processes which is :suicide: regardless of what debugger im using

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY
one distributed systems ppl might find interesting:

http://arxiv.org/pdf/1602.02672v1.pdf

quote:

Learning to Communicate to Solve Riddles with
Deep Distributed Recurrent Q-Networks


We propose deep distributed recurrent Qnetworks
(DDRQN), which enable teams of
agents to learn to solve communication-based coordination
tasks. In these tasks, the agents are
not given any pre-designed communication protocol.
Therefore, in order to successfully communicate,
they must first automatically develop
and agree upon their own communication protocol.
We present empirical results on two multiagent
learning problems based on well-known
riddles, demonstrating that DDRQN can successfully
solve such tasks and discover elegant communication
protocols to do so. To our knowledge,
this is the first time deep reinforcement
learning has succeeded in learning communication
protocols. In addition, we present ablation
experiments that confirm that each of the main
components of the DDRQN architecture are critical
to its success.

Bloody
Mar 3, 2013

i parsed a csv file

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

Bloody posted:

i parsed a csv file

:worship:

Bloody
Mar 3, 2013

i put a rather wide data bus in my fpga and now the toolchain is crashing and its just doing pre-synthesis checks lmao

gently caress fpga tools forever

Bloody
Mar 3, 2013

literally all it is doing right now should be emitting code that says reallyWidePortA -> reallyWidePortB. a CPU core has been pegged for several minutes to accomplish this task.

akadajet
Sep 14, 2003

https://petitions.whitehouse.gov/petition/outlaw-programming-languages-threaten-safety-american-people-and-work-counter-our-way-life


:rolleyes: javascript doesn't belong in that list.

MrMoo
Sep 14, 2000

shock horror, workmen blaming the tools for their own failings.

Finster Dexter
Oct 20, 2014

Beyond is Finster's mad vision of Earth transformed.
Or it's a joke

prefect
Sep 11, 2001

No one, Woodhouse.
No one.




Dead Man’s Band

Finster Dexter posted:

Or it's a joke

jokes?

in my internet?

Adbot
ADBOT LOVES YOU

VikingofRock
Aug 24, 2008




Bloody posted:

i parsed a csv file

:cheers: Nice! Did you handle escaping and everything?

  • Locked thread