profile
viewpoint
If you are wondering where the data of this site comes from, please visit https://api.github.com/users/jonascarpay/events. GitMemory does not store any data, but only uses NGINX to cache data for a period of time. The idea behind GitMemory is simply to give users a better reading experience.

jonascarpay/apecs 304

a fast, type driven, extensible ECS for game development

jonascarpay/apecs-physics 46

2D physics and rendering for apecs

jonascarpay/convoluted 27

Dependently typed convolutional neural networks

jonascarpay/declarative-cachix 11

Add cachix caches declaratively

jonascarpay/Maxwell-manager 4

The Maxwell Manager

jonascarpay/dolphin 1

A fork of dolphin that, when taking melee screenshots, includes part of the game state in the filename

push eventjonascarpay/nord-openvpn-configs

Jonas Carpay

commit sha 27ec41742b61f10e091fea3357e5b94b080e6153

Nord configs at Fri Sep 17 03:00:07 PM UTC 2021

view details

push time in 2 days

create barnchjonascarpay/nix

branch : nextcloud

created branch time in 3 days

push eventjonascarpay/nord-openvpn-configs

Jonas Carpay

commit sha 21ea23c5e820eb2025328f3c1b83e3ddc981167e

Nord configs at Thu Sep 16 03:00:14 PM UTC 2021

view details

push time in 3 days

push eventjonascarpay/nord-openvpn-configs

Jonas Carpay

commit sha 5741a74c60e95517cb535db716a6615c8bb2bb2f

Nord configs at Wed Sep 15 03:00:18 PM UTC 2021

view details

push time in 4 days

push eventjonascarpay/nord-openvpn-configs

Jonas Carpay

commit sha 17c16f262da6ffc812807912748e861906825e9b

Nord configs at Tue Sep 14 03:00:41 PM UTC 2021

view details

push time in 5 days

push eventcdepillabout/cabal2nixWithoutIFD

Jonas Carpay

commit sha 6de7db7118872e44c1a285b644bd4359f838c345

Constructors

view details

Jonas Carpay

commit sha 8c275aa940c25f344c54832b7ad4de536568564b

WIP case statements

view details

Jonas Carpay

commit sha 3b5002eec28c17736311e266fab4f2f77c9bb1ef

Pattern matching

view details

Jonas Carpay

commit sha 44815885889da13a50b1e150fdd9310d9a60421a

Fix parenthesization

view details

Jonas Carpay

commit sha 44310954ef2771eeef7858be58ede88becdb33f5

Clean up string handling

view details

Jonas Carpay

commit sha efb41706d326cbd379e850baba6a887e955d14fe

Fix attr parenthesization

view details

Jonas Carpay

commit sha 7ad7aaf0cb63da14c88ab3d5dbd719bfd149b03d

Put single field attr sets on a single line

view details

Jonas Carpay

commit sha 7acc2cf6963a82415cd1f6f7431e7427a48b343a

Fix indexing of sum constructors

view details

Jonas Carpay

commit sha 00f7e55c551036f2a32d806f59dc4797c7d55dcb

Drop `?` binary expr

view details

Jonas Carpay

commit sha e928fe068b214f26dbda4b68df1b78748c5c54df

Fix binary operator parenthesization

view details

Jonas Carpay

commit sha 4b02da8ce4afae1784f16008e654c1cd4bd96139

Merge pattern binds and scrutinee declarations

view details

Jonas Carpay

commit sha 9ef77eb1ed33824ec468d6fe15cd8cc86fe82862

Make let bindings NonEmpty

view details

Jonas Carpay

commit sha 6c293ae57020d389a224c832bdea638b4cb972a2

Improve formatting for conditionals

view details

Jonas Carpay

commit sha ae59bf1ce167305964ac87cbec6d5ecb2bc63a64

Fix pattern matching error for always-pass patterns

view details

Jonas Carpay

commit sha bfd26e584c44ae55b9ab83fd1bb2cbb2e07648f0

Don't print FFI if it's not used

view details

Jonas Carpay

commit sha 0d9b6a3b68817bca467a0a192fd74b390b4a2bd1

Define Path precedence

view details

Jonas Carpay

commit sha 246ddf1ed9bdfcdcadb506c265ca8d33bad490f5

Remove outdated docs

view details

Jonas Carpay

commit sha 0c751277f0bd95404eb4353bf6303fd0e1b4a1b8

Add haddocks for `alternative`

view details

Jonas Carpay

commit sha c76d4b57f61fdb038627c79320b9eb188d8693cb

Print inherit-only attr sets on one line

view details

Jonas Carpay

commit sha 6c137cfea888ada35154124960626595f77cbe70

