Skip to content

Instantly share code, notes, and snippets.

View liarokapisv's full-sized avatar

Liarokapis Alexandros liarokapisv

View GitHub Profile
@liarokapisv
liarokapisv / conanfile.py
Created January 20, 2023 11:53
gcc-arm-none-eabi recipe
from conan import ConanFile
from conan.tools.layout import basic_layout
from conan.tools.files import copy, get
from conan.errors import ConanInvalidConfiguration
import os
class ArmToolchainConan(ConanFile):
name = "arm-toolchain"
settings = "os", "arch"
@liarokapisv
liarokapisv / Main.hs
Created March 14, 2021 10:39
Ast Transformation - De bruijn Annotation along with Validation using Data.Comp.Multi
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE QuantifiedConstraints #-}
@liarokapisv
liarokapisv / Main.hs
Last active March 13, 2021 18:39
Annotate de bruijn using compdata
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE ViewPatterns #-}
import Data.Comp.Multi.Derive
import Data.Comp.Multi.Algebra
@liarokapisv
liarokapisv / recursion-schemes-annotation.hs
Created March 11, 2021 21:07
Renaming ast using cata
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveFoldable #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE TemplateHaskell #-}
import Data.Functor.Base
import Data.Functor.Foldable
import Data.Functor.Foldable.TH
import Data.Validation
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE PatternSynonyms #-}
data NatE = NZero | NDouble NatG
deriving Show
data NatO = NSucc NatE
deriving Show
type NatG = Either NatE NatO
toInt0 :: NatE -> Int
toInt0 NZero = 0
toInt0 (NDouble n) = 2 * (toInt n)
@liarokapisv
liarokapisv / bt.hs
Created July 5, 2020 15:21
Foldables vs Recursion Schemes
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveFoldable #-}
{-# LANGUAGE DeriveTraversable #-}
import Data.Functor.Foldable
import Data.Functor.Foldable.TH
import game.PlayerModel;
import game.PlayerView;
import game.Player;
import game.GameState;
import java.util.Map;
public class PlayerController
{
public class PlayerController(Map<Player, PlayerModel> modelMap, Map<Player, PlayerView> viewMap)
@liarokapisv
liarokapisv / Errors
Created March 11, 2018 20:39
Error handling
data A
data A'
data B
data B'
data C
data C'
data ExtraX
mutual
renameFuncCall : AnnFuncCall ParserAnn -> Renamer (AnnFuncCall RenamerAnn)
renameFuncCall ((MkFuncCall x xs) .+. y) = [| [| MkFuncCall (renameIdentifier Func x)
(traverse renameExpr xs) |] .+. [|y|] |]
renameExpr : AnnExpr ParserAnn -> Renamer (AnnExpr RenamerAnn)
renameExpr ((IntConst x) .+. y) = [| [| IntConst (renameIntConst x) |] .+. [|y|] |]
renameExpr ((CharConst x) .+. y) = [| [| CharConst (renameCharConst x) |] .+. [|y|] |]
renameExpr ((Lvalue x) .+. y) = [| [| Lvalue (renameLvalue x) |] .+. [|y|] |]