Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Aug 22 18:24
    parsonsmatt commented #952
  • Aug 22 11:14
    erikd commented #952
  • Aug 22 11:13
    erikd commented #952
  • Aug 22 11:13
    erikd commented #952
  • Aug 22 11:11
    erikd commented #952
  • Aug 21 23:28
    parsonsmatt commented #952
  • Aug 21 23:13
    erikd edited #952
  • Aug 21 23:10
    erikd opened #952
  • Aug 21 23:08
    parsonsmatt closed #949
  • Aug 21 23:04
    erikd commented #949
  • Aug 21 15:12

    parsonsmatt on master

    Add comment explaining transact… Encourage use of runSqlConn ove… Merge pull request #951 from in… (compare)

  • Aug 21 15:12
    parsonsmatt closed #951
  • Aug 21 07:06
    erikd commented #950
  • Aug 21 05:40
    erikd commented #951
  • Aug 21 05:34
    erikd commented #950
  • Aug 21 05:32
    erikd commented #950
  • Aug 21 05:27
    erikd edited #951
  • Aug 21 05:26
    erikd opened #951
  • Aug 21 05:09
    erikd closed #950
  • Aug 21 05:09
    erikd commented #950
Victor Miroshnikov
@superduper
@gregwebs Yay!
That could work for yesod web part too ;)
Greg Weber
@gregwebs
yeah, but I think there is already an established IRC channel #yesod
Victor Miroshnikov
@superduper
Oh, thats correct. I like irc, but gitter has more well integrated features like history search and github integration.
I wonder if gitter.im has in plans irc bridging. That would be a killer feature IMO.
Maximilian Tagher
@MaxGabriel
Hi guys
Greg Weber
@gregwebs
Hi Max!
Maximilian Tagher
@MaxGabriel
Hey Greg, at the meetup on Wednesday I heard you talking to someone about Elm for frontend programming
But I wasn't really paying attention
Any conclusions on if it's worth learning? I read through some docs on their website and did some of their tutorials
Maximilian Tagher
@MaxGabriel
Anyone know how to run ghci to load modules from the test suite? Something like: stack ghci --main-is /test/main.hs ?
Greg Weber
@gregwebs
in general I think stack ghci is supposed to bring test stuff into scope. I structure my test modules so that each one can be run from ghci using hspec
I think the Elm Architecture is informing the rest of Javascript UI development now (it is similar to Flux. redux is directly modeled after it). I am planning on talking on this subject at the next meetup
Maximilian Tagher
@MaxGabriel
Oh sweet
Christine Dodrill
@Xe
I'm having trouble defining a set of data models: https://gist.github.com/Xe/ffb1394e315f39804cbf
Divam
@dfordivam
@gregwebs Hi Greg, the persistent-mongodb package on stackage doesn't have the > 2.5 version, though hackage has. Is this intended because of some incompatibility or the stackage has not been upated yet?
Rui Afonso Pereira
@rpereira

Hey guys. I'm using Servant and Database.Persist.Postgresql and struggling with relations in persistent. Perhaps you guys can give me some help, please :) I have the two following entities:

Schedule json
  trainId       Int
  stationId     StationId
  srcStationId  Int
  dstStationId  Int
  arrivalTime   UTCTime Maybe
  departureTime UTCTime Maybe
  deriving Show

Station json
  name      Text
  crsCode Text sqltype=varchar(3)
  UniqueCode crsCode tiplicCode
  deriving Show

I'm trying to get all schedule trains for a given station. So far this is what I have:

getScheduleForStation :: Text -> App [Entity Schedule]
getScheduleForStation crsCode = do
  station <- runDb (selectFirst [StationId ==. crsCode] [])
  runDb (selectList [ScheduleStationId ==. station] [])

and this is the error I'm getting:

/Users/rap/code/thesis/TicketReservation/src/Api/Schedule.hs:29:34: error:
    • Couldn't match type ‘Text’ with ‘Key Station’
        arising from a use of ‘StationId’
    • In the first argument of ‘(==.)’, namely ‘StationIdIn the expression: StationId ==. crsCode
      In the first argument of ‘selectFirst’, namely
        ‘[StationId ==. crsCode]’

/Users/rap/code/thesis/TicketReservation/src/Api/Schedule.hs:30:22: error:
    • Couldn't match type ‘Maybe (Entity Station)’ withKey Station’
        arising from a use of ‘ScheduleStationId’
    • In the first argument of ‘(==.)’, namely ‘ScheduleStationIdIn the expression: ScheduleStationId ==. station
      In the first argument of ‘selectList’, namely
        ‘[ScheduleStationId ==. station]’

can anyone please help me understand what's wrong with the relation? Thanks in advance.

