Skip to content

Instantly share code, notes, and snippets.

@bergmark
bergmark / Compiler.hs
Last active April 9, 2022 14:41
Parsing JSON in Haskell vs Rust
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeApplications #-}
module Compiler (Version, Compiler) where
import Control.Monad ((<=<))
import Data.Aeson (FromJSON (..))
data Version = Version String
@bergmark
bergmark / comments.txt
Last active June 21, 2021 16:31
commenter example run
BiobaseBlast-0.3.3.0 ([changelog](http://hackage.haskell.org/package/BiobaseBlast-0.3.3.0/changelog)) (Florian Eggenhofer <florian.eggenhofer@univie.ac.at> @eggzilla) is out of bounds for:
- [ ] RNAlien-1.7.0 (==0.3.1.*). Florian Eggenhofer <florian.eggenhofer@univie.ac.at> @eggzilla. @eggzilla. Used by: library
BiobaseFasta-0.4.0.1 ([changelog](http://hackage.haskell.org/package/BiobaseFasta-0.4.0.1/changelog)) (Florian Eggenhofer <florian.eggenhofer@univie.ac.at> @eggzilla) is out of bounds for:
- [ ] RNAlien-1.7.0 (==0.3.0.*). Florian Eggenhofer <florian.eggenhofer@univie.ac.at> @eggzilla. @eggzilla. Used by: library
BiobaseHTTP-1.2.0 ([changelog](http://hackage.haskell.org/package/BiobaseHTTP-1.2.0/changelog)) (Florian Eggenhofer <florian.eggenhofer@univie.ac.at> @eggzilla) is out of bounds for:
- [ ] RNAlien-1.7.0 (==1.1.0). Florian Eggenhofer <florian.eggenhofer@univie.ac.at> @eggzilla. @eggzilla. Used by: library
@bergmark
bergmark / ForLoop.hs
Last active March 16, 2021 12:04
Yes, haskell has for loops
module Main where
import Control.Monad
import Control.Monad.IO.Class
import Control.Monad.Trans.State
main :: IO ()
main = do
forLoop 0 (< 10) (+ 1)
print

Keybase proof

I hereby claim:

  • I am bergmark on github.
  • I am bergmark (https://keybase.io/bergmark) on keybase.
  • I have a public key ASAp5pMEPBNqDl4XHeTMtzBg2VsGxMl4316UVSQZbD6AXgo

To claim this, I am signing this object:

Magic: Wanted 33214052,
got 33214052
Version: Wanted [8, 0, 4, 3],
got [8, 0, 4, 3]
Way: Wanted [],
got []
interface Data.Aeson.Parser.Internal 8043
interface hash: 6c48b91f954a886667298160132ec1f5
ABI hash: cbc607c318f4c74423c0c6c39b768837
export-list hash: b58d6e2302b000257458873f6a7faddd
sealed trait State
case class WithOffer(offer: Offer) extends State
object WithOffer {
implicit val hasOffer: HasOffer[WithOffer] = _.offer
}
case class WithoutOffer() extends State
case class WithPartner(partnerName: String) extends State
#!/usr/bin/env scala
trait DbRep[A] {
type Rep
}
class Email
object EmailRep extends DbRep[Email] {
override type Rep = String
}
#!/usr/bin/env scala
trait DbRep[A] {
type Rep
}
class Email
object EmailRep extends DbRep[Email] {
override type Rep = String
}
trait Foo[A]
object A {
implicit val foo: Foo[Int] = new Foo[Int] {}
}
object B {
implicit val foo: Foo[String] = new Foo[String] {}
}
object C {
data Vect : (n: Nat) -> (elem : Type) -> Type where
Empty : Vect 0 elem
OneAnd : elem -> Vect n elem -> Vect (S n) elem
showString : Show elem => Vect n elem -> String
showString Empty = ""
showString (OneAnd x y) = show x ++ showString y
Show elem => Show (Vect n elem) where
show = showString