Don't defer scrutinees

view details

push time in 6 days

delete branch cdepillabout/cabal2nixWithoutIFD

delete branch : constructors

delete time in 6 days

PR merged cdepillabout/cabal2nixWithoutIFD

Constructors
module Main where

import Prelude

data Maybe a = Nothing | Just a

data FBB a
  = Foo
  | Bar a
  | Baz a a

myCase :: FBB (Maybe Int) -> Int
myCase fbb = case fbb of
  Foo -> 0
  Bar Nothing -> 1
  Bar (Just n) -> n + 1
  Baz (Just a) (Just b) | a + b < 9 -> 9
  Baz _ Nothing -> 10
  Baz Nothing _ -> 11
  Baz (Just _) (Just _) | otherwise -> 12

myMultiCase :: Maybe Int -> Maybe Int -> Int
myMultiCase a b = case a, (\x -> x) b of
  Nothing, Nothing -> 0
  Just n, Nothing -> n
  Just n, Just m | n < 9 -> n + m
  _, _ -> 2

turns into

modules: 
let
  Nothing = {__tag = "Nothing";};
  Just = value0: 
    { inherit value0;
      __tag = "Just";
      __field0 = value0;
    };
  Foo = {__tag = "Foo";};
  Bar = value0: 
    { inherit value0;
      __tag = "Bar";
      __field0 = value0;
    };
  Baz = value0: value1: 
    { inherit value0 value1;
      __tag = "Baz";
      __field0 = value0;
      __field1 = value1;
    };
  myMultiCase = a: b: 
    let
      v = (x: x) b;
      v1 = a;
    in
      
      let
        __pattern0 = __fail: if v1.__tag == "Nothing" && v.__tag == "Nothing" then 0 else __fail;
        __pattern1 = __fail: 
          if v1.__tag == "Just" && v.__tag == "Nothing"
            then 
              let
                n = v1.__field0;
              in
                n
            else __fail;
        __pattern2 = __fail: 
          if v1.__tag == "Just" && v.__tag == "Just"
            then 
              let
                n = v1.__field0;
                m = v.__field0;
              in
                if modules."Data.Ord".lessThan modules."Data.Ord".ordInt n 9 then modules."Data.Semiring".add modules."Data.Semiring".semiringInt n m else __fail
            else __fail;
        __pattern3 = __fail: 2;
        __pattern4 = builtins.throw "Pattern match failure";
      in
        __pattern0 (__pattern1 (__pattern2 (__pattern3 __pattern4)));
  myCase = fbb: 
    let
      __pattern0 = __fail: if fbb.__tag == "Foo" then 0 else __fail;
      __pattern1 = __fail: if fbb.__tag == "Bar" && fbb.__field0.__tag == "Nothing" then 1 else __fail;
      __pattern2 = __fail: 
        if fbb.__tag == "Bar" && fbb.__field0.__tag == "Just"
          then 
            let
              n = fbb.__field0.__field0;
            in
              modules."Data.Semiring".add modules."Data.Semiring".semiringInt n 1
          else __fail;
      __pattern3 = __fail: 
        if fbb.__tag == "Baz" && (fbb.__field0.__tag == "Just" && fbb.__field1.__tag == "Just")
          then 
            let
              a = fbb.__field0.__field0;
              b = fbb.__field1.__field0;
            in
              if modules."Data.Ord".lessThan modules."Data.Ord".ordInt (modules."Data.Semiring".add modules."Data.Semiring".semiringInt a b) 9 then 9 else __fail
          else __fail;
      __pattern4 = __fail: if fbb.__tag == "Baz" && fbb.__field1.__tag == "Nothing" then 10 else __fail;
      __pattern5 = __fail: if fbb.__tag == "Baz" && fbb.__field0.__tag == "Nothing" then 11 else __fail;
      __pattern6 = __fail: if fbb.__tag == "Baz" && (fbb.__field0.__tag == "Just" && fbb.__field1.__tag == "Just") then if modules."Data.Boolean".otherwise then 12 else __fail else __fail;
      __pattern7 = builtins.throw "Pattern match failure";
    in
      __pattern0 (__pattern1 (__pattern2 (__pattern3 (__pattern4 (__pattern5 (__pattern6 __pattern7))))));
in
  {inherit Nothing Just Foo Bar Baz myCase myMultiCase __ffi;}
+249 -118

0 comment

4 changed files

jonascarpay

pr closed time in 6 days

push eventjonascarpay/nix

Jonas Carpay

commit sha 5a79827673fcbd0579ff0a3811f1638cce458148

fish: cn abbr

view details

Jonas Carpay

