이 글은 하스켈 위키북스 Haskell/GADT를 읽고 정리한 것이다.
- Generalized Algebraic DataTypes
- GHC 확장
- 데이터 타입 선언 시 값 생성자에 타입을 적을 수 있게 한다.
data Maybe a where
import java.util.*; | |
public class Main { | |
public static void main(String[] args) { | |
Scanner sc = new Scanner(System.in); | |
int n = sc.nextInt(); | |
int m = sc.nextInt(); | |
int[] trees = new int[n]; | |
for (int i = 0; i < n; i++) |
import java.util.*; | |
class ListOfInteger extends ArrayList<Integer> {} | |
class Graph extends HashMap<Integer,ListOfInteger> {} | |
public class Main { | |
static List discovered = new ListOfInteger(); | |
static List explored = new ListOfInteger(); |
module Tree where | |
data Tree a = Leaf a | |
| Node (Tree a) (Tree a) | |
deriving Show | |
type WithCounter a = Int -> (a, Int) | |
numberOfLeaves :: Tree a -> Integer | |
numberOfLeaves (Leaf _) = 1 |
{-# LANGUAGE GADTs #-} | |
module Operational where | |
import Control.Monad | |
data Program instr a where | |
Then :: instr a -> (a -> Program instr b) -> Program instr b | |
Return :: a -> Program instr a |
이 글은 하스켈 위키북스 Haskell/GADT를 읽고 정리한 것이다.
data Maybe a where
import java.util.*; | |
public class Main { | |
static Scanner sc; | |
public static void main(String[] args) { | |
sc = new Scanner(System.in); | |
while (true) { | |
int w = sc.nextInt(); | |
int h = sc.nextInt(); |
import java.util.*; | |
public class Main { | |
static Map<Integer, List<Integer>> map; | |
static Map<Integer, Integer> dp; | |
public static void main(String[] args) { | |
Scanner sc = new Scanner(System.in); | |
int n = sc.nextInt(); | |
int m = sc.nextInt(); |
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
{-# LANGUAGE LambdaCase #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
module Main where | |
import Data.List | |
import Data.Text | |
import Numeric.Natural |