odsogunro
@odsogunro

hello all
a beginner here
I am looking for the best haskell ORM to use for abstracting SQL and NoSQL backends.
I have been using/working with Yesod's persistent and made progress; however, I am having problems connecting to an existing database in sqlite3 using persistent.

https://pastebin.com/ChaB0zG7

Felix Schlitter
@felixSchl
@odsogunro what's your problem?
Question: Is there a way to perform data migrations using persistent? By that I mean a way to safely write a migration in haskell code that will only be executed once on a given database.
Felix Schlitter
@felixSchl
Another question: is it possible to insert an Entity? I have a bunch of records with existing ids that I need to insert
Eugen Kuksa
@eugenk
@felixSchl , if you have an id, then it's already inserted. The id is generated at insertion.

Is it possible to create an index on an sql table column? I don't mean a unique index. Just a regular index without constraints.
Example:

share [mkPersist sqlSettings, mkMigrate "migrateAll"] [persistLowerCase|
MyObject
  myValue String
  UniqueMyValue myValue
|]

would create a unique index on the column myValue, but how would I create a regular index?

Felix Schlitter
@felixSchl
@eugenk yes, but if you have data from elsewhere that already has ids then you need to insert an existing id. anyway, i asked that in july and have long solved it :P It's pretty quite in here. I'd be interested in the index question, too.
to be honest, i think you would need to create that index in an extra sql script
Eugen Kuksa
@eugenk
@felixSchl how have you inserted the ids?
Eugen Kuksa
@eugenk
thanks
Eugen Kuksa
@eugenk
@felixSchl I searched the source code of persistent and could not find any trace of creating indexes
Ricardo Sanchez
@ricksanchez
Hello, is somebody using Esqueleto? do you know about some way to unValue tuples? e.g. (Value x, Value y, Value z) = (x,y,z) or some generic way to run functions in tuples?

I made a class with a type family for this issue:

class EsqueletoValued m where
    type ValuesResult m
    unValueTuple :: m -> ValuesResult m

But maybe there is an existing solution in Esqueleto

Felix Schlitter
@felixSchl
@ricksanchez I don't think so, but I am curious how does code look like with your solution?
Ricardo Sanchez
@ricksanchez
@felixSchl I made instances for a simple value and tuples of 2 elements to 8, and a function selectUnvalue, so I can use the values directly, without having to pattern match the constructor. The (Value x,...) is something that really makes me feel not DRY at all. Needless to say, this only applies for tuples without Entity
Ricardo Sanchez
@ricksanchez
or maybe a new operator that returns the values without Value, does it exist? if no, is it worthy to add it to esqueleto?
Sandy Maguire
@isovector
hey! is there an easy way to add instrumentation to the individual actual IO actions that hit sql dbs?
i want to add some automatic timing around them
Alexis King
@lexi-lambda
I would really like to find a way to fix this issue I opened a couple days ago, but the persist-template code is rather confusing to me. yesodweb/persistent#729
It seems like Database.Persist.TH makes some awkward assumptions and relies very heavily on names rather than bindings, so it only looks at the syntactic structure of field types. I was looking to see if there was a place I could insert a call to reifyRoles, but it doesn’t seem obvious to me.
Is solving that issue hopeless without restructuring the way it handles fields, or is there something I could do to get it working, even in a hacky way?
Maximilian Tagher
@MaxGabriel
Maybe wrap runDB with some function that takes the time before and after, and sends it off to STATSD or something?
@isovector
naushadh
@naushadh

re: instrumentation - @MaxGabriel such a runDB wrapper would only show how long database call(s) took. What would be ideal is to capture stats of each call (sql + duration). Sometimes an inefficient database query does not manifest itself until it's already in Production (an unusual amount of data added to a table that used to be small).

I can think of couple of options

  • quick and dirty: bracket each database query with timing and log it along with the query. persistent users either then manually grep through logs or use a log processor to push to say statsD.

  • stats tooling: persistent adds ability to track the timing+sql of each database query (ex: in an IORef) and exposes an API to get the latest stats (ex: getStats or runDbWithStats).

Sibi
@psibi

@MaxGabriel Saw your change to Yesod wiki - https://github.com/yesodweb/yesod/wiki/ghci/_compare/02fd78f%5E...02fd78f

IIRC, that page has been migrated to yesod-cookbook repo previously. We really need to fix up the yesod wiki (Just like how persistent wiki was cleaned up some months ago).

Maximilian Tagher
@MaxGabriel
Ah ok, yeah I remember now
Steven Leiva
@StevenXL
Folks, a little help
Where does db come from?
Steven Leiva
@StevenXL
@psibi thank you. I was able to find it eventually. Appreciate the help!