commit sha b703f9403c12399434c95d82f77d530f5c28f0d3

flake: bump

view details

Jonas Carpay

commit sha 11534e4676965e8eb524007da7e49d294d062456

vim: lsp trouble plugin

view details

Jonas Carpay

commit sha 73ef6db79dc3427feedd00bf5cbb6c1b271a405b

openvpn: update hk server

view details

Jonas Carpay

commit sha f25c99f496b7af7b2ba81ea979fda75ec998ed68

formatting: Alphabetization

view details

push time in 6 days

push eventcdepillabout/cabal2nixWithoutIFD

Jonas Carpay

commit sha cc13fcc87716bb8f975bb7c5055c05db34267b27

Update purenix/src/Nix/Convert.hs Co-authored-by: Dennis Gosnell <cdep.illabout@gmail.com>

view details

push time in 6 days

Pull request review commentcdepillabout/cabal2nixWithoutIFD

Constructors

 checkKeyword w   | otherwise = pure w   where     -- These idents have a special meaning in purenix.-    purenixIdents = ["modules", "__ffi"]+    purenixIdents = ["modules", "__tag", "__ffi"]

also __fieldX

jonascarpay

comment created time in 6 days

PullRequestReviewEvent

push eventjonascarpay/nord-openvpn-configs

Jonas Carpay

commit sha 5f3933fb4a6b154d9d0d5b28ee534605331091be

Nord configs at Mon Sep 13 03:00:12 PM UTC 2021

view details

push time in 6 days

push eventcdepillabout/cabal2nixWithoutIFD

Jonas Carpay

commit sha 53ac4e9fee13388f3ab5a26c941ca23f0c10bc49

Print source of pattern match failure

view details

push time in 7 days

push eventcdepillabout/cabal2nixWithoutIFD

Jonas Carpay

commit sha c5c279f40faa94dc8a141bd193b4472cf3573a8d

Pattern matching on objects

view details

Jonas Carpay

commit sha 650b083a28ff846d53a96b13138269357451b630

rename go -> litBinder

view details

push time in 7 days

push eventcdepillabout/cabal2nixWithoutIFD

Jonas Carpay

commit sha 162264b4adf546a90e80bac7c7eeeaeb0ba7d128

Don't export `__ffi`

view details

Jonas Carpay

commit sha d9bdc86cbf9bdbd9e65d66d5c121fe95851ffcfc

Fix warnings

view details

push time in 7 days

PullRequestReviewEvent

Pull request review commentcdepillabout/cabal2nixWithoutIFD

Constructors

 style a _ Single = a style _ b Multi = b  exprStyle :: ExprF Style -> Style+exprStyle (Attrs _ [] []) = Single+exprStyle (Attrs [] [(sty, _)] []) = sty+exprStyle (Attrs [] [] [(_, sty)]) = sty exprStyle Attrs {} = Multi exprStyle Let {} = Multi exprStyle v = bool Single Multi $ elem Multi v -exprPrec :: ExprF a -> Int-exprPrec Var {} = 10-exprPrec Num {} = 10-exprPrec Path {} = 10-exprPrec String {} = 10-exprPrec Attrs {} = 10-exprPrec List {} = 10-exprPrec Sel {} = 9-exprPrec App {} = 8+newtype Precedence = Precedence Int deriving newtype (Num, Eq, Ord)++data Associativity = AssocLeft | AssocRight | AssocNone+  deriving (Eq, Show)++exprAssoc :: ExprF a -> Associativity+exprAssoc Sel {} = AssocLeft+exprAssoc App {} = AssocLeft+exprAssoc (Bin op _ _) = opAssoc op+  where+    opAssoc Update = AssocRight

Done in 8e7c93a248344a685d12a2a234f8421875514919

jonascarpay

comment created time in 7 days

push eventcdepillabout/cabal2nixWithoutIFD

Jonas Carpay

commit sha 8e7c93a248344a685d12a2a234f8421875514919

Add support for associative parenthesization

view details

push time in 7 days

PullRequestReviewEvent

Pull request review commentcdepillabout/cabal2nixWithoutIFD

Constructors

 bin op a b = Expr $ Bin op a b  path :: Text -> Expr path = Expr . Path++numberedNames :: Text -> [Ident]+numberedNames prefix = fmap (\n -> prefix <> T.pack (show n)) [0 :: Int ..]++constructorFieldNames :: [Ident]+constructorFieldNames = numberedNames "__field"++negate :: Expr -> Expr+negate = Expr . Not++builtin :: Text -> Expr+builtin = sel (var "builtins")++--   Just+-- becomes+--   (a: { __tag = "Just"; __field0 = a; })+constructor :: Ident -> [Ident] -> Expr+constructor conName fields =+  foldr+    lam+    ( attrs+        fields

Oh I see, that's really neat

jonascarpay

comment created time in 7 days

push eventcdepillabout/cabal2nixWithoutIFD

Jonas Carpay

commit sha 8df7a8b56fdc8f642873226b46b0b54622a09940

Update purenix/src/Nix/Expr.hs Co-authored-by: Dennis Gosnell <cdep.illabout@gmail.com>

view details

push time in 7 days

Pull request review commentcdepillabout/cabal2nixWithoutIFD

Constructors

 bin op a b = Expr $ Bin op a b  path :: Text -> Expr path = Expr . Path++numberedNames :: Text -> [Ident]+numberedNames prefix = fmap (\n -> prefix <> T.pack (show n)) [0 :: Int ..]++constructorFieldNames :: [Ident]+constructorFieldNames = numberedNames "__field"++negate :: Expr -> Expr+negate = Expr . Not++builtin :: Text -> Expr+builtin = sel (var "builtins")++--   Just+-- becomes+--   (a: { __tag = "Just"; __field0 = a; })+constructor :: Ident -> [Ident] -> Expr+constructor conName fields =+  foldr+    lam+    ( attrs+        fields

Did you try named record field accessors? I sort of assumed that the 'value' names were just defaults in case of nameless fields

jonascarpay

comment created time in 7 days

PullRequestReviewEvent

push eventcdepillabout/cabal2nixWithoutIFD

Jonas Carpay

commit sha fc21b67602490589b0ba9a0109222f350bf70099

Reword/add haddocks

view details

push time in 8 days

Pull request review commentcdepillabout/cabal2nixWithoutIFD

Constructors

 bin op a b = Expr $ Bin op a b  path :: Text -> Expr path = Expr . Path++numberedNames :: Text -> [Ident]+numberedNames prefix = fmap (\n -> prefix <> T.pack (show n)) [0 :: Int ..]++constructorFieldNames :: [Ident]+constructorFieldNames = numberedNames "__field"++negate :: Expr -> Expr+negate = Expr . Not++builtin :: Text -> Expr+builtin = sel (var "builtins")++--   Just+-- becomes+--   (a: { __tag = "Just"; __field0 = a; })+constructor :: Ident -> [Ident] -> Expr+constructor conName fields =+  foldr+    lam+    ( attrs+        fields

I wasn't sure what to best do here. My thinking was that it's nice to have named fields when using constructors in the FFI somewhere, but I guess that only works when deconstructing, since modifying/constructing requires properly handling the __tag and __fieldX attrs anyway.

The annoying thing is that, when pattern matching, ConstructorBinder doesn't give you the names of fields, just their positions, so you need positional accessors.

jonascarpay

comment created time in 8 days

PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentcdepillabout/cabal2nixWithoutIFD

Constructors

 style a _ Single = a style _ b Multi = b  exprStyle :: ExprF Style -> Style+exprStyle (Attrs _ [] []) = Single+exprStyle (Attrs [] [(sty, _)] []) = sty+exprStyle (Attrs [] [] [(_, sty)]) = sty exprStyle Attrs {} = Multi exprStyle Let {} = Multi exprStyle v = bool Single Multi $ elem Multi v -exprPrec :: ExprF a -> Int-exprPrec Var {} = 10-exprPrec Num {} = 10-exprPrec Path {} = 10-exprPrec String {} = 10-exprPrec Attrs {} = 10-exprPrec List {} = 10-exprPrec Sel {} = 9-exprPrec App {} = 8+newtype Precedence = Precedence Int deriving newtype (Num, Eq, Ord)++data Associativity = AssocLeft | AssocRight | AssocNone+  deriving (Eq, Show)++exprAssoc :: ExprF a -> Associativity+exprAssoc Sel {} = AssocLeft+exprAssoc App {} = AssocLeft+exprAssoc (Bin op _ _) = opAssoc op+  where+    opAssoc Update = AssocRight

Yeah, I guess it's like mappend for maps, which is obviously associative?

Also, in the example generated code I posted you can see an expression consisting of only &&s in which one && term is parenthesized because it occurs in the right in the AST. I was thinking it might be worth adding an Associative :: Associativity to avoid some parens in these cases, that could also apply here.

jonascarpay

comment created time in 8 days

push eventcdepillabout/cabal2nixWithoutIFD

Jonas Carpay

commit sha 489b28f1d4b3d5567fc33eab4cece5773f61ca66

Typo in comment Co-authored-by: Dennis Gosnell <cdep.illabout@gmail.com>

view details

push time in 8 days